diff --git a/cmake/macros.cmake b/cmake/macros.cmake index e3cd1bafa..61659e2fb 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -190,6 +190,17 @@ macro(default_plugin_options name) # ${CMAKE_INSTALL_PREFIX}/xstudio.bin.app/Contents/Resources/share/xstudio/plugin/lib${name}.dylib # ) + elseif(WIN32) + # On Windows for SHARED libs, RUNTIME_OUTPUT_DIRECTORY controls the .dll + # (LIBRARY_OUTPUT_DIRECTORY only controls the .lib import library). + # Build the .dll directly at the final location so the .pdb sits next to + # it — debuggers resolve symbols without ambiguity, and no POST_BUILD copy + # is needed. + set_target_properties(${name} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/share/xstudio/plugin" + ) + else() set_target_properties(${name} PROPERTIES @@ -209,12 +220,9 @@ macro(default_plugin_options name) # We don't want the vcpkg install because it forces dependences; we just want the plugin. _install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION share/xstudio/plugin) - #For interactive debugging, we want only the output dll to be copied to the build plugins folder. - add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "$" "${CMAKE_BINARY_DIR}/share/xstudio/plugin" - ) + # Note: default_plugin_options sets RUNTIME_OUTPUT_DIRECTORY to + # ${CMAKE_BINARY_DIR}/share/xstudio/plugin on Windows, so the .dll is + # already linked at the final dev-tree location. No POST_BUILD copy needed. endif() endmacro() @@ -380,9 +388,15 @@ macro(add_python_plugin NAME) else() - add_custom_command(TARGET COPY_PY_PLUGIN_${NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${NAME} ${CMAKE_BINARY_DIR}/bin/plugin-python/${NAME}) + if (WIN32) + add_custom_command(TARGET COPY_PY_PLUGIN_${NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${NAME} ${CMAKE_BINARY_DIR}/share/xstudio/plugin-python/${NAME}) + else() + add_custom_command(TARGET COPY_PY_PLUGIN_${NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${NAME} ${CMAKE_BINARY_DIR}/bin/plugin-python/${NAME}) + endif() endif() @@ -491,10 +505,17 @@ macro(add_resource name path target resource_type) else() - add_custom_command(TARGET ${target} POST_BUILD + if (WIN32) + add_custom_command(TARGET ${target} POST_BUILD + BYPRODUCTS ${CMAKE_BINARY_DIR}/share/xstudio/${resource_type}/${name} + COMMAND ${CMAKE_COMMAND} -E copy ${path}/${name} + ${CMAKE_BINARY_DIR}/share/xstudio/${resource_type}/${name}) + else() + add_custom_command(TARGET ${target} POST_BUILD BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/${resource_type}/${name} COMMAND ${CMAKE_COMMAND} -E copy ${path}/${name} ${CMAKE_BINARY_DIR}/bin/${resource_type}/${name}) + endif() if(INSTALL_XSTUDIO) install(FILES @@ -556,9 +577,15 @@ macro(add_font name path target) else() - add_custom_command(TARGET ${target} POST_BUILD + if (WIN32) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${path}/${name} + ${CMAKE_BINARY_DIR}/share/xstudio/fonts/${name}) + else() + add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${path}/${name} ${CMAKE_BINARY_DIR}/bin/fonts/${name}) + endif() if(INSTALL_XSTUDIO) install(FILES diff --git a/extern/quickfuture/CMakeLists.txt b/extern/quickfuture/CMakeLists.txt index c59299b02..3caa1ee2f 100644 --- a/extern/quickfuture/CMakeLists.txt +++ b/extern/quickfuture/CMakeLists.txt @@ -24,6 +24,13 @@ if(APPLE) PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/xSTUDIO.app/Contents/PlugIns/xstudio/qml/QuickFuture" ) +elseif(WIN32) + # On Windows for SHARED libs, RUNTIME_OUTPUT_DIRECTORY controls the .dll. + # qmldir declares `plugin quickfuture` so the .dll must be co-located with + # qmldir in the module directory at runtime. + set_target_properties(quickfuture + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/share/xstudio/plugin/qml/QuickFuture") else() set_target_properties(quickfuture PROPERTIES @@ -49,6 +56,8 @@ set(QML_FUTURE_FILES if (APPLE) set(QML_DEST_DIR ${CMAKE_BINARY_DIR}/xSTUDIO.app/Contents/PlugIns/xstudio/qml/QuickFuture) +elseif (WIN32) + set(QML_DEST_DIR ${CMAKE_BINARY_DIR}/share/xstudio/plugin/qml/QuickFuture) else() set(QML_DEST_DIR ${CMAKE_BINARY_DIR}/bin/plugin/qml/QuickFuture) endif() diff --git a/extern/quickpromise/CMakeLists.txt b/extern/quickpromise/CMakeLists.txt index a3efcafa0..982af68eb 100644 --- a/extern/quickpromise/CMakeLists.txt +++ b/extern/quickpromise/CMakeLists.txt @@ -61,6 +61,8 @@ add_custom_target(COPY_PROMISE_QML) if (APPLE) set(QML_DEST_DIR ${CMAKE_BINARY_DIR}/xSTUDIO.app/Contents/PlugIns/xstudio/qml/QuickPromise) +elseif (WIN32) + set(QML_DEST_DIR ${CMAKE_BINARY_DIR}/share/xstudio/plugin/qml/QuickPromise) else() set(QML_DEST_DIR ${CMAKE_BINARY_DIR}/bin/plugin/qml/QuickPromise) endif() diff --git a/share/snippets/CMakeLists.txt b/share/snippets/CMakeLists.txt index ccd08a3e5..f5c4839e9 100644 --- a/share/snippets/CMakeLists.txt +++ b/share/snippets/CMakeLists.txt @@ -2,11 +2,16 @@ set(snippets) macro(add_snip name) - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/snippets/${name} + if (WIN32) + set(_snip_dest ${CMAKE_BINARY_DIR}/share/xstudio/snippets/${name}) + else() + set(_snip_dest ${CMAKE_BINARY_DIR}/bin/snippets/${name}) + endif() + add_custom_command(OUTPUT ${_snip_dest} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${name} - ${CMAKE_BINARY_DIR}/bin/snippets/${name} + ${_snip_dest} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}) - list(APPEND snippets ${CMAKE_BINARY_DIR}/bin/snippets/${name}) + list(APPEND snippets ${_snip_dest}) endmacro() add_snip(Demo/print_status.py) diff --git a/src/launch/xstudio/src/CMakeLists.txt b/src/launch/xstudio/src/CMakeLists.txt index aa460f563..dd8acd08e 100644 --- a/src/launch/xstudio/src/CMakeLists.txt +++ b/src/launch/xstudio/src/CMakeLists.txt @@ -116,6 +116,7 @@ if(WIN32) get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) file(TO_NATIVE_PATH "${_qt_bin_dir}" _qt_bin_dir) + file(TO_NATIVE_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin" _vcpkg_bin_dir) configure_file(run_xstudio.bat.in ${CMAKE_BINARY_DIR}/run_xstudio.bat @ONLY) elseif(APPLE) diff --git a/src/launch/xstudio/src/run_xstudio.bat.in b/src/launch/xstudio/src/run_xstudio.bat.in index c701e3e6f..4c67a574d 100644 --- a/src/launch/xstudio/src/run_xstudio.bat.in +++ b/src/launch/xstudio/src/run_xstudio.bat.in @@ -3,5 +3,5 @@ REM Dev-only launcher for xstudio.exe from the build tree. REM Adds Qt's bin directory to PATH so Qt DLLs resolve without needing REM an install or windeployqt run. Generated by CMake; do not edit. -set "PATH=@_qt_bin_dir@;%~dp0bin;%PATH%" +set "PATH=@_qt_bin_dir@;@_vcpkg_bin_dir@;%~dp0bin;%PATH%" "%~dp0bin\xstudio.exe" %* diff --git a/src/plugin_manager/test/CMakeLists.txt b/src/plugin_manager/test/CMakeLists.txt index 311553813..c564b5f65 100644 --- a/src/plugin_manager/test/CMakeLists.txt +++ b/src/plugin_manager/test/CMakeLists.txt @@ -42,10 +42,6 @@ target_link_libraries(plugin_test xstudio::utility CAF::core ) -set_target_properties(${name} - PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/plugin" -) set_target_properties(plugin_test PROPERTIES LINK_DEPENDS_NO_SHARED true