Hi !
I am not sure if it is a more about SFML or about cmake but :
(Windows 10 x64 / SFML 2.6.x / CMake 3.21.0)
I am using FetchContent to automatically fecth sfml and build it alongside my project statically.
Problem is I cant run my project because it needs openal32.dll to be next to the executable to run, but openal32.dll is in build\_deps\sfml-src\extlibs\bin\x64\openal32.dll and my executable at project root.
I can simply move the dll next to my project manualy but I would like cmake to do it automatically, I tried to use a custom command and $<TARGET_RUNTIME_DLLS:exe> from cmake 3.21 but it cant find any dll.
So, is there a simple way to do what I described ?
It feels like an obvious thing but I cant quite find the way to do it ...
Thanks !
CMake :
cmake_minimum_required(VERSION 3.21.0
)include(FetchContent
)project(exe
VERSION 0.1.0
)### CMake config ###set(CMAKE_EXPORT_COMPILE_COMMANDS
ON)set(CMAKE_CXX_STANDARD 20
)set(CMAKE_CXX_EXTENSIONS
OFF)set(CMAKE_CXX_STANDARD_REQUIRED
TRUE)set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${PROJECT_SOURCE_DIR}")### Dependency declaration ###FetchContent_Declare
( sfml
GIT_REPOSITORY
"https://github.com/SFML/SFML.git" GIT_TAG 2.6.x
)### Dependency population #### sfmlset(BUILD_SHARED_LIBS
OFF)set(SFML_BUILD_EXAMPLES
OFF)set(SFML_BUILD_DOC
OFF)set(SFML_BUILD_NETWORK
OFF)set(SFML_BUILD_AUDIO
ON)set(SFML_BUILD_GRAPHICS
ON)set(SFML_BUILD_WINDOW
ON)FetchContent_GetProperties
(sfml
)if(NOT sfml_POPULATED
) FetchContent_Populate
(sfml
) add_subdirectory(${sfml_SOURCE_DIR})endif()# !sfml# sfml audio cannot build since c++17 due to removed auto_ptr (fixed in sfml 2.6.x)# set_target_properties(sfml-audio PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)### Project headers ###include_directories(include
)### Project sources ###file(GLOB_RECURSE SRCS ./src/*
)add_executable(exe
${SRCS})target_link_libraries( exe
sfml-graphics
sfml-window
sfml-system
sfml-audio
)## Fail since $<TARGET_RUNTIME_DLLS:exe> resolves to empty stringadd_custom_command(TARGET exe
POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:exe> $<TARGET_FILE_DIR:exe>
COMMAND_EXPAND_LISTS
)