VS_DEBUGGER_ENVIRONMENT should have an INTERFACE_ variant for usage requirements
As of CMake 3.13 I can build an executable which uses Qt5 and be able to debug it in Visual Studio like this:
cmake_minimum_required(VERSION 3.13)
project(cmaketest)
find_package(Qt5Widgets REQUIRED)
add_executable(mn main.cpp)
target_link_libraries(mn PRIVATE Qt5::Widgets)
set(targetPath
"%PATH%;$<TARGET_FILE_DIR:Qt5::Widgets>;${otherPaths}")
set(targetEnvSep "\n")
set_property(TARGET mn PROPERTY
VS_DEBUGGER_ENVIRONMENT "PATH=${targetPath}${targetEnvSep}QT_PLUGIN_PATH=/path/to/Qt/plugins"
)
The VS_DEBUGGER_ENVIRONMENT
is useful, but it is not convenient to use in a large project because the feature lacks transitive usage requirements.
The Qt5 imported targets (and any targets) should be able to provide some expression of a usage requirement for this feature. CMake should consume the INTERFACE property and apply it to executables.
A possible design is for INTERFACE_VS_DEBUGGER_ENVIRONMENT_<ENVVAR>
target properties to be populated and for CMake to aggregate them as needed. Two dependencies should be able to set different INTERFACE_VS_DEBUGGER_ENVIRONMENT_PATH
content and have that combined into a single PATH
setting in the VS_DEBUGGER_ENVIRONMENT
content. Qt needs to be able to set QT_PLUGIN_PATH
, and other dependencies might have similar requirements.