From e2871abdde5f61ffe8bc24e0706d7fc777d61e85 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 17 Apr 2024 21:44:44 +0200 Subject: [PATCH 1/5] Provide 'OpenAL' target when using USE_SYSTEM_OPENAL --- extern/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 49fcf137f..8a0152bdf 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -106,6 +106,11 @@ target_include_directories(tinyobjloader INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/t if (IS_64_BIT) if (USE_SYSTEM_OPENAL) find_package(OpenAL REQUIRED) + + # Provide "OpenAL" target with result of CMake's detection + add_library(OpenAL INTERFACE IMPORTED GLOBAL) + target_link_libraries(OpenAL INTERFACE ${OPENAL_LIBRARY}) + target_include_directories(OpenAL INTERFACE ${OPENAL_INCLUDE_DIR}) else() set(LIBTYPE STATIC) option(FORCE_STATIC_VCRT "" ON) From c6e09b518a745417ea4b933cdfa3eb316609e709 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 17 Apr 2024 21:47:01 +0200 Subject: [PATCH 2/5] Move AL_LIBTYPE_STATIC definition to extern/ --- extern/CMakeLists.txt | 1 + src/CMakeLists.txt | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 8a0152bdf..d6f6093f9 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -127,5 +127,6 @@ if (IS_64_BIT) set_target_properties(OpenAL PROPERTIES FOLDER extern/openal-soft) set_target_properties(common PROPERTIES FOLDER extern/openal-soft) set_target_properties(ex-common PROPERTIES FOLDER extern/openal-soft) + target_compile_definitions(OpenAL PUBLIC AL_LIBTYPE_STATIC) endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5e170b075..2b7cf7c80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -380,10 +380,6 @@ ADD_DEFINITIONS(-DVERSION_SHA=${Q2RTX_VERSION_SHA}) ADD_DEFINITIONS(-DVERSION_BRANCH=${Q2RTX_VERSION_BRANCH}) ADD_DEFINITIONS(-DHAVE_CONFIG_H=1) -IF (NOT USE_SYSTEM_OPENAL) - ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC) -ENDIF() - IF(WIN32) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) ENDIF() From 6c871eec2cb431b69cfdf9cf78253338efd681b7 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 17 Apr 2024 22:04:49 +0200 Subject: [PATCH 3/5] Always provide a 'libcurl' target --- extern/CMakeLists.txt | 2 ++ src/CMakeLists.txt | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index d6f6093f9..e8edea14a 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -66,6 +66,8 @@ endif() if(CONFIG_USE_CURL) if(USE_SYSTEM_CURL) find_package(CURL REQUIRED) + add_library(libcurl INTERFACE IMPORTED GLOBAL) + target_link_libraries(libcurl INTERFACE CURL::libcurl) else() option(BUILD_CURL_EXE "" OFF) option(BUILD_SHARED_LIBS "" OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b7cf7c80..fa5e85eeb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -473,14 +473,9 @@ IF (TARGET client) TARGET_COMPILE_DEFINITIONS(client PRIVATE USE_CLIENT=1 USE_SAVEGAMES=1 USE_FIXED_LIBAL=1 USE_SDL=1) IF(CONFIG_USE_CURL) - IF(USE_SYSTEM_CURL) - TARGET_LINK_LIBRARIES(client curl) - ELSE() - ADD_DEFINITIONS(-DCURL_STATICLIB) - TARGET_SOURCES(client PRIVATE ${SRC_CLIENT_HTTP}) - TARGET_COMPILE_DEFINITIONS(client PRIVATE USE_CURL=1) - TARGET_LINK_LIBRARIES(client libcurl) - ENDIF() + TARGET_LINK_LIBRARIES(client libcurl) + TARGET_SOURCES(client PRIVATE ${SRC_CLIENT_HTTP}) + TARGET_COMPILE_DEFINITIONS(client PRIVATE USE_CURL=1) ENDIF() add_dependencies(client shaders) From 74467db24e5254bddedb2ce95ac0c427b9ea588d Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 17 Apr 2024 22:09:29 +0200 Subject: [PATCH 4/5] Always provide a target 'z' for zlib --- extern/CMakeLists.txt | 7 +++++++ src/CMakeLists.txt | 23 ++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index e8edea14a..cb003b530 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -5,6 +5,9 @@ if(USE_SYSTEM_ZLIB) find_package(ZLIB REQUIRED) + + add_library(z INTERFACE IMPORTED GLOBAL) + target_link_libraries(z INTERFACE ZLIB::ZLIB) else() add_subdirectory(zlib) target_include_directories(zlibstatic PUBLIC $ $) @@ -13,6 +16,10 @@ else() set_target_properties(zlibstatic PROPERTIES FOLDER extern POSITION_INDEPENDENT_CODE ON) set_target_properties(minigzip PROPERTIES FOLDER extern) set_target_properties(example PROPERTIES FOLDER extern) + + add_library(z INTERFACE IMPORTED GLOBAL) + target_link_libraries(z INTERFACE zlibstatic) + target_include_directories(z INTERFACE "${ZLIB_INCLUDE_DIRS}") endif() # diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa5e85eeb..feaa33d7a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -549,9 +549,6 @@ TARGET_INCLUDE_DIRECTORIES(game PRIVATE ../inc) IF(TARGET client) TARGET_INCLUDE_DIRECTORIES(client PRIVATE ../inc) - IF(NOT USE_SYSTEM_ZLIB) - TARGET_INCLUDE_DIRECTORIES(client PRIVATE "${ZLIB_INCLUDE_DIRS}") - ENDIF() ENDIF() TARGET_INCLUDE_DIRECTORIES(server PRIVATE ../inc) @@ -564,22 +561,10 @@ if(TARGET client) endif() endif() -if(NOT USE_SYSTEM_ZLIB) - TARGET_INCLUDE_DIRECTORIES(server PRIVATE "${ZLIB_INCLUDE_DIRS}") -endif() - -if(USE_SYSTEM_ZLIB) - TARGET_LINK_LIBRARIES(server z) - TARGET_LINK_LIBRARIES(game z) - if(TARGET client) - TARGET_LINK_LIBRARIES(client z) - endif() -else() - TARGET_LINK_LIBRARIES(server zlibstatic) - TARGET_LINK_LIBRARIES(game zlibstatic) - if(TARGET client) - TARGET_LINK_LIBRARIES(client zlibstatic) - endif() +TARGET_LINK_LIBRARIES(server z) +TARGET_LINK_LIBRARIES(game z) +if(TARGET client) + TARGET_LINK_LIBRARIES(client z) endif() IF(UNIX) From cc2eaefd4ce6055645c41a69806bf63ab1f64b98 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 17 Apr 2024 22:16:01 +0200 Subject: [PATCH 5/5] Always provide a target 'SDL2' --- extern/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index cb003b530..80087345f 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -48,7 +48,10 @@ endif() if (IS_64_BIT) if (USE_SYSTEM_SDL2) find_package(SDL2 REQUIRED) - else() + + add_library(SDL2 INTERFACE IMPORTED GLOBAL) + target_link_libraries(SDL2 INTERFACE SDL2::SDL2) + else() option(SDL_SHARED "" OFF) option(SDL_STATIC "" ON) option(SDL_SHARED_ENABLED_BY_DEFAULT OFF) @@ -64,7 +67,10 @@ if (IS_64_BIT) set_target_properties(SDL2-static PROPERTIES FOLDER extern) set_target_properties(uninstall PROPERTIES FOLDER extern) set_target_properties(sdl_headers_copy PROPERTIES FOLDER extern) - endif() + + add_library(SDL2 INTERFACE IMPORTED GLOBAL) + target_link_libraries(SDL2 INTERFACE SDL2main SDL2-static) + endif() endif() #