mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 19:08:07 +08:00
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
This commit is contained in:
@@ -33,7 +33,7 @@ macro(__compiler_armcc lang)
|
||||
set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map")
|
||||
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--depend=<DEPFILE> --depend_single_line --no_depend_system_headers")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--depend=<DEP_FILE> --depend_single_line --no_depend_system_headers")
|
||||
|
||||
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ")
|
||||
endmacro()
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
|
||||
# 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.
|
||||
|
@@ -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 <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_ASM${ASM_DIALECT} "--MD <DEP_FILE>")
|
||||
set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE
|
||||
"<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
set(CMAKE_ASM_DEFINE_FLAG "--defsym ")
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
endif()
|
||||
|
||||
# Initial configuration flags.
|
||||
|
@@ -49,7 +49,7 @@ macro(__compiler_iar_ilink lang)
|
||||
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
|
||||
|
||||
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEP_FILE>")
|
||||
|
||||
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_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
|
||||
|
||||
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEP_FILE>")
|
||||
|
||||
string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
|
||||
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r")
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_C "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
|
||||
if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
|
||||
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_ISPC "-M -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
|
||||
string(APPEND CMAKE_ISPC_FLAGS_INIT " ")
|
||||
string(APPEND CMAKE_ISPC_FLAGS_DEBUG_INIT "-O0 -g")
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
endif()
|
||||
|
||||
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
|
@@ -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,<DEPFILE> -Wp,-MT,<OBJECT> -Wp,-MF,<DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD,<DEP_FILE> -Wp,-MT,<DEP_TARGET> -Wp,-MF,<DEP_FILE>")
|
||||
|
||||
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
|
||||
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
|
||||
|
@@ -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 <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_C "-xMD -xMF <DEP_FILE>")
|
||||
|
||||
# Initialize C link type selection flags. These flags are used when
|
||||
# building a shared library, shared module, or executable that links
|
||||
|
@@ -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 <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_CXX "-xMD -xMF <DEP_FILE>")
|
||||
|
||||
# Initialize C link type selection flags. These flags are used when
|
||||
# building a shared library, shared module, or executable that links
|
||||
|
@@ -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=<DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "--preproc_with_compile --preproc_dependency=<DEP_FILE>")
|
||||
|
||||
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> --preproc_only ${__COMPILER_TI_SOURCE_FLAG_${lang}}=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>")
|
||||
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> --compile_only --skip_assembler ${__COMPILER_TI_SOURCE_FLAG_${lang}}=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>")
|
||||
|
@@ -30,5 +30,5 @@ macro(__compiler_xl lang)
|
||||
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
|
||||
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
|
||||
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "-MF <DEPFILE> -qmakedep=gcc")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "-MF <DEP_FILE> -qmakedep=gcc")
|
||||
endmacro()
|
||||
|
@@ -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 <OBJECT> -MF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
|
||||
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}<DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}<DEP_FILE>")
|
||||
# The <FLAGS> 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 "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> <FLAGS> /fo <OBJECT> <OBJECT>.pp")
|
||||
|
@@ -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 <OBJECT> -QMF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
|
||||
|
@@ -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 <OBJECT> -QMF <DEPFILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
|
||||
|
@@ -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, "<DEPFILE>", "$DEP_FILE");
|
||||
cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
|
||||
cmSystemTools::ReplaceString(depfileFlags, "<DEP_FILE>", "$DEP_FILE");
|
||||
cmSystemTools::ReplaceString(depfileFlags, "<DEP_TARGET>", "$out");
|
||||
cmSystemTools::ReplaceString(
|
||||
depfileFlags, "<CMAKE_C_COMPILER>",
|
||||
cmToCStr(mf->GetDefinition("CMAKE_C_COMPILER")));
|
||||
|
@@ -3,7 +3,6 @@
|
||||
#include "cmRulePlaceholderExpander.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user