Browse Source

CMake: create the output dir before copying a DLL.

Otherwise, in case of SDL and GLFW, where we don't really know the DLL
name, it would create a file named `bin` instead of copying into a newly
created bin/ directory if it doesn't exist yet. That happens in case of
a static build, where there are no DLLs and thus
CMAKE_RUNTIME_OUTPUT_DIRECTORY gets never created.
pull/454/head
Vladimír Vondruš 6 years ago
parent
commit
5b7caaee84
  1. 11
      src/Magnum/Audio/CMakeLists.txt
  2. 30
      src/Magnum/Platform/CMakeLists.txt

11
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 $<$<CONFIG:Debug>:${OPENAL_DLL_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${OPENAL_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenAL32.dll)
set(openal_dll_input $<$<CONFIG:Debug>:${OPENAL_DLL_DEBUG}>$<$<NOT:$<CONFIG: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

30
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 $<$<CONFIG:Debug>:${GLFW_DLL_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${GLFW_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(glfw_dll_input $<$<CONFIG:Debug>:${GLFW_DLL_DEBUG}>$<$<NOT:$<CONFIG: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 $<$<CONFIG:Debug>:${SDL2_DLL_DEBUG}>$<$<NOT:$<CONFIG:Debug>>,${SDL2_DLL_RELEASE}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(sdl2_dll_input $<$<CONFIG:Debug>:${SDL2_DLL_DEBUG}>$<$<NOT:$<CONFIG: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

Loading…
Cancel
Save