[Cmake] Optionally use a system isl version.
This patch adds an option to build against a version of libisl already installed on the system. The installation is autodetected using the pkg-config file shipped with isl. The detection of the library is in the FindISL.cmake module that creates an imported target. Contributed-by: Philip Pfaffe <philip.pfaffe@gmail.com> Differential Revision: https://reviews.llvm.org/D30043 llvm-svn: 296361
This commit is contained in:
parent
47e7d7fe85
commit
6469380daa
|
|
@ -158,12 +158,24 @@ if (CUDALIB_FOUND)
|
|||
INCLUDE_DIRECTORIES( ${CUDALIB_INCLUDE_DIR} )
|
||||
endif(CUDALIB_FOUND)
|
||||
|
||||
option(POLLY_BUNDLED_ISL "Use the bundled version of libisl included in Polly" ON)
|
||||
if (NOT POLLY_BUNDLED_ISL)
|
||||
find_package(ISL MODULE REQUIRED)
|
||||
message(STATUS "Using external libisl ${ISL_VERSION} in: ${ISL_PREFIX}")
|
||||
set(ISL_TARGET ISL)
|
||||
else()
|
||||
set(ISL_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lib/External/isl/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/isl/include
|
||||
)
|
||||
set(ISL_TARGET PollyISL)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
BEFORE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${ISL_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/JSON/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lib/External/isl/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/isl/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External/pet/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/External
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(ISL isl)
|
||||
if (NOT ISL_FOUND EQUAL 1)
|
||||
message(FATAL_ERROR "No libisl found on this system. Consider setting PKG_CONFIG_PATH.")
|
||||
endif()
|
||||
|
||||
add_library(ISL INTERFACE IMPORTED)
|
||||
foreach (incl IN LISTS ISL_INCLUDE_DIRS)
|
||||
set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
|
||||
endforeach()
|
||||
|
||||
foreach (libname IN LISTS ISL_LIBRARIES)
|
||||
if (ISL_LIBRARY_DIRS)
|
||||
foreach (dir IN LISTS ISL_LIBRARY_DIRS)
|
||||
list(APPEND hints ${dir})
|
||||
endforeach()
|
||||
endif()
|
||||
find_library(lib NAMES ${libname} HINTS ${hints} NO_DEFAULT_PATH)
|
||||
set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
|
||||
endforeach()
|
||||
|
||||
foreach (opt IN LISTS ISL_CFLAGS ISL_CFLAGS_OTHER)
|
||||
set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})
|
||||
endforeach()
|
||||
|
|
@ -66,7 +66,7 @@ if (GPU_CODEGEN)
|
|||
target_link_libraries(Polly PollyPPCG)
|
||||
endif (GPU_CODEGEN)
|
||||
|
||||
target_link_libraries(Polly PollyISL)
|
||||
target_link_libraries(Polly ${ISL_TARGET})
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
target_link_libraries(Polly
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# External: Integer Set Library
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
set(ISL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/isl")
|
||||
set(ISL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/isl")
|
||||
|
||||
|
|
@ -263,7 +264,6 @@ add_polly_library(PollyISL
|
|||
)
|
||||
|
||||
|
||||
# TODO: optionally use system isl instead
|
||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
||||
install(DIRECTORY
|
||||
${ISL_SOURCE_DIR}/include/
|
||||
|
|
@ -288,6 +288,7 @@ target_link_libraries(polly-isl-test
|
|||
# ISL requires at least C99 to compile. gcc < 5.0 use -std=gnu89 as default.
|
||||
target_enable_c99(PollyISL)
|
||||
target_enable_c99(polly-isl-test)
|
||||
endif (POLLY_BUNDLED_ISL)
|
||||
|
||||
set(PET_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pet")
|
||||
set(PPCG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ppcg")
|
||||
|
|
@ -335,7 +336,7 @@ add_polly_library(PollyPPCG
|
|||
${PPCG_FILES}
|
||||
)
|
||||
|
||||
target_link_libraries(PollyPPCG PollyISL)
|
||||
target_link_libraries(PollyPPCG ${ISL_TARGET})
|
||||
|
||||
# Disable warnings for upstream projects.
|
||||
if (MSVC)
|
||||
|
|
@ -346,13 +347,16 @@ if (MSVC)
|
|||
-wd4201 # nonstandard extension used: nameless struct/union
|
||||
-wd4334 # 'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
|
||||
)
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
target_compile_options(PollyISL PRIVATE ${DISABLE_WARNING_FLAGS})
|
||||
target_compile_options(polly-isl-test PRIVATE ${DISABLE_WARNING_FLAGS})
|
||||
endif (POLLY_BUNDLED_ISL)
|
||||
target_compile_options(PollyPPCG PRIVATE ${DISABLE_WARNING_FLAGS})
|
||||
else ()
|
||||
set_target_properties(PollyISL polly-isl-test PollyPPCG PROPERTIES
|
||||
COMPILE_FLAGS "-w"
|
||||
)
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
set_target_properties(PollyISL polly-isl-test PROPERTIES COMPILE_FLAGS "-w")
|
||||
endif (POLLY_BUNDLED_ISL)
|
||||
set_target_properties(PollyPPCG PROPERTIES COMPILE_FLAGS "-w")
|
||||
endif ()
|
||||
|
||||
if(MSVC)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|||
# We are building polly out of tree, adjust the settings.
|
||||
# FIXME: FileCheck is not available in llvm install directory at the moment.
|
||||
set(LLVM_LIT ${LLVM_INSTALL_ROOT}/bin/llvm-lit)
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
set(POLLY_TEST_DEPS LLVMPolly polly-isl-test)
|
||||
endif (POLLY_BUNDLED_ISL)
|
||||
if (POLLY_GTEST_AVAIL)
|
||||
list(APPEND POLLY_TEST_DEPS PollyUnitTests)
|
||||
endif ()
|
||||
|
|
@ -101,6 +103,8 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg)
|
||||
|
||||
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
add_custom_target(check-polly-isl
|
||||
command ${LLVM_LIT}
|
||||
--param polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg
|
||||
|
|
@ -110,12 +114,16 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|||
DEPENDS polly-isl-test
|
||||
COMMENT "Running isl unit tests")
|
||||
set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly")
|
||||
endif (POLLY_BUNDLED_ISL)
|
||||
endif()
|
||||
|
||||
else (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
||||
|
||||
set(LLVM_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit)
|
||||
set(POLLY_TEST_DEPS llvm-config opt LLVMPolly FileCheck not polly-isl-test)
|
||||
set(POLLY_TEST_DEPS llvm-config opt LLVMPolly FileCheck not)
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
list(APPEND POLLY_TEST_DEPS polly-isl-test)
|
||||
endif()
|
||||
if (POLLY_GTEST_AVAIL)
|
||||
list(APPEND POLLY_TEST_DEPS PollyUnitTests)
|
||||
endif ()
|
||||
|
|
@ -158,12 +166,14 @@ else (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg)
|
||||
|
||||
if (POLLY_BUNDLED_ISL)
|
||||
add_lit_testsuite(check-polly-isl "Running isl unit tests only"
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UnitIsl
|
||||
PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg
|
||||
DEPENDS polly-isl-test
|
||||
)
|
||||
set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly")
|
||||
endif (POLLY_BUNDLED_ISL)
|
||||
|
||||
# Run polly-check-format as part of polly-check only if we are compiling with
|
||||
# clang, so clang-format is available.
|
||||
|
|
|
|||
Loading…
Reference in New Issue