diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-10-18 14:11:27 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-11-29 14:25:42 (GMT) |
commit | 2c71d051facad13b0a42a57066be2489d5fff6ea (patch) | |
tree | d07f850f8abc74d9df34ad885681c08d36c14472 /Modules/Platform | |
parent | afd0f6785dc1220a07743d31699fcd9097cca46a (diff) | |
download | CMake-2c71d051facad13b0a42a57066be2489d5fff6ea.zip CMake-2c71d051facad13b0a42a57066be2489d5fff6ea.tar.gz CMake-2c71d051facad13b0a42a57066be2489d5fff6ea.tar.bz2 |
Makefiles Generators: use compiler for dependencies generation
Each source compilation generates a dependencies file. These dependencies
files are consolidated in one file per target. This consolidation is done
as part of command 'cmake -E cmake_depends` launched before evaluation of
makefile dependency graph.
The consolidation uses the same approach as `CMake` dependencies management.
Fixes: #21321
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/Windows-Clang-C.cmake | 16 | ||||
-rw-r--r-- | Modules/Platform/Windows-Clang-CXX.cmake | 16 | ||||
-rw-r--r-- | Modules/Platform/Windows-Intel-C.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-Intel-CXX.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC-C.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC-CXX.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 7 |
7 files changed, 67 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-Clang-C.cmake b/Modules/Platform/Windows-Clang-C.cmake index d007105..322e3fb 100644 --- a/Modules/Platform/Windows-Clang-C.cmake +++ b/Modules/Platform/Windows-Clang-C.cmake @@ -1,2 +1,18 @@ include(Platform/Windows-Clang) __windows_compiler_clang(C) + +if("x${MAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) + endif() +elseif("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPFILE_FORMAT gcc) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) + endif() +endif() diff --git a/Modules/Platform/Windows-Clang-CXX.cmake b/Modules/Platform/Windows-Clang-CXX.cmake index f1d40f2..b4aaf1e 100644 --- a/Modules/Platform/Windows-Clang-CXX.cmake +++ b/Modules/Platform/Windows-Clang-CXX.cmake @@ -1,3 +1,19 @@ include(Platform/Windows-Clang) set(_COMPILE_CXX_MSVC " -TP") __windows_compiler_clang(CXX) + +if("x${MAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) + endif() +elseif("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPFILE_FORMAT gcc) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) + endif() +endif() diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake index f3aa851..3cbc7a5 100644 --- a/Modules/Platform/Windows-Intel-C.cmake +++ b/Modules/Platform/Windows-Intel-C.cmake @@ -2,3 +2,10 @@ include(Platform/Windows-Intel) __windows_compiler_intel(C) set(CMAKE_NINJA_DEPTYPE_C intel) # special value handled by CMake set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake") + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPFILE_FORMAT gcc) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) +endif() diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake index f0b15b1..6539f64 100644 --- a/Modules/Platform/Windows-Intel-CXX.cmake +++ b/Modules/Platform/Windows-Intel-CXX.cmake @@ -3,3 +3,10 @@ set(_COMPILE_CXX " /TP") __windows_compiler_intel(CXX) set(CMAKE_NINJA_DEPTYPE_CXX intel) # special value handled by CMake set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake") + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPFILE_FORMAT gcc) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) +endif() diff --git a/Modules/Platform/Windows-MSVC-C.cmake b/Modules/Platform/Windows-MSVC-C.cmake index cbe1586..67b6827 100644 --- a/Modules/Platform/Windows-MSVC-C.cmake +++ b/Modules/Platform/Windows-MSVC-C.cmake @@ -3,3 +3,10 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) set(_FS_C " /FS") endif() __windows_compiler_msvc(C) + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) +endif() diff --git a/Modules/Platform/Windows-MSVC-CXX.cmake b/Modules/Platform/Windows-MSVC-CXX.cmake index 0e85005..6fea617 100644 --- a/Modules/Platform/Windows-MSVC-CXX.cmake +++ b/Modules/Platform/Windows-MSVC-CXX.cmake @@ -4,3 +4,10 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) set(_FS_CXX " /FS") endif() __windows_compiler_msvc(CXX) + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) +endif() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 3f65475..ec5758c 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -437,6 +437,13 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) set(CMAKE_NINJA_DEPTYPE_${lang} msvc) __windows_compiler_msvc_enable_rc("${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}") + + # define generic information about compiler dependencies + # activation is done on per language platform configuration basis + if (MSVC_VERSION GREATER 1300) + set(CMAKE_DEPFILE_FLAGS_${lang} "/showIncludes") + set(CMAKE_${lang}_DEPFILE_FORMAT msvc) + endif() endmacro() macro(__windows_compiler_msvc_enable_rc flags) |