diff options
author | Oscar Fuentes <ofv@wanadoo.es> | 2011-01-09 14:34:39 +0000 |
---|---|---|
committer | Oscar Fuentes <ofv@wanadoo.es> | 2011-01-09 14:34:39 +0000 |
commit | 2c5e0b8b981dc9d1ea575037b9befa8c3b6102b8 (patch) | |
tree | aca074fdeb18bdbfaa21e6ea0ac9795b18a6d5aa /CMakeLists.txt | |
parent | e7d7865bfdc26c0e9732c6a98a36289b64fdc84a (diff) |
Rewrite handling of LLVM_ENABLE_PIC. It was being processed after
config.h was generated, so it had no effect on it.
Thanks to arrowdodger for pointing out this and a tentative patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123119 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e27c6f82e..7daaa82eef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,27 +195,29 @@ else(WIN32) endif(UNIX) endif(WIN32) -include(config-ix) - option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) -set(ENABLE_PIC 0) if( LLVM_ENABLE_PIC ) - if( XCODE ) - # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't - # know how to disable this, so just force ENABLE_PIC off for now. - message(STATUS "Warning: -fPIC not supported with Xcode.") - else( XCODE ) - if( SUPPORTS_FPIC_FLAG ) + if( XCODE ) + # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't + # know how to disable this, so just force ENABLE_PIC off for now. + message(WARNING "-fPIC not supported with Xcode.") + elseif( WIN32 ) + # On Windows all code is PIC. MinGW warns if -fPIC is used. + else() + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG) + if( SUPPORTS_FPIC_FLAG ) message(STATUS "Building with -fPIC") - add_llvm_definitions(-fPIC) - set(ENABLE_PIC 1) - else( SUPPORTS_FPIC_FLAG ) - message(STATUS "Warning: -fPIC not supported.") - endif() - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + else( SUPPORTS_FPIC_FLAG ) + message(WARNING "-fPIC not supported.") + endif() + endif() endif() +include(config-ix) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |