Skip to content

Commit

Permalink
Made vcpkg always build SDL2 in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
noodlecollie committed Apr 20, 2023
1 parent e15c8ea commit d7e081f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ cmake_minimum_required(VERSION 3.21)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# This cannot use HOST_PLATFORM because we don't want to rely on custom scripts
# just yet. This is an early check and should be OG CMake.
# just yet. This is an early check and should use OG CMake variables only.
if(WIN32)
set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/vcpkg-overlays")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()

Expand Down
6 changes: 6 additions & 0 deletions vcpkg-overlays/x64-windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

# The engine expects the SDL2 release library.
set(VCPKG_BUILD_TYPE release)
6 changes: 6 additions & 0 deletions vcpkg-overlays/x86-windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

# The engine expects the SDL2 release library.
set(VCPKG_BUILD_TYPE release)
15 changes: 15 additions & 0 deletions xash3d_engine/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,18 @@ install(TARGETS ${TARGETNAME_LIB_ENGINE}
LIBRARY DESTINATION ${INSTALL_ROOT}
RUNTIME DESTINATION ${INSTALL_ROOT}
)

if(TARGET_PLATFORM STREQUAL "WINDOWS" AND CLIENT_SUPPORT)
add_custom_command(
TARGET ${TARGETNAME_LIB_ENGINE} POST_BUILD
MAIN_DEPENDENCY SDL2::SDL2
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:SDL2::SDL2>"
"$<TARGET_FILE_DIR:${TARGETNAME_LIB_ENGINE}>"
)

install(IMPORTED_RUNTIME_ARTIFACTS SDL2::SDL2
RUNTIME DESTINATION ${INSTALL_ROOT}
LIBRARY DESTINATION ${INSTALL_ROOT}
)
endif()

0 comments on commit d7e081f

Please sign in to comment.