From ab3b549ee0dcd79607f8347a9b69c9b029590fbd Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 21 Jan 2019 09:57:25 -0500 Subject: CROSSCOMPILING_EMULATOR: Fix test generation for empty value If CROSSCOMPILING_EMULATOR was set to an empty string, and a test was generated with the executable as the command, CMake would segfault upon trying to generate the test file. Fix this. Fixes: #18819 --- Source/cmTestGenerator.cxx | 2 +- .../CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 1e2ddc7..6032701 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -90,7 +90,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Prepend with the emulator when cross compiling if required. const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); - if (emulator != nullptr) { + if (emulator != nullptr && *emulator) { std::vector emulatorWithArgs; cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); std::string emulatorExe(emulatorWithArgs[0]); diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake index 1aeb510..2fdefc4 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake @@ -26,3 +26,9 @@ get_property(emulator TARGET target_without_emulator if(NOT "${emulator}" STREQUAL "") message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set to null") endif() + +add_executable(target_with_empty_emulator simple_src_exiterror.cxx) +set_property(TARGET target_with_empty_emulator PROPERTY CROSSCOMPILING_EMULATOR "") + +enable_testing() +add_test(NAME test_target_with_empty_emulator COMMAND target_with_empty_emulator) -- cgit v0.12