Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -207,6 +207,7 @@ add_subdirectory(unittests) endif () add_subdirectory(tools) +add_subdirectory(cmake) # TODO: docs. Index: cmake/CMakeLists.txt =================================================================== --- /dev/null +++ cmake/CMakeLists.txt @@ -0,0 +1,58 @@ +# Keep this in sync with llvm/cmake/CMakeLists.txt! +set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") +set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") + +set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly") +set(polly_cmake_builddir "${POLLY_BINARY_DIR}/${POLLY_INSTALL_PACKAGE_DIR}") + +if (BUILD_SHARED_LIBS) + set(POLLY_CONFIG_LIBKIND SHARED) +else() + set(POLLY_CONFIG_LIBKIND STATIC) +endif() + +if (NOT POLLY_BUNDLED_ISL) + get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + get_property(lib TARGET ISL PROPERTY INTERFACE_LINK_LIBRARIES) + get_property(opt TARGET ISL PROPERTY INTERFACE_COMPILE_OPTIONS) + set(ISL_CONFIG_CODE " +add_library(ISL INTERFACE IMPORTED) +set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl}) +set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib}) +set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})") +else() + set(ISL_CONFIG_CODE " +if (NOT TARGET PollyISL) + add_library(PollyISL ${POLLY_CONFIG_LIBKIND} IMPORTED) +endif()") +endif() + +# Generate PollyConfig.cmake for the build tree. +set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}") +set(POLLY_CONFIG_CMAKE_DIR "${polly_cmake_builddir}") + + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in + ${polly_cmake_builddir}/PollyConfig.cmake + @ONLY) + + +# Generate PollyConfig.cmake for the install tree. +set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") +set(POLLY_CONFIG_LLVM_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") +set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") +if (POLLY_BUNDLED_ISL) + set(ISL_INCLUDE_DIRS "${POLLY_INSTALL_PREFIX}/include/polly") +endif() + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake + @ONLY) + +if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake" + DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}") +endif () Index: cmake/PollyConfig.cmake.in =================================================================== --- /dev/null +++ cmake/PollyConfig.cmake.in @@ -0,0 +1,32 @@ +# This file allows users to call find_package(Polly) and pick up our targets. + +find_package(LLVM REQUIRED CONFIG + HINTS "@POLLY_CONFIG_LLVM_CMAKE_DIR@") + + +set(Polly_CMAKE_DIR "@POLLY_CONFIG_CMAKE_DIR@") +set(Polly_DEFINITIONS ${LLVM_DEFINITIONS}) +set(Polly_INCLUDE_DIRS "@POLLY_CONFIG_INCLUDE_DIRS@" ${LLVM_INCLUDE_DIRS} @ISL_INCLUDE_DIRS@) +set(Polly_LIBRARY_DIRS ${LLVM_LIBRARY_DIRS}) +set(Polly_LIBRARIES ${LLVM_LIBRARIES} @ISL_TARGET@ PollyPPCG Polly) +set(Polly_BUNDLED_ISL @POLLY_BUNDLED_ISL) + +set(Polly_EXPORTED_TARGETS @ISL_TARGET@ PollyPPCG Polly LLVMPolly) + +@ISL_CONFIG_CODE@ + +# TODO: put includes and definitions on the INTERFACE as well +if (NOT TARGET PollyPPCG) + add_library(PollyPPCG @POLLY_CONFIG_LIBKIND@ IMPORTED) + target_link_libraries(PollyPPCG INTERFACE @ISL_TARGET@) +endif() + +if (NOT TARGET Polly) + add_library(Polly @POLLY_CONFIG_LIBKIND@ IMPORTED) + target_link_libraries(Polly INTERFACE @ISL_TARGET@ PollyPPCG) +endif() + +if (NOT TARGET LLVMPolly) + add_library(LLVMPolly @POLLY_CONFIG_LIBKIND@ IMPORTED) + target_link_libraries(LLVMPolly INTERFACE Polly) +endif()