summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeCInformation.cmake
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-07-02 08:47:32 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2021-07-09 12:50:50 (GMT)
commit14e57e9637964594461711954c6c906bc22eb7c7 (patch)
tree7e6bbfb2303d1c4377470180a36a6103df1a55fb /Modules/CMakeCInformation.cmake
parent9c5132a586562c00511fd8ff2bac0250c70dae95 (diff)
downloadCMake-14e57e9637964594461711954c6c906bc22eb7c7.zip
CMake-14e57e9637964594461711954c6c906bc22eb7c7.tar.gz
CMake-14e57e9637964594461711954c6c906bc22eb7c7.tar.bz2
LINK_WHAT_YOU_USE feature: externalize configuration
Currently, this feature is only supported on ELF platforms. So, the property LINK_WHAT_YOU_USE will be ignored for other plateforms. Moreover, flags and commands are now controled by CMake variables. Fixes: #20174
Diffstat (limited to 'Modules/CMakeCInformation.cmake')
-rw-r--r--Modules/CMakeCInformation.cmake10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake
index 6be1865..665f309 100644
--- a/Modules/CMakeCInformation.cmake
+++ b/Modules/CMakeCInformation.cmake
@@ -91,6 +91,14 @@ if(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_C "${_override}")
endif()
+if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
+ if(NOT DEFINED CMAKE_C_LINK_WHAT_YOU_USE_FLAG)
+ set(CMAKE_C_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed")
+ endif()
+ if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK)
+ set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r)
+ endif()
+endif()
# for most systems a module is the same as a shared library
# so unless the variable CMAKE_MODULE_EXISTS is set just
@@ -196,5 +204,3 @@ if(NOT CMAKE_EXECUTABLE_RPATH_LINK_C_FLAG)
endif()
set(CMAKE_C_INFORMATION_LOADED 1)
-
-