openmohaa/CMakeLists.txt

179 lines
5.5 KiB
Text
Raw Normal View History

cmake_minimum_required(VERSION 3.5)
2023-05-18 20:24:09 +02:00
project(openmohaa)
2023-02-01 00:29:02 +01:00
include(TargetArch.cmake)
target_architecture(TARGET_ARCH)
set(USE_INTERNAL_LIBS ON)
if(USE_SYSTEM_LIBS)
set(USE_INTERNAL_LIBS OFF)
endif()
option(USE_INTERNAL_JPEG "If set, use bundled libjpeg." ${USE_INTERNAL_LIBS})
option(USE_INTERNAL_MAD "If set, use bundled libmad." ${USE_INTERNAL_LIBS})
option(USE_INTERNAL_ZLIB "If set, use bundled zlib." ${USE_INTERNAL_LIBS})
2023-07-02 20:06:15 +02:00
2023-01-30 18:39:52 +01:00
if(TARGET_GAME_TYPE)
2023-07-02 20:06:15 +02:00
message(SEND_ERROR "TARGET_GAME_TYPE is now unsupported, it is now done at runtime.")
2023-01-30 18:39:52 +01:00
endif()
2023-07-02 20:06:15 +02:00
set(TARGET_BASE_GAME "./")
set(CMAKE_DEBUG_POSTFIX "-dbg")
2023-01-30 18:39:52 +01:00
#
# Microsoft compiler specific parameters
#
2023-01-30 18:39:52 +01:00
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
# Treat no return type as error
add_compile_options(/we4715)
endif()
#
# Clang and GCC specific parameters
#
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
2023-02-01 00:29:02 +01:00
add_compile_options(-Wno-comment)
# Treat no return type as error
add_compile_options(-Werror=return-type)
# Don't export symbols, there are some OSes that can resolve symbols
# globally
add_compile_options(-fvisibility=hidden)
endif()
#
# Clang specific parameters
#
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
2023-02-01 00:29:02 +01:00
# Ignore warnings for code like 'assert("Assert string")'
add_compile_options(-Wno-pointer-bool-conversion)
2023-01-30 18:39:52 +01:00
endif()
#
# GCC specific parameters
#
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Add this option on gcc to prevent functions from having the STB_GNU_UNIQUE binding
# Otherwise, it would prevent libraries from being unloaded
# which will cause undefined behavior and crashes due to memory corruption
add_compile_options(-fno-gnu-unique)
endif()
if(DEBUG_MEMORY)
add_definitions(-D_DEBUG_MEM)
endif()
2023-05-24 01:07:45 +02:00
IF("${TARGET_ARCH}" STREQUAL "i386")
2023-02-01 22:45:04 +01:00
set(TARGET_ARCH_SUFFIX "x86")
ELSE()
set(TARGET_ARCH_SUFFIX ${TARGET_ARCH})
ENDIF()
set(TARGET_BIN_SUFFIX ".${TARGET_ARCH}")
2023-07-02 20:06:15 +02:00
message(STATUS "Architecture detected: ${TARGET_ARCH}, suffix set to ${TARGET_ARCH_SUFFIX}.")
2023-02-01 00:29:02 +01:00
IF(WIN32)
set(TARGET_PLATFORM_PREFIX "")
message(STATUS "Using Win32 naming convention")
ELSEIF(UNIX)
2023-02-01 22:45:04 +01:00
set(TARGET_PLATFORM_PREFIX "")
2023-02-01 00:29:02 +01:00
message(STATUS "Using Unix naming convention")
ELSE()
set(TARGET_PLATFORM_PREFIX "")
ENDIF()
2023-02-05 14:15:24 +01:00
IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG)
2023-08-26 20:22:39 +02:00
# NOTE: The following may mess up function importation
2023-05-29 01:49:10 +02:00
#if(UNIX)
# # Enable all exports so all functions name can be seen during executable crash
# set(CMAKE_ENABLE_EXPORTS ON)
# message(STATUS "Enabling exports on Unix for backtrace")
#endif()
2023-02-05 14:15:24 +01:00
ENDIF()
2024-10-09 19:24:34 +02:00
if(APPLE)
# macOS doesn't search the executable path by default
# so, locate libraries like SDL in the executable path
set(CMAKE_INSTALL_RPATH "@executable_path")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()
# Common stuff
2023-06-17 01:44:38 +02:00
add_subdirectory("code/qcommon")
add_subdirectory("code/gamespy")
2023-06-17 01:44:38 +02:00
# Application
2023-06-17 01:44:38 +02:00
add_subdirectory("code/sys")
2023-04-30 20:37:50 +02:00
2023-06-17 01:44:38 +02:00
## Server app
add_subdirectory("code/server")
2023-01-30 18:39:52 +01:00
2023-06-17 01:44:38 +02:00
add_executable(omohaaded "code/null/null_client.c" "code/null/null_input.c" "code/null/null_snddma.c")
target_compile_definitions(omohaaded PRIVATE APP_MODULE DEDICATED)
target_compile_features(omohaaded PUBLIC cxx_nullptr)
target_compile_features(omohaaded PUBLIC c_variadic_macros)
2023-06-17 01:44:38 +02:00
target_link_libraries(omohaaded PRIVATE omohserver)
target_link_libraries(omohaaded PRIVATE syslib)
target_link_libraries(omohaaded PRIVATE qcommon qcommon_standalone)
2023-08-26 20:22:39 +02:00
# Gamespy dependency
2023-06-17 01:44:38 +02:00
target_include_directories(omohaaded PUBLIC "code/qcommon" "code/script" "code/gamespy" "code/server")
set_target_properties(omohaaded PROPERTIES OUTPUT_NAME "omohaaded${TARGET_BIN_SUFFIX}")
set_target_properties(omohaaded PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
if (MSVC)
target_link_options(omohaaded PRIVATE "/MANIFEST:NO")
INSTALL(FILES $<TARGET_PDB_FILE:omohaaded> DESTINATION "./" OPTIONAL)
endif()
2023-02-01 22:45:04 +01:00
INSTALL(TARGETS omohaaded DESTINATION "./")
2023-08-14 13:31:42 +02:00
if (NOT BUILD_NO_CLIENT)
2023-06-17 01:44:38 +02:00
## Client app
2024-08-21 18:35:06 +02:00
add_subdirectory("code/client")
2023-06-17 01:44:38 +02:00
add_subdirectory("code/renderer")
add_subdirectory("code/sdl")
#include("code/renderergl2/glsl/shaders.cmake")
#file(GLOB_RECURSE SOURCES_RENDERER "code/sdl/*.c" "code/renderercommon/*.c" "code/renderergl2/*.c" "code/renderergl2/*.cpp")
#list(FILTER SOURCES_RENDERER EXCLUDE REGEX "code/renderergl2/tr_subs.c")
#list(FILTER SOURCES_RENDERER EXCLUDE REGEX "code/renderergl2/tr_model.c")
add_executable(openmohaa "misc/dummy.c")
2023-06-17 01:44:38 +02:00
target_link_libraries(openmohaa PRIVATE syslib)
target_link_libraries(openmohaa PRIVATE omohserver)
target_link_libraries(openmohaa PRIVATE omohclient)
target_link_libraries(openmohaa PRIVATE omohrenderer omohsdl)
target_link_libraries(openmohaa PRIVATE qcommon qcommon_standalone)
2023-05-29 19:03:56 +02:00
### Gamespy dependency
target_include_directories(openmohaa PUBLIC "code/qcommon" "code/script" "code/gamespy" "code/server" "code/client" "code/uilib")
set_target_properties(openmohaa PROPERTIES OUTPUT_NAME "openmohaa${TARGET_BIN_SUFFIX}")
set_target_properties(openmohaa PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
2023-05-29 19:03:56 +02:00
if(USE_INTERNAL_JPEG)
target_include_directories(openmohaa PUBLIC "code/jpeg-8c")
target_link_libraries(openmohaa PRIVATE jpeg8)
else()
find_package(JPEG REQUIRED)
target_include_directories(openmohaa PUBLIC ${JPEG_INCLUDE_DIRS})
target_link_libraries(openmohaa PRIVATE ${JPEG_LIBRARIES})
endif()
2023-05-28 20:59:55 +02:00
if (MSVC)
target_link_options(openmohaa PRIVATE "/MANIFEST:NO")
2023-05-18 19:56:46 +02:00
INSTALL(FILES $<TARGET_PDB_FILE:openmohaa> DESTINATION "./" OPTIONAL)
2023-05-08 23:36:41 +02:00
endif()
INSTALL(TARGETS openmohaa DESTINATION "./")
endif()