From ef1fbd8e4b3963f1f58f6b44a9a52c296824923c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 12 Oct 2019 16:26:38 +0200 Subject: [PATCH] CMake: copy SDL / GLFW DLLs to CMAKE_RUNTIME_OUTPUT_DIRECTORY. Shall make Windows users' life a bit less painful. --- doc/changelog.dox | 7 +++++++ src/Magnum/Platform/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index 62b6ca946..594801176 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -532,6 +532,13 @@ See also: - `FindSDL2.cmake` was updated to work with MinGW version 2.0.5 and newer, since these dropped the old directory hierarchy. Older versions have both the original and the new hierarchy, so it should work with these as well. +- When using Magnum as a CMake subproject, @ref Platform::GlfwApplication and + @ref Platform::Sdl2Application now copy the GLFW / SDL2 DLLs to + `CMAKE_RUNTIME_OUTPUT_DIRECTORY` (if set) as a post-build step. The DLL + location, if found, is also available through `GLFW_DLL` and + `SDL2_DLL_RELEASE` / `SDL2_DLL_DEBUG` variables for use by 3rd party code. + See also [mosra/magnum#347](https://github.com/mosra/magnum/pull/347) for + more information. - Updated *extremely* outdated Emscripten boilerplate from the [base-emscripten bootstrap project](https://github.com/mosra/magnum-bootstrap/tree/base-emscripten) (the HTML markup was unchanged since 2013, heh) diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 6e73220f1..38f97639f 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -268,6 +268,21 @@ if(WITH_GLFWAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + # Copy the GLFW DLL next to the place where all executables are stored to + # 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}) + 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}) + else() + add_custom_command(TARGET MagnumGlfwApplication POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + endif() + endif() + # Magnum GlfwApplication target alias for superprojects add_library(Magnum::GlfwApplication ALIAS MagnumGlfwApplication) endif() @@ -323,6 +338,21 @@ if(WITH_SDL2APPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + # Copy the SDL2 DLL next to the place where all executables are stored to + # 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}) + 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}) + else() + add_custom_command(TARGET MagnumSdl2Application POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SDL2_DLL_RELEASE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + endif() + endif() + # Magnum Sdl2Application target alias for superprojects add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application) endif()