From 542bd343e3eb5b824046649c0335a56dd2497f8e Mon Sep 17 00:00:00 2001 From: Asit Dhal Date: Sun, 11 Jul 2021 20:33:01 +0200 Subject: VS: Always enable CMAKE_MSVCIDE_RUN_PATH Do not require a language to be enabled. Fixes: #22343 --- Source/cmLocalVisualStudioGenerator.cxx | 2 +- Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt | 3 +++ .../CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt | 1 + Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake | 2 ++ Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake | 8 ++++++++ Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat | 1 + Tests/RunCMake/CMakeLists.txt | 1 + 7 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt create mode 100644 Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt create mode 100644 Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake create mode 100644 Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake create mode 100755 Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 002f484..46f9d31 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -171,7 +171,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript( // for visual studio IDE add extra stuff to the PATH // if CMAKE_MSVCIDE_RUN_PATH is set. - if (this->Makefile->GetDefinition("MSVC_IDE")) { + if (this->GetGlobalGenerator()->IsVisualStudio()) { cmProp extraPath = this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH"); if (extraPath) { script += newline; diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt new file mode 100644 index 0000000..bbc08e6 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.21) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt new file mode 100644 index 0000000..f0f2efc --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt @@ -0,0 +1 @@ +This message is printed by echo_message.bat diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake new file mode 100644 index 0000000..63d6068 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake @@ -0,0 +1,2 @@ +set(CMAKE_MSVCIDE_RUN_PATH "${CMAKE_SOURCE_DIR}") +add_custom_target(main COMMAND echo_message) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake new file mode 100644 index 0000000..a424ff2 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CheckEnvironmentVar-build) +run_cmake(CheckEnvironmentVar) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(CheckEnvironmentVar-build ${CMAKE_COMMAND} --build . --config Debug --target main) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat new file mode 100755 index 0000000..9037d02 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat @@ -0,0 +1 @@ +echo This message is printed by echo_message.bat diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 59fa9dc..de01ba6 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -544,6 +544,7 @@ if(CMake_TEST_FindGTK2) endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + add_RunCMake_test(CMAKE_MSVCIDE_RUN_PATH) add_RunCMake_test(include_external_msproject -DVS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME}) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio (9|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) set(NO_USE_FOLDERS 1) -- cgit v0.12