diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index c86fef020..af9ac818c 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -116,15 +116,14 @@ if(CMAKE_RUNTIME_OUTPUT_DIRECTORY AND CORRADE_TARGET_WINDOWS AND (OPENAL_DLL_DEB # named soft_oal.dll and needs to be renamed to OpenAL32.dll to work # correctly. Not the case with OpenAL Soft built by hand. if(OPENAL_DLL_DEBUG AND OPENAL_DLL_RELEASE) - add_custom_command(TARGET MagnumAudio POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $<$:${OPENAL_DLL_DEBUG}>$<$>:${OPENAL_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll) + set(openal_dll_input $<$:${OPENAL_DLL_DEBUG}>$<$>:${OPENAL_DLL_RELEASE}>) elseif(OPENAL_DLL_DEBUG) - add_custom_command(TARGET MagnumAudio POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENAL_DLL_DEBUG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll) + set(openal_dll_input ${OPENAL_DLL_DEBUG}) else() - add_custom_command(TARGET MagnumAudio POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENAL_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll) + set(openal_dll_input ${OPENAL_DLL_RELEASE}) endif() + add_custom_command(TARGET MagnumAudio POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${openal_dll_input} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll) endif() # Magnum Audio target alias for superprojects diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 95aaa5681..f1b404f1d 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -272,15 +272,18 @@ if(WITH_GLFWAPPLICATION) # help people running the apps if(CMAKE_RUNTIME_OUTPUT_DIRECTORY AND CORRADE_TARGET_WINDOWS AND (GLFW_DLL_DEBUG OR GLFW_DLL_RELEASE)) if(GLFW_DLL_DEBUG AND GLFW_DLL_RELEASE) - add_custom_command(TARGET MagnumGlfwApplication POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $<$:${GLFW_DLL_DEBUG}>$<$>:${GLFW_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(glfw_dll_input $<$:${GLFW_DLL_DEBUG}>$<$>:${GLFW_DLL_RELEASE}>) elseif(GLFW_DLL_DEBUG) - add_custom_command(TARGET MagnumGlfwApplication POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_DLL_DEBUG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(glfw_dll_input ${GLFW_DLL_DEBUG}) else() - add_custom_command(TARGET MagnumGlfwApplication POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(glfw_dll_input ${GLFW_DLL_RELEASE}) endif() + add_custom_command(TARGET MagnumGlfwApplication POST_BUILD + # The directory might not always exist before (e.g. if creating a + # static build) and copy_if_different would just name the file + # `bin` instead of creating such directory + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${glfw_dll_input} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() # Magnum GlfwApplication target alias for superprojects @@ -342,15 +345,18 @@ if(WITH_SDL2APPLICATION) # help people running the apps if(CMAKE_RUNTIME_OUTPUT_DIRECTORY AND CORRADE_TARGET_WINDOWS AND (SDL2_DLL_DEBUG OR SDL2_DLL_RELEASE)) if(SDL2_DLL_DEBUG AND SDL2_DLL_RELEASE) - add_custom_command(TARGET MagnumSdl2Application POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $<$:${SDL2_DLL_DEBUG}>$<$>,${SDL2_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(sdl2_dll_input $<$:${SDL2_DLL_DEBUG}>$<$>,${SDL2_DLL_RELEASE}>) elseif(SDL2_DLL_DEBUG) - add_custom_command(TARGET MagnumSdl2Application POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SDL2_DLL_DEBUG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(sdl2_dll_input ${SDL2_DLL_DEBUG}) else() - add_custom_command(TARGET MagnumSdl2Application POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SDL2_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(sdl2_dll_input ${SDL2_DLL_RELEASE}) endif() + add_custom_command(TARGET MagnumSdl2Application POST_BUILD + # The directory might not always exist before (e.g. if creating a + # static build) and copy_if_different would just name the file + # `bin` instead of creating such directory + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${sdl2_dll_input} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() # Magnum Sdl2Application target alias for superprojects