commit 825f59bb89733078b572cd8557ab7e4001f2e9f6
Author: Roman Fomin <rfomin@gmail.com>
AuthorDate: Thu Jan 26 20:59:31 2023 +0700
Commit: GitHub <noreply@github.com>
CommitDate: Thu Jan 26 14:59:31 2023 +0100
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.
---
CMakeLists.txt | 3 +++
cmake/FindSDL2_mixer.cmake | 4 ++--
cmake/FindSDL2_net.cmake | 4 ++--
opl/CMakeLists.txt | 2 +-
pcsound/CMakeLists.txt | 2 +-
src/CMakeLists.txt | 10 +++++-----
src/doom/CMakeLists.txt | 4 ++--
src/heretic/CMakeLists.txt | 4 ++--
src/hexen/CMakeLists.txt | 4 ++--
src/setup/CMakeLists.txt | 2 +-
src/strife/CMakeLists.txt | 4 ++--
vcpkg.json | 9 +++++++++
12 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12da2fa2..1a7bb6ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,9 @@ else()
"-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)
diff --git a/cmake/FindSDL2_mixer.cmake b/cmake/FindSDL2_mixer.cmake
index 3e5218ce..3328c6c3 100644
--- a/cmake/FindSDL2_mixer.cmake
+++ b/cmake/FindSDL2_mixer.cmake
@@ -79,8 +79,8 @@ find_package_handle_standard_args(SDL2_mixer
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
diff --git a/cmake/FindSDL2_net.cmake b/cmake/FindSDL2_net.cmake
index 2b1e29d1..96b6cd72 100644
--- a/cmake/FindSDL2_net.cmake
+++ b/cmake/FindSDL2_net.cmake
@@ -79,8 +79,8 @@ find_package_handle_standard_args(SDL2_net
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
diff --git a/opl/CMakeLists.txt b/opl/CMakeLists.txt
index 751ff71a..b9cc2dd8 100644
--- a/opl/CMakeLists.txt
+++ b/opl/CMakeLists.txt
@@ -14,5 +14,5 @@ target_include_directories(opl
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()
diff --git a/pcsound/CMakeLists.txt b/pcsound/CMakeLists.txt
index 4e989a4a..f9eb1f2e 100644
--- a/pcsound/CMakeLists.txt
+++ b/pcsound/CMakeLists.txt
@@ -10,5 +10,5 @@ target_include_directories(pcsound
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()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b1035482..69d3993e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -34,7 +34,7 @@ target_include_directories("${PROGRAM_PREFIX}server"
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(SOURCE_FILES_WITH_DEH ${SOURCE_FILES} ${DEHACKED_SOURCE_FILES})
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 @@ target_include_directories("${PROGRAM_PREFIX}setup"
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)
diff --git a/src/doom/CMakeLists.txt b/src/doom/CMakeLists.txt
index e89325d1..36db89da 100644
--- a/src/doom/CMakeLists.txt
+++ b/src/doom/CMakeLists.txt
@@ -70,8 +70,8 @@ add_library(doom STATIC
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()
diff --git a/src/heretic/CMakeLists.txt b/src/heretic/CMakeLists.txt
index a9c8e0e9..ea39c44d 100644
--- a/src/heretic/CMakeLists.txt
+++ b/src/heretic/CMakeLists.txt
@@ -56,8 +56,8 @@ add_library(heretic STATIC
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()
diff --git a/src/hexen/CMakeLists.txt b/src/hexen/CMakeLists.txt
index eba8c5e3..fe963224 100644
--- a/src/hexen/CMakeLists.txt
+++ b/src/hexen/CMakeLists.txt
@@ -58,8 +58,8 @@ add_library(hexen STATIC
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()
diff --git a/src/setup/CMakeLists.txt b/src/setup/CMakeLists.txt
index 1117c78b..fa7390c2 100644
--- a/src/setup/CMakeLists.txt
+++ b/src/setup/CMakeLists.txt
@@ -17,5 +17,5 @@ add_library(setup STATIC
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()
diff --git a/src/strife/CMakeLists.txt b/src/strife/CMakeLists.txt
index 8784828b..58d74dad 100644
--- a/src/strife/CMakeLists.txt
+++ b/src/strife/CMakeLists.txt
@@ -72,8 +72,8 @@ add_library(strife STATIC ${STRIFE_SOURCES})
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()
diff --git a/vcpkg.json b/vcpkg.json
new file mode 100644
index 00000000..bfdbda6e
--- /dev/null
+++ b/vcpkg.json
@@ -0,0 +1,9 @@
+{
+ "dependencies": [
+ "sdl2",
+ "sdl2-mixer",
+ "sdl2-net",
+ "libpng",
+ "libsamplerate"
+ ]
+}