diff options
Diffstat (limited to 'Modules/Platform')
19 files changed, 28 insertions, 64 deletions
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 6544696..8755d4f 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -107,6 +107,7 @@ set(_ANDROID_ABI_INIT_CFLAGS "") set(_ANDROID_ABI_INIT_CFLAGS_DEBUG "") set(_ANDROID_ABI_INIT_CFLAGS_RELEASE "") set(_ANDROID_ABI_INIT_LDFLAGS "") +set(_ANDROID_ABI_INIT_EXE_LDFLAGS "") macro(__android_compiler_common lang) if(_ANDROID_ABI_INIT_CFLAGS) @@ -125,6 +126,9 @@ macro(__android_compiler_common lang) string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_ANDROID_ABI_INIT_LDFLAGS}") endforeach() endif() + if(_ANDROID_ABI_INIT_EXE_LDFLAGS) + string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${_ANDROID_ABI_INIT_EXE_LDFLAGS}") + endif() if(DEFINED _ANDROID_STL_EXCEPTIONS) if(_ANDROID_STL_EXCEPTIONS) diff --git a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake index 3ff1fe5..f4717d5 100644 --- a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake +++ b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake @@ -1,8 +1,7 @@ # <ndk>/build/core/toolchains/aarch64-linux-android-clang/setup.mk set(_ANDROID_ABI_CLANG_TARGET "aarch64-none-linux-android") -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fpic" - ) +# Suppress -Wl,-z,nocopyreloc flag on arm64-v8a +set(_ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc 1) include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake b/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake index 538ec2f..b71a674 100644 --- a/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake +++ b/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake @@ -1,6 +1,6 @@ # <ndk>/build/core/toolchains/aarch64-linux-android-4.9/setup.mk -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fpic" - ) + +# Suppress -Wl,-z,nocopyreloc flag on arm64-v8a +set(_ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc 1) include(Platform/Android/abi-common-GNU) diff --git a/Modules/Platform/Android/abi-armeabi-Clang.cmake b/Modules/Platform/Android/abi-armeabi-Clang.cmake index 4fc3009..b857bd3 100644 --- a/Modules/Platform/Android/abi-armeabi-Clang.cmake +++ b/Modules/Platform/Android/abi-armeabi-Clang.cmake @@ -14,7 +14,6 @@ endif() string(APPEND _ANDROID_ABI_INIT_CFLAGS " -msoft-float" " -mtune=xscale" - " -fpic" ) include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-armeabi-GNU.cmake b/Modules/Platform/Android/abi-armeabi-GNU.cmake index 10cac00..33e8b31 100644 --- a/Modules/Platform/Android/abi-armeabi-GNU.cmake +++ b/Modules/Platform/Android/abi-armeabi-GNU.cmake @@ -12,7 +12,6 @@ endif() string(APPEND _ANDROID_ABI_INIT_CFLAGS " -msoft-float" " -mtune=xscale" - " -fpic" ) include(Platform/Android/abi-common-GNU) diff --git a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake index 15f1d4a..a7412f5 100644 --- a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake +++ b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake @@ -13,7 +13,6 @@ endif() string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfloat-abi=softfp" - " -fpic" ) include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake b/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake index 7492de0..1fda184 100644 --- a/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake +++ b/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake @@ -11,7 +11,6 @@ endif() string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfloat-abi=softfp" - " -fpic" ) include(Platform/Android/abi-common-GNU) diff --git a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake index 3a3efb3..e2ab58b 100644 --- a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake +++ b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake @@ -23,7 +23,6 @@ string(APPEND _ANDROID_ABI_INIT_LDFLAGS string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfloat-abi=softfp" - " -fpic" ) include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake b/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake index d27e37e..b7c328d 100644 --- a/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake +++ b/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake @@ -17,7 +17,6 @@ endif() string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfloat-abi=softfp" - " -fpic" ) string(APPEND _ANDROID_ABI_INIT_LDFLAGS diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake index 12d8e5c..3b0eb01 100644 --- a/Modules/Platform/Android/abi-common.cmake +++ b/Modules/Platform/Android/abi-common.cmake @@ -2,3 +2,18 @@ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -funwind-tables" " -no-canonical-prefixes" ) + +if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE + AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 16) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() + +if(CMAKE_POSITION_INDEPENDENT_CODE) + string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie") +endif() + +string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,--gc-sections") + +if(NOT _ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc) + string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,-z,nocopyreloc") +endif() diff --git a/Modules/Platform/Android/abi-mips-Clang.cmake b/Modules/Platform/Android/abi-mips-Clang.cmake index bf6b9fc..73addde 100644 --- a/Modules/Platform/Android/abi-mips-Clang.cmake +++ b/Modules/Platform/Android/abi-mips-Clang.cmake @@ -1,8 +1,4 @@ # <ndk>/build/core/toolchains/mipsel-linux-android-clang/setup.mk set(_ANDROID_ABI_CLANG_TARGET "mipsel-none-linux-android") -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fpic" - ) - include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-mips-GNU.cmake b/Modules/Platform/Android/abi-mips-GNU.cmake index d380440..982ad46 100644 --- a/Modules/Platform/Android/abi-mips-GNU.cmake +++ b/Modules/Platform/Android/abi-mips-GNU.cmake @@ -1,6 +1,3 @@ # <ndk>/build/core/toolchains/mipsel-linux-android-4.9/setup.mk -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fpic" - ) include(Platform/Android/abi-common-GNU) diff --git a/Modules/Platform/Android/abi-mips64-Clang.cmake b/Modules/Platform/Android/abi-mips64-Clang.cmake index 1a94107..603f1b2 100644 --- a/Modules/Platform/Android/abi-mips64-Clang.cmake +++ b/Modules/Platform/Android/abi-mips64-Clang.cmake @@ -1,8 +1,4 @@ # <ndk>/build/core/toolchains/mips64el-linux-android-clang/setup.mk set(_ANDROID_ABI_CLANG_TARGET "mips64el-none-linux-android") -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fpic" - ) - include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-mips64-GNU.cmake b/Modules/Platform/Android/abi-mips64-GNU.cmake index 4525d40..a1bc2c2 100644 --- a/Modules/Platform/Android/abi-mips64-GNU.cmake +++ b/Modules/Platform/Android/abi-mips64-GNU.cmake @@ -1,6 +1,3 @@ # <ndk>/build/core/toolchains/mips64el-linux-android-4.9/setup.mk -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fpic" - ) include(Platform/Android/abi-common-GNU) diff --git a/Modules/Platform/Android/abi-x86-Clang.cmake b/Modules/Platform/Android/abi-x86-Clang.cmake index f63ed36..fe7eace 100644 --- a/Modules/Platform/Android/abi-x86-Clang.cmake +++ b/Modules/Platform/Android/abi-x86-Clang.cmake @@ -1,8 +1,4 @@ # <ndk>/build/core/toolchains/x86-clang/setup.mk set(_ANDROID_ABI_CLANG_TARGET "i686-none-linux-android") -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fPIC" - ) - include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/abi-x86_64-Clang.cmake b/Modules/Platform/Android/abi-x86_64-Clang.cmake index c15042b..3cbcd49 100644 --- a/Modules/Platform/Android/abi-x86_64-Clang.cmake +++ b/Modules/Platform/Android/abi-x86_64-Clang.cmake @@ -1,8 +1,4 @@ # <ndk>/build/core/toolchains/x86_64-clang/setup.mk set(_ANDROID_ABI_CLANG_TARGET "x86_64-none-linux-android") -string(APPEND _ANDROID_ABI_INIT_CFLAGS - " -fPIC" - ) - include(Platform/Android/abi-common-Clang) diff --git a/Modules/Platform/Android/ndk-stl-c++_static.cmake b/Modules/Platform/Android/ndk-stl-c++_static.cmake index 8e562f8..061a5c2 100644 --- a/Modules/Platform/Android/ndk-stl-c++_static.cmake +++ b/Modules/Platform/Android/ndk-stl-c++_static.cmake @@ -3,4 +3,6 @@ macro(__android_stl lang) __android_stl_cxx(${lang} libc++_static.a) __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libc++abi.a" 0) __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libandroid_support.a" 0) + __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libunwind.a" 0) + string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -latomic") # provided by toolchain endmacro() diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index 39374e1..b539e45 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -113,7 +113,6 @@ set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT "The product will be built against the headers and libraries located inside the indicated SDK.") # Transform the cached value to something we can use. -set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}") set(_CMAKE_OSX_SYSROOT_PATH "") if(CMAKE_OSX_SYSROOT) if("x${CMAKE_OSX_SYSROOT}" MATCHES "/") @@ -122,13 +121,10 @@ if(CMAKE_OSX_SYSROOT) message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n" "because the directory does not exist.") set(CMAKE_OSX_SYSROOT "") - set(_CMAKE_OSX_SYSROOT_ORIG "") endif() set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}") - endif() - - if(CMAKE_OSX_SYSROOT) - # Transform the (maybe unversioned) sysroot into a versioned path. + else() + # Transform the sdk name into a path. execute_process( COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path OUTPUT_VARIABLE _stdout diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index bb085ac..26b12a1 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -64,30 +64,6 @@ if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) mark_as_advanced(CMAKE_INSTALL_NAME_TOOL) endif() -# Make sure the combination of SDK and Deployment Target are allowed -if(CMAKE_OSX_DEPLOYMENT_TARGET) - if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk") - set(_sdk_ver "${CMAKE_MATCH_1}") - elseif("${_CMAKE_OSX_SYSROOT_ORIG}" MATCHES "^macosx([0-9]+\\.[0-9]+)$") - set(_sdk_ver "${CMAKE_MATCH_1}") - elseif("${_CMAKE_OSX_SYSROOT_ORIG}" STREQUAL "/") - set(_sdk_ver "${_CURRENT_OSX_VERSION}") - else() - message(FATAL_ERROR - "CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' " - "but CMAKE_OSX_SYSROOT:\n \"${_CMAKE_OSX_SYSROOT_ORIG}\"\n" - "is not set to a MacOSX SDK with a recognized version. " - "Either set CMAKE_OSX_SYSROOT to a valid SDK or set " - "CMAKE_OSX_DEPLOYMENT_TARGET to empty.") - endif() - if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER "${_sdk_ver}") - message(FATAL_ERROR - "CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) " - "is greater than CMAKE_OSX_SYSROOT SDK:\n ${_CMAKE_OSX_SYSROOT_ORIG}\n" - "Please set CMAKE_OSX_DEPLOYMENT_TARGET to ${_sdk_ver} or lower.") - endif() -endif() - # Enable shared library versioning. set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") |