diff options
author | David Cole <david.cole@kitware.com> | 2012-06-12 20:01:04 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-06-12 20:01:04 (GMT) |
commit | c95d1baa194c8108841a8b973d3bbe50ca7d5666 (patch) | |
tree | be3efd1ba2c1b58cb3d51242e246777527842efc /Modules/Platform | |
parent | c6f6929e31a3e8067633aa57cf0775bced9d8443 (diff) | |
parent | bd3496300262bd26073ce03e020731c592249148 (diff) | |
download | CMake-c95d1baa194c8108841a8b973d3bbe50ca7d5666.zip CMake-c95d1baa194c8108841a8b973d3bbe50ca7d5666.tar.gz CMake-c95d1baa194c8108841a8b973d3bbe50ca7d5666.tar.bz2 |
Merge topic 'position-independent-targets'
bd34963 Refactor generation of shared library flags
55d7aa4 Add platform variable for flags specific to shared libraries
31d7a0f Add platform variables for position independent code flags
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/BeOS.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/BlueGeneP-base.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/CYGWIN-GNU.cmake | 5 | ||||
-rw-r--r-- | Modules/Platform/FreeBSD.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/HP-UX-HP.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Haiku.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Linux-Intel.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Linux-PGI.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Linux-PathScale.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/MP-RAS.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/NetBSD.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/OSF1.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/SINIX.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/SunOS.cmake | 6 | ||||
-rw-r--r-- | Modules/Platform/UNIX_SV.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/UnixWare.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-Embarcadero.cmake | 3 | ||||
-rw-r--r-- | Modules/Platform/Windows-GNU.cmake | 6 | ||||
-rw-r--r-- | Modules/Platform/Windows-wcl386.cmake | 3 | ||||
-rw-r--r-- | Modules/Platform/syllable.cmake | 4 |
20 files changed, 54 insertions, 10 deletions
diff --git a/Modules/Platform/BeOS.cmake b/Modules/Platform/BeOS.cmake index 41aa8f7..3ffb67c 100644 --- a/Modules/Platform/BeOS.cmake +++ b/Modules/Platform/BeOS.cmake @@ -1,6 +1,8 @@ SET(BEOS 1) SET(CMAKE_DL_LIBS root be) +SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake index 926dbc0..c0241e1 100644 --- a/Modules/Platform/BlueGeneP-base.cmake +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -85,11 +85,15 @@ set(CMAKE_DL_LIBS "dl") macro(__BlueGeneP_set_dynamic_flags compiler_id lang) if (${compiler_id} STREQUAL XL) # Flags for XL compilers if we explicitly detected XL + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-qpie") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") else() # Assume flags for GNU compilers (if the ID is GNU *or* anything else). + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 5aad45b..eae313a 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -35,7 +35,10 @@ macro(__cygwin_compiler_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on cygwin + # No -fPIC on cygwin + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index 033db06..82fe961 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -1,6 +1,8 @@ IF(EXISTS /usr/include/dlfcn.h) SET(CMAKE_DL_LIBS "") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath diff --git a/Modules/Platform/HP-UX-HP.cmake b/Modules/Platform/HP-UX-HP.cmake index bce0a8b..871ea13 100644 --- a/Modules/Platform/HP-UX-HP.cmake +++ b/Modules/Platform/HP-UX-HP.cmake @@ -19,6 +19,7 @@ endif() set(__HPUX_COMPILER_HP 1) macro(__hpux_compiler_hp lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "+Z") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "+Z") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-Wl,-E,+nodefaultrpath -b -L/usr/lib") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,+s,-E,+nodefaultrpath") diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index 8277a24..9dda3c5 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -1,6 +1,8 @@ SET(BEOS 1) SET(CMAKE_DL_LIBS root be) +SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index dea8b90..47bf246 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -31,6 +31,8 @@ if(NOT XIAR) endif(NOT XIAR) macro(__linux_compiler_intel lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake index ef06acd..3cbb35c 100644 --- a/Modules/Platform/Linux-PGI.cmake +++ b/Modules/Platform/Linux-PGI.cmake @@ -20,6 +20,8 @@ set(__LINUX_COMPILER_PGI 1) macro(__linux_compiler_pgi lang) # Shared library compile and link flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") endmacro() diff --git a/Modules/Platform/Linux-PathScale.cmake b/Modules/Platform/Linux-PathScale.cmake index c131af2..d230ab2 100644 --- a/Modules/Platform/Linux-PathScale.cmake +++ b/Modules/Platform/Linux-PathScale.cmake @@ -20,6 +20,8 @@ set(__LINUX_COMPILER_PATHSCALE 1) macro(__linux_compiler_pathscale lang) # Shared library compile and link flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") endmacro() diff --git a/Modules/Platform/MP-RAS.cmake b/Modules/Platform/MP-RAS.cmake index 1e3e239..ff22a4f 100644 --- a/Modules/Platform/MP-RAS.cmake +++ b/Modules/Platform/MP-RAS.cmake @@ -1,6 +1,10 @@ IF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) + SET(CMAKE_C_COMPILE_OPTIONS_PIE -K PIE) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") ELSE(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) + SET(CMAKE_C_COMPILE_OPTIONS_PIE -K PIE) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport") ENDIF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 0fb8636..e1b66b8 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -1,6 +1,8 @@ IF(EXISTS /usr/include/dlfcn.h) SET(CMAKE_DL_LIBS "") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake index 076410a..49a30e9 100644 --- a/Modules/Platform/OSF1.cmake +++ b/Modules/Platform/OSF1.cmake @@ -4,7 +4,9 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") IF(CMAKE_SYSTEM MATCHES "OSF1-1.*") # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2 - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fpic") # -pic + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fpic") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fpie") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fpic") # -pic SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fpic") # -pic ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.*") diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake index 4592fdd..e0809f8 100644 --- a/Modules/Platform/SINIX.cmake +++ b/Modules/Platform/SINIX.cmake @@ -1,2 +1,4 @@ +SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index 2291c34..de287aa 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -1,6 +1,8 @@ IF(CMAKE_SYSTEM MATCHES "SunOS-4.*") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC") - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r") + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC") + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") ENDIF(CMAKE_SYSTEM MATCHES "SunOS-4.*") diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake index 3b50e0a..869b3a6 100644 --- a/Modules/Platform/UNIX_SV.cmake +++ b/Modules/Platform/UNIX_SV.cmake @@ -1,3 +1,5 @@ +SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake index c324bc8..3112ee1 100644 --- a/Modules/Platform/UnixWare.cmake +++ b/Modules/Platform/UnixWare.cmake @@ -1,3 +1,5 @@ +SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-Wl,-Bexport") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index 87b3767..62e8eb7 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -76,7 +76,8 @@ SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_SHARED_LINKER_FLAGS_R macro(__embarcadero_language lang) - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") + set(CMAKE_${lang}_COMPILE_OPTIONS_DLL "${_tD}") # Note: This variable is a ';' separated list + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") # ... while this is a space separated string. # compile a source file into an object file # place <DEFINES> outside the response file because Borland refuses diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index dd47692..1a2ee5e 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -77,7 +77,11 @@ macro(__windows_compiler_gnu lang) endforeach(type) endif() - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows + # No -fPIC on Windows + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index e1140df..14b3b81 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -20,7 +20,8 @@ SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "debug all" ) SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) -set (CMAKE_SHARED_LIBRARY_C_FLAGS "-bd" ) +set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list +set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string. SET(CMAKE_RC_COMPILER "rc" ) diff --git a/Modules/Platform/syllable.cmake b/Modules/Platform/syllable.cmake index 3ce42f6..2d11d08 100644 --- a/Modules/Platform/syllable.cmake +++ b/Modules/Platform/syllable.cmake @@ -10,7 +10,9 @@ SET(CMAKE_DL_LIBS "dl") -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic +SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") |