Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -66,7 +66,14 @@ target_link_libraries(Polly PollyISL) -if (BUILD_SHARED_LIBS) +if (LLVM_LINK_LLVM_DYLIB) + target_link_libraries(Polly + LLVM + ) + link_directories( + ${LLVM_LIBRARY_DIR} + ) +elseif (BUILD_SHARED_LIBS OR LINK_POLLY_INTO_TOOLS) target_link_libraries(Polly LLVMSupport LLVMCore @@ -87,33 +94,28 @@ link_directories( ${LLVM_LIBRARY_DIR} ) -elseif (LLVM_LINK_LLVM_DYLIB) - target_link_libraries(Polly - LLVM - ) - link_directories( - ${LLVM_LIBRARY_DIR} - ) endif() # Build a monolithic Polly.a and a thin module LLVMPolly.moduleext that links to # that static library. -if (MSVC) - # Add dummy target, because loadable modules are not supported on Windows - add_custom_target(LLVMPolly) - set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") -else () - add_polly_loadable_module(LLVMPolly - Polly.cpp - ) +if (NOT LINK_POLLY_INTO_TOOLS) + if (MSVC) + # Add dummy target, because loadable modules are not supported on Windows + add_custom_target(LLVMPolly) + set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") + else () + add_polly_loadable_module(LLVMPolly + Polly.cpp + ) - target_link_libraries(LLVMPolly Polly) + target_link_libraries(LLVMPolly Polly) - set_target_properties(LLVMPolly - PROPERTIES - LINKER_LANGUAGE CXX - PREFIX "") -endif () + set_target_properties(LLVMPolly + PROPERTIES + LINKER_LANGUAGE CXX + PREFIX "") + endif () +endif(NOT LINK_POLLY_INTO_TOOLS) if (TARGET intrinsics_gen) # Check if we are building as part of an LLVM build Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -20,7 +20,9 @@ # 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) - set(POLLY_TEST_DEPS LLVMPolly) + if (NOT LINK_POLLY_INTO_TOOLS) + set(POLLY_TEST_DEPS LLVMPolly) + endif () if (POLLY_GTEST_AVAIL) list(APPEND POLLY_TEST_DEPS PollyUnitTests) endif () @@ -102,7 +104,10 @@ 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) + set(POLLY_TEST_DEPS llvm-config opt FileCheck not) + if (NOT LINK_POLLY_INTO_TOOLS) + set(POLLY_TEST_DEPS ${POLLY_TEST_DEPS} LLVMPolly) + endif() if (POLLY_GTEST_AVAIL) list(APPEND POLLY_TEST_DEPS PollyUnitTests) endif ()