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 speed-dreams/speed-dreams-code#42

[1]: https://stackoverflow.com/questions/3272383/linking-with-r-and-rpath-switches-on-windows
This commit is contained in:
Xavier Del Campo Romero 2025-01-30 00:13:54 +01:00
parent 5cf9c09950
commit 5652175db7
Signed by: xavi
GPG key ID: 84FF3612A9BF43F2

View file

@ -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
$<TARGET_FILE:${target}> ${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)