diff options
author | Brad King <brad.king@kitware.com> | 2022-05-10 14:27:02 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-05-10 10:27:15 -0400 |
commit | 54c3563e951edf70f4fa4fe310cbed21f5412a56 (patch) | |
tree | 7e5668265531388f817e8d57107b2064999fbadc /Source | |
parent | 02b4cd9827b7f2354350bef4e44cb3514edb5c26 (diff) | |
parent | 6a2b016bbd35f5843cc95e36431928fd0905a61c (diff) | |
download | cmake-54c3563e951edf70f4fa4fe310cbed21f5412a56.tar.gz |
Merge topic 'watcom-runtime-library-v2'
6a2b016bbd OpenWatcom: Support CMAKE_WATCOM_RUNTIME_LIBRARY with Linux and OS/2 builds
33da5824ac OpenWatcom: Allow specifying the runtime library
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7184
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 10 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 32 | ||||
-rw-r--r-- | Source/cmPolicies.h | 5 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
4 files changed, 47 insertions, 1 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 5bdd8882ef..4909948c2b 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -228,6 +228,8 @@ std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES = std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES = "CMAKE_TRY_COMPILE_PLATFORM_VARIABLES"; std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED"; +std::string const kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT = + "CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT"; /* GHS Multi platform variables */ std::set<std::string> const ghs_platform_vars{ @@ -555,6 +557,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, !msvcRuntimeLibraryDefault->empty() ? "NEW" : "OLD"); } + /* Set Watcom runtime library policy to match our selection. */ + if (cmValue watcomRuntimeLibraryDefault = this->Makefile->GetDefinition( + kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT)) { + fprintf(fout, "cmake_policy(SET CMP0136 %s)\n", + !watcomRuntimeLibraryDefault->empty() ? "NEW" : "OLD"); + } + /* Set CUDA architectures policy to match outer project. */ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0104) != cmPolicies::NEW && @@ -902,6 +911,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert(kCMAKE_SYSROOT_LINK); vars.insert(kCMAKE_WARN_DEPRECATED); vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s); + vars.emplace("CMAKE_WATCOM_RUNTIME_LIBRARY"_s); if (cmValue varListStr = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c54d5bfe74..4b0a78bff7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1994,6 +1994,38 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } } + + // Add Watcom runtime library flags. This is activated by the presence + // of a default selection whether or not it is overridden by a property. + cmValue watcomRuntimeLibraryDefault = + this->Makefile->GetDefinition("CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT"); + if (cmNonempty(watcomRuntimeLibraryDefault)) { + cmValue watcomRuntimeLibraryValue = + target->GetProperty("WATCOM_RUNTIME_LIBRARY"); + if (!watcomRuntimeLibraryValue) { + watcomRuntimeLibraryValue = watcomRuntimeLibraryDefault; + } + std::string const watcomRuntimeLibrary = cmGeneratorExpression::Evaluate( + *watcomRuntimeLibraryValue, this, config, target); + if (!watcomRuntimeLibrary.empty()) { + if (cmValue watcomRuntimeLibraryOptions = this->Makefile->GetDefinition( + "CMAKE_" + lang + "_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_" + + watcomRuntimeLibrary)) { + this->AppendCompileOptions(flags, *watcomRuntimeLibraryOptions); + } else if ((this->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_ID") == "OpenWatcom" || + this->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_SIMULATE_ID") == "OpenWatcom") && + !cmSystemTools::GetErrorOccuredFlag()) { + // The compiler uses the Watcom ABI so it needs a known runtime + // library. + this->IssueMessage(MessageType::FATAL_ERROR, + "WATCOM_RUNTIME_LIBRARY value '" + + watcomRuntimeLibrary + "' not known for this " + + lang + " compiler."); + } + } + } } void cmLocalGenerator::AddLanguageFlagsForLinking( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7d066074f9..49770833bf 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -408,7 +408,10 @@ class cmMakefile; SELECT(POLICY, CMP0135, \ "ExternalProject ignores timestamps in archives by default for the " \ "URL download method", \ - 3, 24, 0, cmPolicies::WARN) + 3, 24, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0136, \ + "Watcom runtime library flags are selected by an abstraction.", 3, \ + 24, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index feb2ee3909..646fd7eeef 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -543,6 +543,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("LINK_DEPENDS_NO_SHARED"); initProp("LINK_INTERFACE_LIBRARIES"); initProp("MSVC_RUNTIME_LIBRARY"); + initProp("WATCOM_RUNTIME_LIBRARY"); initProp("WIN32_EXECUTABLE"); initProp("MACOSX_BUNDLE"); initProp("MACOSX_RPATH"); |