summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeCXXInformation.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-09-30 17:42:50 (GMT)
committerBrad King <brad.king@kitware.com>2015-09-30 19:01:23 (GMT)
commit8b4873a1b025d7f47c90f3cafc93ca152b9e4652 (patch)
treebfbccc8785c7852687be5a6fafcde4dd9707805b /Modules/CMakeCXXInformation.cmake
parente90f463a312e18fd6498799de1522b96d84fd012 (diff)
downloadCMake-8b4873a1b025d7f47c90f3cafc93ca152b9e4652.zip
CMake-8b4873a1b025d7f47c90f3cafc93ca152b9e4652.tar.gz
CMake-8b4873a1b025d7f47c90f3cafc93ca152b9e4652.tar.bz2
Disable shared library support when compiler links statically
When a user or a compiler wrapper adds '-static' to the compiler flags then it will always link static binaries. Detect this from the compiler id binary and disable TARGET_SUPPORTS_SHARED_LIBS. This will prevent projects from accidentally adding shared libraries when the toolchain does not support them. It also helps CMake avoid linking with flags that require shared libraries to be supported.
Diffstat (limited to 'Modules/CMakeCXXInformation.cmake')
-rw-r--r--Modules/CMakeCXXInformation.cmake4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake
index 091627b..dad7969 100644
--- a/Modules/CMakeCXXInformation.cmake
+++ b/Modules/CMakeCXXInformation.cmake
@@ -74,6 +74,10 @@ if(CMAKE_CXX_SIZEOF_DATA_PTR)
unset(CMAKE_CXX_ABI_FILES)
endif()
+if(CMAKE_CXX_COMPILER_LINKS_STATICALLY)
+ set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
+endif()
+
# This should be included before the _INIT variables are
# used to initialize the cache. Since the rule variables
# have if blocks on them, users can still define them here.