mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-04 04:03:22 +03:00
6 files changed
+81
-1
No files matched your search
@@ -11,6 +11,7 @@
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
@@ -320,6 +321,17 @@ cmCxxModuleUsageEffects::cmCxxModuleUsageEffects(cmGeneratorTarget const* gt,
|
||||
gt->GetLanguageStandardRequired("CXX") ? "TRUE" : "FALSE"));
|
||||
}
|
||||
|
||||
cmValue runtimeDefault =
|
||||
gt->Makefile->GetDefinition("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT");
|
||||
if (cmNonempty(runtimeDefault)) {
|
||||
cmValue runtime = gt->GetProperty("MSVC_RUNTIME_LIBRARY");
|
||||
this->MsvcRuntimeLibrary =
|
||||
cmGeneratorExpression::Evaluate(runtime ? *runtime : *runtimeDefault,
|
||||
gt->GetLocalGenerator(), config, gt);
|
||||
AppendUsage(usageHashInput,
|
||||
cmStrCat("MSVC_RUNTIME_LIBRARY:", this->MsvcRuntimeLibrary));
|
||||
}
|
||||
|
||||
cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_512);
|
||||
this->Hash = hasher.HashString(usageHashInput);
|
||||
}
|
||||
@@ -329,6 +341,11 @@ std::string const& cmCxxModuleUsageEffects::GetHash() const
|
||||
return this->Hash;
|
||||
}
|
||||
|
||||
std::string const& cmCxxModuleUsageEffects::GetMsvcRuntimeLibrary() const
|
||||
{
|
||||
return this->MsvcRuntimeLibrary;
|
||||
}
|
||||
|
||||
std::vector<BT<std::string>> const&
|
||||
cmCxxModuleUsageEffects::GetPreprocessorCompileOptions() const
|
||||
{
|
||||
|
||||
@@ -17,9 +17,11 @@ public:
|
||||
cmCxxModuleUsageEffects(cmGeneratorTarget const* gt,
|
||||
std::string const& config);
|
||||
std::string const& GetHash() const;
|
||||
std::string const& GetMsvcRuntimeLibrary() const;
|
||||
std::vector<BT<std::string>> const& GetPreprocessorCompileOptions() const;
|
||||
|
||||
private:
|
||||
std::string Hash;
|
||||
std::string MsvcRuntimeLibrary;
|
||||
std::vector<BT<std::string>> PreprocessorCompileOptions;
|
||||
};
|
||||
+4
-1
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCustomCommand.h"
|
||||
#include "cmCxxModuleUsageEffects.h"
|
||||
#include "cmFileSet.h"
|
||||
#include "cmFileSetMetadata.h"
|
||||
#include "cmFindPackageStack.h"
|
||||
@@ -1854,6 +1855,9 @@ void cmTarget::CopyUsageEffects(cmGeneratorTarget const* gt,
|
||||
}
|
||||
copyProperty(tgt, this, "CXX_EXTENSIONS");
|
||||
copyProperty(tgt, this, "CXX_STANDARD_REQUIRED");
|
||||
this->SetProperty(
|
||||
"MSVC_RUNTIME_LIBRARY",
|
||||
gt->GetCxxModuleUsageEffects(config).GetMsvcRuntimeLibrary());
|
||||
}
|
||||
|
||||
void cmTarget::CopyPolicyStatuses(cmTarget const* tgt)
|
||||
@@ -1942,7 +1946,6 @@ void cmTarget::CopyCxxModulesProperties(cmTarget const* tgt)
|
||||
// ---- Windows
|
||||
"MSVC_DEBUG_INFORMATION_FORMAT",
|
||||
"MSVC_RUNTIME_CHECKS",
|
||||
"MSVC_RUNTIME_LIBRARY",
|
||||
"VS_PLATFORM_TOOLSET",
|
||||
// ---- OpenWatcom
|
||||
"WATCOM_RUNTIME_LIBRARY",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
file(GLOB ninja_files "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/impl-*.ninja")
|
||||
else()
|
||||
set(ninja_files "${RunCMake_TEST_BINARY_DIR}/build.ninja")
|
||||
endif()
|
||||
|
||||
foreach(ninja_file IN LISTS ninja_files)
|
||||
file(READ "${ninja_file}" ninja)
|
||||
string(REGEX MATCHALL "build [^\n]*: CXX_COMPILER__runtime-module[^\n]*synth_[^\n]*\n( [^\n]*\n)*" rules "${ninja}")
|
||||
set(runtimes)
|
||||
foreach(rule IN LISTS rules)
|
||||
if(rule MATCHES "-runtime-([A-Za-z]+)")
|
||||
list(APPEND runtimes "${CMAKE_MATCH_1}")
|
||||
else()
|
||||
list(APPEND runtimes "empty")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(expected MultiThreaded MultiThreadedDLL MultiThreadedDebug MultiThreadedDebugDLL empty)
|
||||
list(SORT runtimes)
|
||||
list(SORT expected)
|
||||
if(NOT runtimes STREQUAL expected)
|
||||
set(RunCMake_TEST_FAILED "Synthetic runtime selections in ${ninja_file}: '${runtimes}', expected '${expected}'")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -0,0 +1,31 @@
|
||||
set(CMAKE_CXX_SCANDEP_SOURCE "")
|
||||
enable_language(CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
unset(CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
|
||||
add_library(runtime-module INTERFACE IMPORTED)
|
||||
target_sources(runtime-module INTERFACE
|
||||
FILE_SET modules TYPE CXX_MODULES FILES sources/module.cxx)
|
||||
set_property(TARGET runtime-module PROPERTY MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
|
||||
|
||||
foreach(runtime IN ITEMS MultiThreaded MultiThreadedDLL MultiThreadedDebug MultiThreadedDebugDLL)
|
||||
set(CMAKE_CXX_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_${runtime} "-runtime-${runtime}")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "${runtime}")
|
||||
add_library(${runtime} OBJECT main-no-use.cxx)
|
||||
target_link_libraries(${runtime} PRIVATE runtime-module)
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
|
||||
add_library(empty-runtime OBJECT main-no-use.cxx)
|
||||
target_link_libraries(empty-runtime PRIVATE runtime-module)
|
||||
|
||||
unset(CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
add_library(default-runtime OBJECT main-no-use.cxx)
|
||||
target_link_libraries(default-runtime PRIVATE runtime-module)
|
||||
|
||||
add_library(genex-runtime OBJECT main-no-use.cxx)
|
||||
set_target_properties(genex-runtime PROPERTIES
|
||||
CUSTOM_RUNTIME "MultiThreaded"
|
||||
MSVC_RUNTIME_LIBRARY "$<TARGET_PROPERTY:CUSTOM_RUNTIME>$<$<CONFIG:Debug>:Debug>")
|
||||
target_link_libraries(genex-runtime PRIVATE runtime-module)
|
||||
@@ -113,6 +113,7 @@ if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
run_cmake(NinjaDependInfoExportFilesystemSafe)
|
||||
run_cmake(NinjaDependInfoBMIInstall)
|
||||
run_cmake(NinjaForceResponseFile) # issue#25367
|
||||
run_cmake(NinjaMSVCRuntimeLibrary)
|
||||
run_cmake(NinjaDependInfoCompileDatabase)
|
||||
elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
|
||||
run_cmake(VisualStudioNoSyntheticTargets)
|
||||
|
||||
Reference in new issue
Block a user