diff options
author | Brad King <brad.king@kitware.com> | 2023-12-20 14:09:12 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-12-20 14:09:48 (GMT) |
commit | a350d92c06d9640b0daa75663f057a1b48a1b432 (patch) | |
tree | 4d9409487e4865f3fa1bdae0d4b6e1a27a726cba /Source | |
parent | 5c1990fc5187884724a3fcc703051805bb97b99e (diff) | |
parent | ca5a300d7fee308a0f32bf677e4bb5d74ebbd0cc (diff) | |
download | CMake-a350d92c06d9640b0daa75663f057a1b48a1b432.zip CMake-a350d92c06d9640b0daa75663f057a1b48a1b432.tar.gz CMake-a350d92c06d9640b0daa75663f057a1b48a1b432.tar.bz2 |
Merge topic 'add_test-CROSSCOMPILING_EMULATOR-exclusive'
ca5a300d7f add_test: Honor CROSSCOMPILING_EMULATOR only when cross-compiling
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8947
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmPolicies.h | 6 | ||||
-rw-r--r-- | Source/cmTest.cxx | 1 | ||||
-rw-r--r-- | Source/cmTest.h | 8 | ||||
-rw-r--r-- | Source/cmTestGenerator.cxx | 4 |
4 files changed, 17 insertions, 2 deletions
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7964f32..f038c6b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -480,7 +480,11 @@ class cmMakefile; 29, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0157, \ "Swift compilation mode selected by an abstraction.", 3, 29, 0, \ - cmPolicies::WARN) + cmPolicies::WARN) \ + SELECT(POLICY, CMP0158, \ + "add_test() honors CMAKE_CROSSCOMPILING_EMULATOR only when " \ + "cross-compiling.", \ + 3, 28, 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/cmTest.cxx b/Source/cmTest.cxx index b0d9c2d..7c9969c 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -9,6 +9,7 @@ cmTest::cmTest(cmMakefile* mf) : Backtrace(mf->GetBacktrace()) + , PolicyStatusCMP0158(mf->GetPolicyStatus(cmPolicies::CMP0158)) { this->Makefile = mf; this->OldStyle = true; diff --git a/Source/cmTest.h b/Source/cmTest.h index 8b50b87..480966a 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -9,6 +9,7 @@ #include <vector> #include "cmListFileCache.h" +#include "cmPolicies.h" #include "cmPropertyMap.h" #include "cmValue.h" @@ -60,6 +61,12 @@ public: bool GetOldStyle() const { return this->OldStyle; } void SetOldStyle(bool b) { this->OldStyle = b; } + /** Get/Set if CMP0158 policy is NEW */ + bool GetCMP0158IsNew() const + { + return this->PolicyStatusCMP0158 == cmPolicies::NEW; + } + /** Set/Get whether lists in command lines should be expanded. */ bool GetCommandExpandLists() const; void SetCommandExpandLists(bool b); @@ -74,4 +81,5 @@ private: cmMakefile* Makefile; cmListFileBacktrace Backtrace; + cmPolicies::PolicyStatus PolicyStatusCMP0158; }; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 2831d0d..3194d8f 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -167,6 +167,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, if (target && target->GetType() == cmStateEnums::EXECUTABLE) { // Use the target file on disk. exe = target->GetFullPath(config); + auto useEmulator = !this->GetTest()->GetCMP0158IsNew() || + this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"); // Prepend with the test launcher if specified. cmValue launcher = target->GetProperty("TEST_LAUNCHER"); @@ -182,7 +184,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Prepend with the emulator when cross compiling if required. cmValue emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); - if (cmNonempty(emulator)) { + if (cmNonempty(emulator) && useEmulator) { cmList emulatorWithArgs{ *emulator }; std::string emulatorExe(emulatorWithArgs[0]); cmSystemTools::ConvertToUnixSlashes(emulatorExe); |