ref: 825f59bb89733078b572cd8557ab7e4001f2e9f6
parent: ac1f0c32193abd006536eb3bfd20dc8b3a6b691a
author: Roman Fomin <[email protected]>
date: Thu Jan 26 15:59:31 EST 2023
CMake build system updates (#1572) * Enable the CMAKE_FIND_PACKAGE_PREFER_CONFIG option to find modules first in configuration mode. * Rename SDL2 targets for compatibility with vendored configurations. * Add vcpkg.json to support vcpkg in manifest mode.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,9 @@
"-Wredundant-decls")
endif()
+option(CMAKE_FIND_PACKAGE_PREFER_CONFIG
+ "Lookup package config files before using find modules" On)
+
option(ENABLE_SDL2_NET "Enable SDL2_net" On)
option(ENABLE_SDL2_MIXER "Enable SDL2_mixer" On)
--- a/cmake/FindSDL2_mixer.cmake
+++ b/cmake/FindSDL2_mixer.cmake
@@ -79,8 +79,8 @@
if(SDL2_MIXER_FOUND)
# Imported target.
- add_library(SDL2::mixer UNKNOWN IMPORTED)
- set_target_properties(SDL2::mixer PROPERTIES
+ add_library(SDL2_mixer::SDL2_mixer UNKNOWN IMPORTED)
+ set_target_properties(SDL2_mixer::SDL2_mixer PROPERTIES
INTERFACE_COMPILE_OPTIONS "${PC_SDL2_MIXER_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES SDL2::SDL2
--- a/cmake/FindSDL2_net.cmake
+++ b/cmake/FindSDL2_net.cmake
@@ -79,8 +79,8 @@
if(SDL2_NET_FOUND)
# Imported target.
- add_library(SDL2::net UNKNOWN IMPORTED)
- set_target_properties(SDL2::net PROPERTIES
+ add_library(SDL2_net::SDL2_net UNKNOWN IMPORTED)
+ set_target_properties(SDL2_net::SDL2_net PROPERTIES
INTERFACE_COMPILE_OPTIONS "${PC_SDL2_NET_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_NET_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES SDL2::SDL2
--- a/opl/CMakeLists.txt
+++ b/opl/CMakeLists.txt
@@ -14,5 +14,5 @@
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
target_link_libraries(opl SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(opl SDL2::mixer)
+ target_link_libraries(opl SDL2_mixer::SDL2_mixer)
endif()
--- a/pcsound/CMakeLists.txt
+++ b/pcsound/CMakeLists.txt
@@ -10,5 +10,5 @@
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
target_link_libraries(pcsound SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(pcsound SDL2::mixer)
+ target_link_libraries(pcsound SDL2_mixer::SDL2_mixer)
endif()
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -34,7 +34,7 @@
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
target_link_libraries("${PROGRAM_PREFIX}server" SDL2::SDL2main SDL2::SDL2)
if(ENABLE_SDL2_NET)
- target_link_libraries("${PROGRAM_PREFIX}server" SDL2::net)
+ target_link_libraries("${PROGRAM_PREFIX}server" SDL2_net::SDL2_net)
endif()
# Source files used by the game binaries (chocolate-doom, etc.)
@@ -127,10 +127,10 @@
set(EXTRA_LIBS SDL2::SDL2main SDL2::SDL2 textscreen pcsound opl)
if(ENABLE_SDL2_MIXER)
- list(APPEND EXTRA_LIBS SDL2::mixer)
+ list(APPEND EXTRA_LIBS SDL2_mixer::SDL2_mixer)
endif()
if(ENABLE_SDL2_NET)
- list(APPEND EXTRA_LIBS SDL2::net)
+ list(APPEND EXTRA_LIBS SDL2_net::SDL2_net)
endif()
if(SAMPLERATE_FOUND)
list(APPEND EXTRA_LIBS samplerate::samplerate)
@@ -225,10 +225,10 @@
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::SDL2main SDL2::SDL2 setup textscreen)
if(ENABLE_SDL2_MIXER)
- target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::mixer)
+ target_link_libraries("${PROGRAM_PREFIX}setup" SDL2_mixer::SDL2_mixer)
endif()
if(ENABLE_SDL2_NET)
- target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::net)
+ target_link_libraries("${PROGRAM_PREFIX}setup" SDL2_net::SDL2_net)
endif()
if(WIN32)
target_link_libraries("${PROGRAM_PREFIX}setup" winmm)
--- a/src/doom/CMakeLists.txt
+++ b/src/doom/CMakeLists.txt
@@ -70,8 +70,8 @@
target_include_directories(doom PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
target_link_libraries(doom SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(doom SDL2::mixer)
+ target_link_libraries(doom SDL2_mixer::SDL2_mixer)
endif()
if(ENABLE_SDL2_NET)
- target_link_libraries(doom SDL2::net)
+ target_link_libraries(doom SDL2_net::SDL2_net)
endif()
--- a/src/heretic/CMakeLists.txt
+++ b/src/heretic/CMakeLists.txt
@@ -56,8 +56,8 @@
target_include_directories(heretic PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
target_link_libraries(heretic textscreen SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(heretic SDL2::mixer)
+ target_link_libraries(heretic SDL2_mixer::SDL2_mixer)
endif()
if(ENABLE_SDL2_NET)
- target_link_libraries(heretic SDL2::net)
+ target_link_libraries(heretic SDL2_net::SDL2_net)
endif()
--- a/src/hexen/CMakeLists.txt
+++ b/src/hexen/CMakeLists.txt
@@ -58,8 +58,8 @@
target_include_directories(hexen PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
target_link_libraries(hexen SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(hexen SDL2::mixer)
+ target_link_libraries(hexen SDL2_mixer::SDL2_mixer)
endif()
if(ENABLE_SDL2_NET)
- target_link_libraries(hexen SDL2::net)
+ target_link_libraries(hexen SDL2_net::SDL2_net)
endif()
--- a/src/setup/CMakeLists.txt
+++ b/src/setup/CMakeLists.txt
@@ -17,5 +17,5 @@
target_include_directories(setup PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
target_link_libraries(setup textscreen SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(setup SDL2::mixer)
+ target_link_libraries(setup SDL2_mixer::SDL2_mixer)
endif()
--- a/src/strife/CMakeLists.txt
+++ b/src/strife/CMakeLists.txt
@@ -72,8 +72,8 @@
target_include_directories(strife PRIVATE "../" "../../win32/" "${CMAKE_CURRENT_BINARY_DIR}/../../")
target_link_libraries(strife textscreen SDL2::SDL2)
if(ENABLE_SDL2_MIXER)
- target_link_libraries(strife SDL2::mixer)
+ target_link_libraries(strife SDL2_mixer::SDL2_mixer)
endif()
if(ENABLE_SDL2_NET)
- target_link_libraries(strife SDL2::net)
+ target_link_libraries(strife SDL2_net::SDL2_net)
endif()
--- /dev/null
+++ b/vcpkg.json
@@ -1,0 +1,9 @@
+{
+ "dependencies": [
+ "sdl2",
+ "sdl2-mixer",
+ "sdl2-net",
+ "libpng",
+ "libsamplerate"
+ ]
+}