mirror of
https://github.com/intel/llvm.git
synced 2026-01-24 00:20:25 +08:00
[CMake] Introduce POLLY_BUNDLED_JSONCPP.
Allow using a system's install jsoncpp library instead of the bundled one with the setting POLLY_BUNDLED_JSONCPP=OFF. This fixes llvm.org/PR32929 Differential Revision: https://reviews.llvm.org/D32922 llvm-svn: 302336
This commit is contained in:
@@ -179,11 +179,25 @@ else()
|
||||
set(ISL_TARGET PollyISL)
|
||||
endif()
|
||||
|
||||
option(POLLY_BUNDLED_JSONCPP "Use the bundled version of jsoncpp included in Polly" ON)
|
||||
if (POLLY_BUNDLED_JSONCPP)
|
||||
set(JSONCPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/External/JSON/include")
|
||||
set(JSONCPP_LIBRARIES)
|
||||
set(POLLY_JSON_FILES
|
||||
External/JSON/json_reader.cpp
|
||||
External/JSON/json_value.cpp
|
||||
External/JSON/json_writer.cpp
|
||||
)
|
||||
else ()
|
||||
find_package(Jsoncpp REQUIRED)
|
||||
set(POLLY_JSON_FILES)
|
||||
endif ()
|
||||
|
||||
include_directories(
|
||||
BEFORE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${ISL_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/JSON/include
|
||||
${JSONCPP_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/pet/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
|
||||
58
polly/cmake/FindJsoncpp.cmake
Normal file
58
polly/cmake/FindJsoncpp.cmake
Normal file
@@ -0,0 +1,58 @@
|
||||
find_package(PkgConfig QUIET)
|
||||
if (PkgConfig_FOUND)
|
||||
pkg_search_module(JSONCPP jsoncpp QUIET)
|
||||
|
||||
# Get the libraries full paths, to be consistent with find_library().
|
||||
set(fulllibs)
|
||||
foreach (libname IN LISTS JSONCPP_LIBRARIES)
|
||||
find_library(lib NAMES ${libname}
|
||||
HINTS ${JSONCPP_LIBDIR} ${JSONCPP_LIBRARY_DIRS}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (lib)
|
||||
list(APPEND fulllibs ${lib})
|
||||
else ()
|
||||
list(APPEND fulllibs ${libname})
|
||||
endif ()
|
||||
endforeach ()
|
||||
set(JSONCPP_LIBRARIES ${fulllibs})
|
||||
|
||||
set(JSONCPP_DEFINITIONS ${JSONCPP_CFLAGS})
|
||||
else ()
|
||||
set(JSONCPP_DEFINITIONS)
|
||||
|
||||
find_path(JSONCPP_INCLUDE_DIR json/json.h
|
||||
PATHS ENV JSONCPP_INCLUDE ENV JSONCPP_DIR
|
||||
PATH_SUFFIXES jsoncpp
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_path(JSONCPP_INCLUDE_DIR json/json.h
|
||||
PATH_SUFFIXES jsoncpp
|
||||
)
|
||||
mark_as_advanced(JSONCPP_INCLUDE_DIR)
|
||||
set(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIR}")
|
||||
|
||||
find_library(JSONCPP_LIBRARY NAMES jsoncpp
|
||||
HINTS ENV JSONCPP_LIB ENV JSONCPP_DIR
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(JSONCPP_LIBRARY NAMES jsoncpp)
|
||||
mark_as_advanced(JSONCPP_LIBRARY)
|
||||
set(JSON_LIBRARIES ${JSON_LIBRARY})
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Jsoncpp DEFAULT_MSG JSONCPP_INCLUDE_DIRS JSONCPP_LIBRARIES JSONCPP_DEFINITIONS)
|
||||
|
||||
if (Jsoncpp_FOUND)
|
||||
add_library(jsoncpp INTERFACE IMPORTED)
|
||||
foreach (incl IN LISTS JSONCPP_INCLUDE_DIRS)
|
||||
set_property(TARGET jsoncpp APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
|
||||
endforeach ()
|
||||
foreach (libname IN LISTS JSONCPP_LIBRARIES)
|
||||
set_property(TARGET jsoncpp APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
|
||||
endforeach ()
|
||||
foreach (opt IN LISTS JSONCPP_DEFINITIONS)
|
||||
set_property(TARGET jsoncpp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})
|
||||
endforeach ()
|
||||
endif ()
|
||||
@@ -5,6 +5,7 @@ find_package(LLVM REQUIRED CONFIG
|
||||
|
||||
set(Polly_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(Polly_BUNDLED_ISL @POLLY_BUNDLED_ISL@)
|
||||
set(Polly_BUNDLED_JSONCPP @POLLY_BUNDLED_JSONCPP@)
|
||||
set(Polly_ENABLE_GPGPU_CODEGEN @POLLY_ENABLE_GPGPU_CODEGEN@)
|
||||
|
||||
set(Polly_DEFINITIONS ${LLVM_DEFINITIONS})
|
||||
@@ -27,6 +28,7 @@ if (NOT TARGET Polly)
|
||||
if (Polly_ENABLE_GPGPU_CODEGEN)
|
||||
set_property(TARGET Polly APPEND PROPERTY INTERFACE_LINK_LIBRARIES PollyPPCG)
|
||||
endif()
|
||||
set_property(TARGET Polly APPEND PROPERTY INTERFACE_LINK_LIBRARIES @JSONCPP_LIBRARIES@)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET LLVMPolly)
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
set(LLVM_NO_RTTI 1)
|
||||
|
||||
set(POLLY_JSON_FILES
|
||||
External/JSON/json_reader.cpp
|
||||
External/JSON/json_value.cpp
|
||||
External/JSON/json_writer.cpp
|
||||
)
|
||||
|
||||
set(ISL_CODEGEN_FILES
|
||||
CodeGen/IslAst.cpp
|
||||
CodeGen/IslExprBuilder.cpp
|
||||
@@ -77,6 +71,7 @@ set_target_properties(PollyCore PROPERTIES FOLDER "Polly")
|
||||
add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>)
|
||||
target_link_libraries(Polly
|
||||
${ISL_TARGET}
|
||||
${JSONCPP_LIBRARIES}
|
||||
)
|
||||
|
||||
# Additional dependencies for Polly-ACC.
|
||||
@@ -158,7 +153,7 @@ else ()
|
||||
# hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON
|
||||
# instead which will automatically resolve the additional dependencies by
|
||||
# Polly.
|
||||
target_link_libraries(LLVMPolly ${ISL_TARGET})
|
||||
target_link_libraries(LLVMPolly ${ISL_TARGET} ${JSONCPP_LIBRARIES})
|
||||
if (GPU_CODEGEN)
|
||||
target_link_libraries(LLVMPolly PollyPPCG)
|
||||
endif ()
|
||||
|
||||
Reference in New Issue
Block a user