diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -39,8 +39,10 @@ set(POLLY_GTEST_AVAIL 1) endif() - # Make sure the isl c files are built as fPIC - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + if (LLVM_ENABLE_PIC) + # Make sure the isl c files are built as fPIC if possible + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + endif () # Set directory for polly-isl-test. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt --- a/polly/cmake/CMakeLists.txt +++ b/polly/cmake/CMakeLists.txt @@ -10,8 +10,8 @@ endif() set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET}) -if (NOT MSVC) - # LLVMPolly is a dummy target on Win +if (NOT MSVC AND LLVM_ENABLE_PIC) + # LLVMPolly is a dummy target on Win or if PIC code is disabled. list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly) endif() if (POLLY_ENABLE_GPGPU_CODEGEN) diff --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt --- a/polly/lib/CMakeLists.txt +++ b/polly/lib/CMakeLists.txt @@ -137,8 +137,9 @@ # Create a loadable module Polly.so that can be loaded using # LLVM's/clang's "-load" option. -if (MSVC) - # Add dummy target, because loadable modules are not supported on Windows +if (MSVC OR NOT LLVM_ENABLE_PIC) + # Add dummy target, either because loadable modules are not supported + # as on Windows or because PIC code has been disabled add_custom_target(LLVMPolly) set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") else ()