From 3401403f69033446a5dcefd60dd8c375eaa58a44 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 26 Oct 2020 17:08:56 +0100 Subject: Refactoring: Introduce place-holder for dependency target. These changes are in preparation of compiler generated dependencies support for Makefiles generators * compiler output and dependency target can be different for Makefiles generators * resolve inconsistency naming for dependency file place-holder --- Modules/Compiler/ARMCC.cmake | 2 +- Modules/Compiler/Clang-CUDA.cmake | 2 +- Modules/Compiler/GNU-ASM.cmake | 2 +- Modules/Compiler/GNU.cmake | 2 +- Modules/Compiler/IAR.cmake | 4 +- Modules/Compiler/Intel-C.cmake | 2 +- Modules/Compiler/Intel-CXX.cmake | 2 +- Modules/Compiler/Intel-ISPC.cmake | 2 +- Modules/Compiler/NVIDIA-CUDA.cmake | 2 +- Modules/Compiler/QCC.cmake | 2 +- Modules/Compiler/SunPro-C.cmake | 2 +- Modules/Compiler/SunPro-CXX.cmake | 2 +- Modules/Compiler/TI.cmake | 2 +- Modules/Compiler/XL.cmake | 2 +- Modules/Platform/Windows-Clang.cmake | 4 +- Modules/Platform/Windows-Intel-C.cmake | 2 +- Modules/Platform/Windows-Intel-CXX.cmake | 2 +- Source/cmNinjaTargetGenerator.cxx | 5 +- Source/cmRulePlaceholderExpander.cxx | 11 ++--- Source/cmRulePlaceholderExpander.h | 78 ++++++++++++++++---------------- 20 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Modules/Compiler/ARMCC.cmake b/Modules/Compiler/ARMCC.cmake index f949568..f4f1854 100644 --- a/Modules/Compiler/ARMCC.cmake +++ b/Modules/Compiler/ARMCC.cmake @@ -33,7 +33,7 @@ macro(__compiler_armcc lang) set(CMAKE_${lang}_LINK_EXECUTABLE " -o --list .map") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " --create -cr ") - set(CMAKE_DEPFILE_FLAGS_${lang} "--depend= --depend_single_line --no_depend_system_headers") + set(CMAKE_DEPFILE_FLAGS_${lang} "--depend= --depend_single_line --no_depend_system_headers") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") endmacro() diff --git a/Modules/Compiler/Clang-CUDA.cmake b/Modules/Compiler/Clang-CUDA.cmake index fd8c2b7..b6155bd 100644 --- a/Modules/Compiler/Clang-CUDA.cmake +++ b/Modules/Compiler/Clang-CUDA.cmake @@ -2,7 +2,7 @@ include(Compiler/Clang) __compiler_clang(CUDA) # Set explicitly, because __compiler_clang() doesn't set this if we're simulating MSVC. -set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT -MF ") +set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT -MF ") # C++03 isn't supported for CXX, but is for CUDA, so we need to set these manually. # Do this before __compiler_clang_cxx_standards() since that adds the feature. diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake index 94af401..a935416 100644 --- a/Modules/Compiler/GNU-ASM.cmake +++ b/Modules/Compiler/GNU-ASM.cmake @@ -6,7 +6,7 @@ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) __compiler_gnu(ASM) if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH STREQUAL "GNU assembler") - set(CMAKE_DEPFILE_FLAGS_ASM${ASM_DIALECT} "--MD ") + set(CMAKE_DEPFILE_FLAGS_ASM${ASM_DIALECT} "--MD ") set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE " -o ") set(CMAKE_ASM_DEFINE_FLAG "--defsym ") diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 668a6a9..dc06d22 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -49,7 +49,7 @@ macro(__compiler_gnu lang) # distcc does not transform -o to -MT when invoking the preprocessor # internally, as it ought to. Work around this bug by setting -MT here # even though it isn't strictly necessary. - set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") + set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") endif() # Initial configuration flags. diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake index f3938a9..b8c0770 100644 --- a/Modules/Compiler/IAR.cmake +++ b/Modules/Compiler/IAR.cmake @@ -49,7 +49,7 @@ macro(__compiler_iar_ilink lang) set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " ${CMAKE_IAR_${lang}_FLAG} --silent -lAH -o .dummy") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ") - set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns ") + set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns ") string(APPEND CMAKE_${lang}_FLAGS_INIT " ") string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r") @@ -85,7 +85,7 @@ macro(__compiler_iar_xlink lang) set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " ${CMAKE_IAR_${lang}_FLAG} --silent -lAH -o .dummy") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ") - set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns ") + set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns ") string(APPEND CMAKE_${lang}_FLAGS_INIT " ") string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r") diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index ec3bfd8..0a3ab54 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -5,7 +5,7 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") -set(CMAKE_DEPFILE_FLAGS_C "-MD -MT -MF ") +set(CMAKE_DEPFILE_FLAGS_C "-MD -MT -MF ") if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index b71b946..76d0aec 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -5,7 +5,7 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -DNDEBUG") -set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT -MF ") +set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT -MF ") if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") diff --git a/Modules/Compiler/Intel-ISPC.cmake b/Modules/Compiler/Intel-ISPC.cmake index 2e9792a..66b26d7 100644 --- a/Modules/Compiler/Intel-ISPC.cmake +++ b/Modules/Compiler/Intel-ISPC.cmake @@ -3,7 +3,7 @@ include(Compiler/CMakeCommonCompilerMacros) # Not aware of any verbose flag for ISPC #set(CMAKE_ISPC_VERBOSE_FLAG ) -set(CMAKE_DEPFILE_FLAGS_ISPC "-M -MT -MF ") +set(CMAKE_DEPFILE_FLAGS_ISPC "-M -MT -MF ") string(APPEND CMAKE_ISPC_FLAGS_INIT " ") string(APPEND CMAKE_ISPC_FLAGS_DEBUG_INIT "-O0 -g") diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index 95a51f6..464c208 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -28,7 +28,7 @@ if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89) # The -MD flag was only added to nvcc in 10.2 so # before that we had to invoke the compiler twice # to get header dependency information - set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT -MF ") + set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT -MF ") endif() if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake index 10e1389..7fbfd10 100644 --- a/Modules/Compiler/QCC.cmake +++ b/Modules/Compiler/QCC.cmake @@ -14,7 +14,7 @@ macro(__compiler_qcc lang) set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "-Wc,-isysroot,") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") - set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD, -Wp,-MT, -Wp,-MF,") + set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD, -Wp,-MT, -Wp,-MF,") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 7e962b8..c98656f 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -22,7 +22,7 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG") string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG") string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") -set(CMAKE_DEPFILE_FLAGS_C "-xMD -xMF ") +set(CMAKE_DEPFILE_FLAGS_C "-xMD -xMF ") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index c946c64..aa8a9c5 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -22,7 +22,7 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG") string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG") string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG") -set(CMAKE_DEPFILE_FLAGS_CXX "-xMD -xMF ") +set(CMAKE_DEPFILE_FLAGS_CXX "-xMD -xMF ") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Compiler/TI.cmake b/Modules/Compiler/TI.cmake index f631688..c8c1635 100644 --- a/Modules/Compiler/TI.cmake +++ b/Modules/Compiler/TI.cmake @@ -18,7 +18,7 @@ macro(__compiler_ti lang) set(CMAKE_${lang}_RESPONSE_FILE_FLAG "--cmd_file=") set(CMAKE_INCLUDE_FLAG_${lang} "--include_path=") - set(CMAKE_DEPFILE_FLAGS_${lang} "--preproc_with_compile --preproc_dependency=") + set(CMAKE_DEPFILE_FLAGS_${lang} "--preproc_with_compile --preproc_dependency=") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " --preproc_only ${__COMPILER_TI_SOURCE_FLAG_${lang}}= --output_file=") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " --compile_only --skip_assembler ${__COMPILER_TI_SOURCE_FLAG_${lang}}= --output_file=") diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index fc71ab4..8b9d4a9 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -30,5 +30,5 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") - set(CMAKE_DEPFILE_FLAGS_${lang} "-MF -qmakedep=gcc") + set(CMAKE_DEPFILE_FLAGS_${lang} "-MF -qmakedep=gcc") endmacro() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 6275043..d10ea8f 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -27,7 +27,7 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_SHARED_MODULE_SUFFIX ".dll") set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") if(NOT "${lang}" STREQUAL "ASM") - set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") + set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") endif() set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") @@ -111,7 +111,7 @@ macro(__enable_llvm_rc_preprocessing clang_option_prefix) set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) endif() if(DEFINED CMAKE_RC_PREPROCESSOR) - set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}") + set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}") # The are passed to the preprocess and the resource compiler to pick # up the eventual -D / -C options passed through the CMAKE_RC_FLAGS. set(CMAKE_RC_COMPILE_OBJECT " -E cmake_llvm_rc .pp <${CMAKE_RC_PREPROCESSOR}> -DRC_INVOKED -E -- ++ -I /fo .pp") diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake index 06d8f50..f3aa851 100644 --- a/Modules/Platform/Windows-Intel-C.cmake +++ b/Modules/Platform/Windows-Intel-C.cmake @@ -1,4 +1,4 @@ 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 -QMF ") +set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT -QMF ") diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake index 666de6e..f0b15b1 100644 --- a/Modules/Platform/Windows-Intel-CXX.cmake +++ b/Modules/Platform/Windows-Intel-CXX.cmake @@ -2,4 +2,4 @@ include(Platform/Windows-Intel) 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 -QMF ") +set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT -QMF ") diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 6085b25..4ac08e0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -548,6 +548,7 @@ cmNinjaRule GetScanRule( scanVars.Object = "$out"; // for RULE_LAUNCH_COMPILE scanVars.PreprocessedSource = "$out"; scanVars.DependencyFile = rule.DepFile.c_str(); + scanVars.DependencyTarget = "$out"; // Scanning needs the same preprocessor settings as direct compilation would. scanVars.Source = vars.Source; @@ -750,8 +751,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, const std::string flagsName = cmStrCat("CMAKE_DEPFILE_FLAGS_", lang); std::string depfileFlags = mf->GetSafeDefinition(flagsName); if (!depfileFlags.empty()) { - cmSystemTools::ReplaceString(depfileFlags, "", "$DEP_FILE"); - cmSystemTools::ReplaceString(depfileFlags, "", "$out"); + cmSystemTools::ReplaceString(depfileFlags, "", "$DEP_FILE"); + cmSystemTools::ReplaceString(depfileFlags, "", "$out"); cmSystemTools::ReplaceString( depfileFlags, "", cmToCStr(mf->GetDefinition("CMAKE_C_COMPILER"))); diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index f5f9c67..5363fef 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -3,7 +3,6 @@ #include "cmRulePlaceholderExpander.h" #include -#include #include #include "cmOutputConverter.h" @@ -20,11 +19,6 @@ cmRulePlaceholderExpander::cmRulePlaceholderExpander( { } -cmRulePlaceholderExpander::RuleVariables::RuleVariables() -{ - memset(this, 0, sizeof(*this)); -} - std::string cmRulePlaceholderExpander::ExpandRuleVariable( cmOutputConverter* outputConverter, std::string const& variable, const RuleVariables& replaceValues) @@ -141,6 +135,11 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return replaceValues.DependencyFile; } } + if (replaceValues.DependencyTarget) { + if (variable == "DEP_TARGET") { + return replaceValues.DependencyTarget; + } + } if (replaceValues.Fatbinary) { if (variable == "FATBINARY") { return replaceValues.Fatbinary; diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index c8d107d..710f8a6 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -27,45 +27,45 @@ public: // ExpandRuleVariables struct RuleVariables { - RuleVariables(); - const char* CMTargetName; - const char* CMTargetType; - const char* TargetPDB; - const char* TargetCompilePDB; - const char* TargetVersionMajor; - const char* TargetVersionMinor; - const char* Language; - const char* AIXExports; - const char* Objects; - const char* Target; - const char* LinkLibraries; - const char* Source; - const char* AssemblySource; - const char* PreprocessedSource; - const char* Output; - const char* Object; - const char* ObjectDir; - const char* ObjectFileDir; - const char* Flags; - const char* ObjectsQuoted; - const char* SONameFlag; - const char* TargetSOName; - const char* TargetInstallNameDir; - const char* LinkFlags; - const char* Manifests; - const char* LanguageCompileFlags; - const char* Defines; - const char* Includes; - const char* DependencyFile; - const char* FilterPrefix; - const char* SwiftLibraryName; - const char* SwiftModule; - const char* SwiftModuleName; - const char* SwiftOutputFileMap; - const char* SwiftSources; - const char* ISPCHeader; - const char* Fatbinary; - const char* RegisterFile; + const char* CMTargetName = nullptr; + const char* CMTargetType = nullptr; + const char* TargetPDB = nullptr; + const char* TargetCompilePDB = nullptr; + const char* TargetVersionMajor = nullptr; + const char* TargetVersionMinor = nullptr; + const char* Language = nullptr; + const char* AIXExports = nullptr; + const char* Objects = nullptr; + const char* Target = nullptr; + const char* LinkLibraries = nullptr; + const char* Source = nullptr; + const char* AssemblySource = nullptr; + const char* PreprocessedSource = nullptr; + const char* Output = nullptr; + const char* Object = nullptr; + const char* ObjectDir = nullptr; + const char* ObjectFileDir = nullptr; + const char* Flags = nullptr; + const char* ObjectsQuoted = nullptr; + const char* SONameFlag = nullptr; + const char* TargetSOName = nullptr; + const char* TargetInstallNameDir = nullptr; + const char* LinkFlags = nullptr; + const char* Manifests = nullptr; + const char* LanguageCompileFlags = nullptr; + const char* Defines = nullptr; + const char* Includes = nullptr; + const char* DependencyFile = nullptr; + const char* DependencyTarget = nullptr; + const char* FilterPrefix = nullptr; + const char* SwiftLibraryName = nullptr; + const char* SwiftModule = nullptr; + const char* SwiftModuleName = nullptr; + const char* SwiftOutputFileMap = nullptr; + const char* SwiftSources = nullptr; + const char* ISPCHeader = nullptr; + const char* Fatbinary = nullptr; + const char* RegisterFile = nullptr; }; // Expand rule variables in CMake of the type found in language rules -- cgit v0.12