mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-12-19 17:37:42 -05:00
Link SDL3 target & include directories properly, use SDL as a 3rd party
Introduce the USE_EXTERNAL_SDL option allowing the use of an external installation of SDL3, for example from the system's package manager. Also fix double find_package for plog
This commit is contained in:
1
BUILD.md
1
BUILD.md
@@ -196,4 +196,5 @@ cmake --preset linux -DENABLE_LOGGER=ON
|
||||
| `FORCE_COLORED_OUTPUT` | Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja). | `OFF` |
|
||||
| `FORCE_PORTABLE_INSTALL` | Install all files into local directory defined by `CMAKE_INSTALL_PREFIX`. | `ON` |
|
||||
| `USE_EXTERNAL_PLOG` | Use system plog library. | `OFF` |
|
||||
| `USE_EXTERNAL_SDL` | Use system SDL3 library. | `OFF` |
|
||||
| `USE_VCPKG` | Explicitly control whether or not to use vcpkg for dependency resolution. `ON` requires the environment variable `VCPKG_ROOT` to be set. | Determined by the existence of `VCPKG_ROOT` in the environment: If it exists, vcpkg is used. |
|
||||
|
||||
@@ -42,7 +42,8 @@ option(ENABLE_MEM_RTL "Enable Real-time library memory management functions (dis
|
||||
option(FATAL_GL_ERRORS "Check OpenGL calls and raise exceptions on errors." OFF)
|
||||
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja)." OFF)
|
||||
option(FORCE_PORTABLE_INSTALL "Install all files into local directory defined by CMAKE_INSTALL_PREFIX" ON)
|
||||
option(USE_EXTERNAL_PLOG "Use system plog library instead bundled" OFF)
|
||||
option(USE_EXTERNAL_PLOG "Use system plog library instead of bundled version" OFF)
|
||||
option(USE_EXTERNAL_SDL "Use system SDL3 library instead of bundled version" OFF)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
option(BUILD_EDITOR "Build internal editor" OFF)
|
||||
endif()
|
||||
@@ -171,11 +172,9 @@ endif()
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
message("Building for Linux")
|
||||
add_compile_definitions(POSIX __LINUX__ _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-linux.hog\")
|
||||
set(PLATFORM_INCLUDES "lib/linux" ${SDL3_INCLUDE_DIR} ${SDL3_INCLUDE_DIRS})
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
message("Building for MAC OSX")
|
||||
add_compile_definitions(POSIX MACOSX=1 _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-osx.hog\")
|
||||
set(PLATFORM_INCLUDES "lib/linux" ${SDL3_INCLUDE_DIR} ${SDL3_INCLUDE_DIRS})
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
# Windows.h defines to avoid as many issues as possible.
|
||||
add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX NODRAWTEXT NOBITMAP NOMCX NOSERVICE PRIMARY_HOG=\"d3-win.hog\"
|
||||
@@ -191,8 +190,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
|
||||
add_compile_definitions(WIN32 _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE)
|
||||
|
||||
set(PLATFORM_INCLUDES "lib/win/DirectX" "lib/win")
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_PREFIXES "")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
|
||||
|
||||
@@ -240,7 +237,6 @@ include_directories(
|
||||
"lib" # TODO: Remove after untying all modules
|
||||
"linux" # -*-
|
||||
"Descent3"
|
||||
${PLATFORM_INCLUDES}
|
||||
)
|
||||
|
||||
add_subdirectory(third_party)
|
||||
|
||||
@@ -343,7 +343,7 @@ target_link_libraries(Descent3 PRIVATE
|
||||
unzip
|
||||
vecmat
|
||||
${PLATFORM_LIBS})
|
||||
target_include_directories(Descent3 PRIVATE ${PROJECT_BINARY_DIR}/lib)
|
||||
target_include_directories(Descent3 PRIVATE ${PROJECT_BINARY_DIR}/lib ${SDL3_INCLUDE_DIRS})
|
||||
target_link_options(Descent3 PRIVATE $<$<PLATFORM_ID:Windows>:/DEBUG:FULL>)
|
||||
set_target_properties(Descent3 PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build")
|
||||
add_dependencies(Descent3
|
||||
|
||||
@@ -23,6 +23,7 @@ target_include_directories(ddebug PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/ddebug
|
||||
>
|
||||
PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h
|
||||
${SDL3_INCLUDE_DIRS}
|
||||
)
|
||||
target_link_libraries(ddebug PRIVATE
|
||||
$<$<PLATFORM_ID:Windows>:
|
||||
|
||||
@@ -37,6 +37,7 @@ target_include_directories(ddio PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/ddio
|
||||
>
|
||||
${SDL3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
@@ -574,6 +574,7 @@ target_include_directories(Descent3Editor PRIVATE
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/manage
|
||||
${PROJECT_BINARY_DIR}/lib
|
||||
{SDL3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_compile_definitions(Descent3Editor PUBLIC _AFXDLL EDITOR)
|
||||
|
||||
@@ -22,4 +22,5 @@ target_include_directories(libmve PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/libmve
|
||||
>
|
||||
${SDL3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
@@ -19,6 +19,7 @@ target_include_directories(linux PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/linux
|
||||
>
|
||||
${SDL3_INCLUDE_DIRS}
|
||||
)
|
||||
target_link_libraries(linux PRIVATE
|
||||
ddebug
|
||||
|
||||
@@ -22,7 +22,9 @@ target_link_libraries(Descent3_Online_TCP_IP PRIVATE
|
||||
module
|
||||
ui
|
||||
$<$<PLATFORM_ID:Windows>:ws2_32>
|
||||
SDL3::SDL3
|
||||
)
|
||||
target_include_directories(Descent3_Online_TCP_IP PRIVATE ${SDL3_INCLUDE_DIRS})
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_target_properties(Descent3_Online_TCP_IP PROPERTIES SUFFIX ".dylib")
|
||||
endif()
|
||||
|
||||
@@ -12,9 +12,13 @@ target_link_libraries(inetfile PRIVATE
|
||||
)
|
||||
target_link_libraries(inetfile PUBLIC
|
||||
httplib::httplib # For some reason, linking it privately causes issues at runtime
|
||||
SDL3::SDL3
|
||||
)
|
||||
target_include_directories(inetfile PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/netcon/inetfile
|
||||
>
|
||||
mem
|
||||
)
|
||||
target_include_directories(inetfile PRIVATE ${SDL3_INCLUDE_DIRS})
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ target_link_libraries(Direct_TCP_IP PRIVATE
|
||||
module
|
||||
ui
|
||||
$<$<PLATFORM_ID:Windows>:ws2_32>
|
||||
SDL3::SDL3
|
||||
)
|
||||
target_include_directories(Direct_TCP_IP PRIVATE ${SDL3_INCLUDE_DIRS})
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_target_properties(Direct_TCP_IP PROPERTIES SUFFIX ".dylib")
|
||||
endif()
|
||||
|
||||
@@ -24,7 +24,9 @@ target_link_libraries(Parallax_Online PRIVATE
|
||||
module
|
||||
ui
|
||||
$<$<PLATFORM_ID:Windows>:ws2_32>
|
||||
SDL3::SDL3
|
||||
)
|
||||
target_include_directories(Parallax_Online PRIVATE ${SDL3_INCLUDE_DIRS})
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_target_properties(Parallax_Online PROPERTIES SUFFIX ".dylib")
|
||||
endif()
|
||||
|
||||
@@ -35,3 +35,4 @@ target_link_libraries(dmfc PUBLIC
|
||||
physics
|
||||
ddio
|
||||
)
|
||||
target_include_directories(dmfc PRIVATE ${SDL3_INCLUDE_DIRS})
|
||||
@@ -31,7 +31,7 @@ set(CPPS
|
||||
)
|
||||
|
||||
add_library(renderer STATIC ${HEADERS} ${CPPS})
|
||||
target_include_directories(renderer PRIVATE ${GENERATED_HEADERS})
|
||||
target_include_directories(renderer PRIVATE ${GENERATED_HEADERS} ${SDL3_INCLUDE_DIRS})
|
||||
target_link_libraries(renderer PRIVATE
|
||||
glm::glm
|
||||
SDL3::SDL3
|
||||
|
||||
@@ -32,4 +32,5 @@ target_include_directories(sndlib PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/sndlib
|
||||
>
|
||||
${SDL3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
14
third_party/CMakeLists.txt
vendored
14
third_party/CMakeLists.txt
vendored
@@ -3,12 +3,18 @@ set(CMAKE_FOLDER "third_party")
|
||||
add_subdirectory(libacm)
|
||||
add_subdirectory(stb)
|
||||
|
||||
if(USE_EXTERNAL_PLOG)
|
||||
find_package(plog REQUIRED)
|
||||
else()
|
||||
if(NOT USE_EXTERNAL_PLOG)
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plog/CMakeLists.txt)
|
||||
message(FATAL_ERROR "plog third-party directory could not be found. "
|
||||
"Please run 'submodule update --init --recursive' in the source directory.")
|
||||
"Please run 'git submodule update --init --recursive' in the source directory.")
|
||||
endif()
|
||||
add_subdirectory(plog)
|
||||
endif()
|
||||
|
||||
if (NOT USE_EXTERNAL_SDL)
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SDL/CMakeLists.txt)
|
||||
message(FATAL_ERROR "SDL third-party directory could not be found. "
|
||||
"Please run 'git submodule update --init --recursive' in the source directory.")
|
||||
endif()
|
||||
add_subdirectory(SDL)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user