mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-13 05:11:01 +00:00
cmake: copy DLLs to build directory in MSVC
this is done as a POST_BUILD step
This commit is contained in:
parent
4d3a7dd8fb
commit
ec79756c42
2 changed files with 34 additions and 18 deletions
|
@ -34,6 +34,22 @@ macro(add_framework fwname appname)
|
|||
endif()
|
||||
endmacro()
|
||||
|
||||
# Macro to copy Windows DLLs to Debug/Release folder for easy debugging
|
||||
# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though
|
||||
macro(copy_files_to_build_dir target dlllist_var)
|
||||
if(MSVC)
|
||||
# http://stackoverflow.com/a/26983405/3064195
|
||||
foreach(dlllist_item ${${dlllist_var}})
|
||||
get_filename_component(dllname ${dlllist_item} NAME)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${dlllist_item}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/\$\(Configuration\)/${dllname}
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# 64-bit check
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
message(STATUS "Target is 64-bit")
|
||||
|
|
|
@ -179,32 +179,32 @@ if(${SDL2_FOUND})
|
|||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
find_library(SRB2_SDL2_DLL_SDL2 "SDL2.dll")
|
||||
set(win_extra_dll_list "")
|
||||
macro(getwinlib dllname defaultname)
|
||||
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
|
||||
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
|
||||
endmacro()
|
||||
getwinlib(SDL2 "SDL2.dll")
|
||||
if(${SRB2_CONFIG_SDL2_USEMIXER})
|
||||
find_library(SRB2_SDL2_DLL_SDL2_mixer "SDL2_mixer.dll")
|
||||
find_library(SRB2_SDL2_DLL_libmikmod-2 "libmikmod-2.dll")
|
||||
find_library(SRB2_SDL2_DLL_libogg_0 "libogg-0.dll")
|
||||
find_library(SRB2_SDL2_DLL_libvorbis_0 "libvorbis-0.dll")
|
||||
find_library(SRB2_SDL2_DLL_libvorbisfile_3 "libvorbisfile-3.dll")
|
||||
find_library(SRB2_SDL2_DLL_smpeg2 "smpeg2.dll")
|
||||
getwinlib(SDL2_mixer "SDL2_mixer.dll")
|
||||
getwinlib(libmikmod-2 "libmikmod-2.dll")
|
||||
getwinlib(libogg_0 "libogg-0.dll")
|
||||
getwinlib(libvorbis_0 "libvorbis-0.dll")
|
||||
getwinlib(libvorbisfile_3 "libvorbisfile-3.dll")
|
||||
getwinlib(smpeg2 "smpeg2.dll")
|
||||
endif()
|
||||
if(${SRB2_CONFIG_HAVE_GME})
|
||||
find_library(SRB2_SDL2_DLL_libgme "libgme.dll")
|
||||
getwinlib(libgme "libgme.dll")
|
||||
endif()
|
||||
|
||||
install(PROGRAMS
|
||||
${SRB2_SDL2_DLL_SDL2}
|
||||
|
||||
${SRB2_SDL2_DLL_SDL2_mixer}
|
||||
${SRB2_SDL2_DLL_libmikmod}
|
||||
${SRB2_SDL2_DLL_libogg_0}
|
||||
${SRB2_SDL2_DLL_libvorbis_0}
|
||||
${SRB2_SDL2_DLL_libvorbisfile_3}
|
||||
${SRB2_SDL2_DLL_smpeg2}
|
||||
|
||||
${SRB2_SDL2_DLL_libgme}
|
||||
${win_extra_dll_list}
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
# We also want to copy those DLLs to build directories on MSVC.
|
||||
# So we'll add a post_build step.
|
||||
copy_files_to_build_dir(${SRB2_SDL2_EXE_NAME} win_extra_dll_list)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue