From 5652175db7fde8a50543dd8dcfd4ed15053b0fee Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 30 Jan 2025 00:13:54 +0100 Subject: [PATCH] CMakeLists.txt: Copy solid dlls to bin directory As opposed to POSIX, Windows lacks a rpath mechanism, which means that shared libraries (aka dlls) must reside next to the executable. [1] Since freesolid is no longer built by the 3rdParty build system (i.e., it is now a submodule), CMake must copy its libraries to the bin/ directory so simuv5 and friends can find them. Note that no modifications were required for the install step, since libraries would be already installed by the submodule. Fixes https://forge.a-lec.org/speed-dreams/speed-dreams-code/issues/42 [1]: https://stackoverflow.com/questions/3272383/linking-with-r-and-rpath-switches-on-windows --- CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b134668d..196de77e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,23 @@ IF(MSVC) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/userman/images/ DESTINATION ./doc/images/) ENDIF(MSVC) +if(WIN32) + function(copy_dll target) + add_custom_target(${target}_copydll) + add_dependencies(${target}_copydll ${target}) + add_dependencies(${PROJECT_NAME} ${target}_copydll) + add_custom_command(TARGET ${target}_copydll + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ ${CMAKE_BINARY_DIR}/bin/ + VERBATIM + ) + endfunction() + + copy_dll(solid) + copy_dll(broad) + copy_dll(moto) +endif() + # Must be the last ADD_SUBDIRECTORY for FIXUP_BUNDLE to work ADD_SUBDIRECTORY(packaging)