Index: polly/trunk/CMakeLists.txt =================================================================== --- polly/trunk/CMakeLists.txt +++ polly/trunk/CMakeLists.txt @@ -179,11 +179,25 @@ 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 Index: polly/trunk/cmake/FindJsoncpp.cmake =================================================================== --- polly/trunk/cmake/FindJsoncpp.cmake +++ polly/trunk/cmake/FindJsoncpp.cmake @@ -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 () Index: polly/trunk/cmake/PollyConfig.cmake.in =================================================================== --- polly/trunk/cmake/PollyConfig.cmake.in +++ polly/trunk/cmake/PollyConfig.cmake.in @@ -5,6 +5,7 @@ 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 (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) Index: polly/trunk/lib/CMakeLists.txt =================================================================== --- polly/trunk/lib/CMakeLists.txt +++ polly/trunk/lib/CMakeLists.txt @@ -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 @@ add_polly_library(Polly $) target_link_libraries(Polly ${ISL_TARGET} + ${JSONCPP_LIBRARIES} ) # Additional dependencies for Polly-ACC. @@ -158,7 +153,7 @@ # 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 ()