summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2023-11-02 16:48:15 (GMT)
committerBrad King <brad.king@kitware.com>2023-12-19 15:00:55 (GMT)
commitca5a300d7fee308a0f32bf677e4bb5d74ebbd0cc (patch)
tree47870643781ec741b668a8dd0403e0d2d34dba31 /Source
parentdaf8da8c8007229490dbdf0b2cd32f0b575f3c00 (diff)
downloadCMake-ca5a300d7fee308a0f32bf677e4bb5d74ebbd0cc.zip
CMake-ca5a300d7fee308a0f32bf677e4bb5d74ebbd0cc.tar.gz
CMake-ca5a300d7fee308a0f32bf677e4bb5d74ebbd0cc.tar.bz2
add_test: Honor CROSSCOMPILING_EMULATOR only when cross-compiling
Add policy CMP0158 to provide compatibility for existing projects. Fixes: #23672
Diffstat (limited to 'Source')
-rw-r--r--Source/cmPolicies.h6
-rw-r--r--Source/cmTest.cxx1
-rw-r--r--Source/cmTest.h8
-rw-r--r--Source/cmTestGenerator.cxx4
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);