summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-05-04 13:06:13 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-05-04 13:06:23 (GMT)
commit0d2d5a229c1cda842f0e67134637f19fc69de6c6 (patch)
treea49e9c37852a30be719018dd3572742739e81ad4 /Modules
parentbf36ce2ff6122adbbfa4df2d8f731f57ca282d27 (diff)
parent375e6fdbbe398921de321216125765ba1917a325 (diff)
downloadCMake-0d2d5a229c1cda842f0e67134637f19fc69de6c6.zip
CMake-0d2d5a229c1cda842f0e67134637f19fc69de6c6.tar.gz
CMake-0d2d5a229c1cda842f0e67134637f19fc69de6c6.tar.bz2
Merge topic 'use-linker-depfile'
375e6fdbbe Link step: use linker dependency linker file 24a3e5cda0 cmLocalGenerator::MayBeRelativeToWorkDir: take care of all cases Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8443
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeASMCompiler.cmake.in1
-rw-r--r--Modules/CMakeCCompiler.cmake.in1
-rw-r--r--Modules/CMakeCUDACompiler.cmake.in1
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in1
-rw-r--r--Modules/CMakeFortranCompiler.cmake.in1
-rw-r--r--Modules/CMakeHIPCompiler.cmake.in1
-rw-r--r--Modules/CMakeOBJCCompiler.cmake.in1
-rw-r--r--Modules/CMakeOBJCXXCompiler.cmake.in1
-rw-r--r--Modules/Compiler/Clang-HIP.cmake9
-rw-r--r--Modules/Compiler/GNU.cmake38
10 files changed, 55 insertions, 0 deletions
diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in
index e300782..8a1718b 100644
--- a/Modules/CMakeASMCompiler.cmake.in
+++ b/Modules/CMakeASMCompiler.cmake.in
@@ -17,5 +17,6 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@")
set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE 0)
+set(CMAKE_ASM@ASM_DIALECT@_LINKER_DEPFILE_SUPPORTED "@CMAKE_ASM_LINKER_DEPFILE_SUPPORTED@")
@CMAKE_ASM_COMPILER_CUSTOM_CODE@
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index 8ae07a3..cf3a242 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -39,6 +39,7 @@ set(CMAKE_C_COMPILER_ID_RUN 1)
set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_C_LINKER_PREFERENCE 10)
+set(CMAKE_C_LINKER_DEPFILE_SUPPORTED "@CMAKE_C_LINKER_DEPFILE_SUPPORTED@")
# Save compiler ABI information.
set(CMAKE_C_SIZEOF_DATA_PTR "@CMAKE_C_SIZEOF_DATA_PTR@")
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in
index 57d595a..3d7d552 100644
--- a/Modules/CMakeCUDACompiler.cmake.in
+++ b/Modules/CMakeCUDACompiler.cmake.in
@@ -30,6 +30,7 @@ set(CMAKE_CUDA_COMPILER_ID_RUN 1)
set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu)
set(CMAKE_CUDA_LINKER_PREFERENCE 15)
set(CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES 1)
+set(CMAKE_CUDA_LINKER_DEPFILE_SUPPORTED "@CMAKE_CUDA_LINKER_DEPFILE_SUPPORTED@")
set(CMAKE_CUDA_SIZEOF_DATA_PTR "@CMAKE_CUDA_SIZEOF_DATA_PTR@")
set(CMAKE_CUDA_COMPILER_ABI "@CMAKE_CUDA_COMPILER_ABI@")
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index 834c2e6..2052e7f 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -50,6 +50,7 @@ endforeach()
set(CMAKE_CXX_LINKER_PREFERENCE 30)
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
+set(CMAKE_CXX_LINKER_DEPFILE_SUPPORTED "@CMAKE_CXX_LINKER_DEPFILE_SUPPORTED@")
# Save compiler ABI information.
set(CMAKE_CXX_SIZEOF_DATA_PTR "@CMAKE_CXX_SIZEOF_DATA_PTR@")
diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in
index fc81d0e..a7caf2b 100644
--- a/Modules/CMakeFortranCompiler.cmake.in
+++ b/Modules/CMakeFortranCompiler.cmake.in
@@ -29,6 +29,7 @@ set(CMAKE_Fortran_COMPILER_ID_RUN 1)
set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95;f03;F03;f08;F08@CMAKE_Fortran_VENDOR_SOURCE_FILE_EXTENSIONS@)
set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_Fortran_LINKER_PREFERENCE 20)
+set(CMAKE_Fortran_LINKER_DEPFILE_SUPPORTED "@CMAKE_Fortran_LINKER_DEPFILE_SUPPORTED@")
if(UNIX)
set(CMAKE_Fortran_OUTPUT_EXTENSION .o)
else()
diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in
index 8a747c6..32c1223 100644
--- a/Modules/CMakeHIPCompiler.cmake.in
+++ b/Modules/CMakeHIPCompiler.cmake.in
@@ -26,6 +26,7 @@ set(CMAKE_HIP_COMPILER_ID_RUN 1)
set(CMAKE_HIP_SOURCE_FILE_EXTENSIONS hip)
set(CMAKE_HIP_LINKER_PREFERENCE 90)
set(CMAKE_HIP_LINKER_PREFERENCE_PROPAGATES 1)
+set(CMAKE_HIP_LINKER_DEPFILE_SUPPORTED "@CMAKE_HIP_LINKER_DEPFILE_SUPPORTED@")
set(CMAKE_HIP_SIZEOF_DATA_PTR "@CMAKE_HIP_SIZEOF_DATA_PTR@")
set(CMAKE_HIP_COMPILER_ABI "@CMAKE_HIP_COMPILER_ABI@")
diff --git a/Modules/CMakeOBJCCompiler.cmake.in b/Modules/CMakeOBJCCompiler.cmake.in
index ea11a7a..0ceb804 100644
--- a/Modules/CMakeOBJCCompiler.cmake.in
+++ b/Modules/CMakeOBJCCompiler.cmake.in
@@ -37,6 +37,7 @@ set(CMAKE_OBJC_COMPILER_ID_RUN 1)
set(CMAKE_OBJC_SOURCE_FILE_EXTENSIONS m)
set(CMAKE_OBJC_IGNORE_EXTENSIONS h;H;o;O)
set(CMAKE_OBJC_LINKER_PREFERENCE 5)
+set(CMAKE_OBJC_LINKER_DEPFILE_SUPPORTED "@CMAKE_OBJC_LINKER_DEPFILE_SUPPORTED@")
foreach (lang C CXX OBJCXX)
foreach(extension IN LISTS CMAKE_OBJC_SOURCE_FILE_EXTENSIONS)
diff --git a/Modules/CMakeOBJCXXCompiler.cmake.in b/Modules/CMakeOBJCXXCompiler.cmake.in
index 5d0b381..f087ec3 100644
--- a/Modules/CMakeOBJCXXCompiler.cmake.in
+++ b/Modules/CMakeOBJCXXCompiler.cmake.in
@@ -54,6 +54,7 @@ endforeach()
set(CMAKE_OBJCXX_LINKER_PREFERENCE 25)
set(CMAKE_OBJCXX_LINKER_PREFERENCE_PROPAGATES 1)
+set(CMAKE_OBJCXX_LINKER_DEPFILE_SUPPORTED "@CMAKE_OBJCXX_LINKER_DEPFILE_SUPPORTED@")
# Save compiler ABI information.
set(CMAKE_OBJCXX_SIZEOF_DATA_PTR "@CMAKE_OBJCXX_SIZEOF_DATA_PTR@")
diff --git a/Modules/Compiler/Clang-HIP.cmake b/Modules/Compiler/Clang-HIP.cmake
index 4dbe2e8..7e3c99c 100644
--- a/Modules/Compiler/Clang-HIP.cmake
+++ b/Modules/Compiler/Clang-HIP.cmake
@@ -1,4 +1,13 @@
include(Compiler/Clang)
+
+#
+# For now, deactivate globally linker dependency file support because
+# HIP compiler is based on Clang which provides support of other languages
+#
+foreach (lang IN ITEMS "C" "CXX" "OBJC" "OBJCXX" "Fortran" "ASM")
+ set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE)
+endforeach()
+
__compiler_clang(HIP)
__compiler_clang_cxx_standards(HIP)
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 5930e37..f140208 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -52,6 +52,44 @@ macro(__compiler_gnu lang)
set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
endif()
+ # define flags for linker depfile generation
+ if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
+ ## Ensure ninja tool is recent enough...
+ if(CMAKE_GENERATOR MATCHES "^Ninja")
+ # Ninja 1.10 or upper is required
+ execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" --version
+ OUTPUT_VARIABLE _ninja_version
+ ERROR_VARIABLE _ninja_version)
+ if (_ninja_version MATCHES "[0-9]+(\\.[0-9]+)*")
+ set (_ninja_version "${CMAKE_MATCH_0}")
+ endif()
+ if (_ninja_version VERSION_LESS "1.10")
+ set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE)
+ endif()
+ unset(_ninja_version)
+ endif()
+
+ if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
+ ## check if this feature is supported by the linker
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE _linker_capabilities
+ ERROR_VARIABLE _linker_capabilities)
+ if(_linker_capabilities MATCHES "--dependency-file")
+ set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED TRUE)
+ else()
+ set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE)
+ endif()
+ unset(_linker_capabilities)
+ endif()
+ endif()
+ if (CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
+ set(CMAKE_${lang}_LINKER_DEPFILE_FLAGS "LINKER:--dependency-file,<DEP_FILE>")
+ set(CMAKE_${lang}_LINKER_DEPFILE_FORMAT gcc)
+ set(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER TRUE)
+ else()
+ unset(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER)
+ endif()
+
# Initial configuration flags.
string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")