diff --git a/CMakeLists.txt b/CMakeLists.txt index e8ad7b6..c8465d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,34 @@ set(CMAKE_BUILD_TYPE Debug) include(lib/system/cmake/system.cmake) +# Build options + +# UBsan +set(WHOA_UB_SAN_HELP_TEXT, "Disable/Enable the Undefined Behavior Sanitizer. This is turned on by default in Debug build types. Has no effect when using MSVC.") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + option(WHOA_UB_SAN, WHOA_UB_SAN_HELP_TEXT, 1) +else() + option(WHOA_UB_SAN, WHOA_UB_SAN_HELP_TEXT, 0) +endif() +unset(WHOA_UB_SAN_HELP_TEXT) + +# GLSDL +if (WHOA_SYSTEM_WINDOWS) + # GLSDL can be disabled on Windows to save time + option(WHOA_BUILD_GLSDL "Disable/Enable compilation of the OpenGL/SDL2 graphics rendering device on Windows.", 0) +elseif(WHOA_SYSTEM_MAC) + # No need for this, we already have a functioning OpenGL rendering device (CGxDeviceGLL) + set(WHOA_BUILD_GLSDL 0) +else() + # Right now GLSDL is the only rendering device for Linux + set(WHOA_BUILD_GLSDL 1) +endif() + +# FMOD +option(WHOA_BUILD_FMOD, "Disable/Enable the use of the FMOD sound API. This introduces a dependency on a proprietary FMOD dynamically linked library.", 0) + # Compiler options -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # Some templates abuse offsetof set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof") diff --git a/src/gx/CMakeLists.txt b/src/gx/CMakeLists.txt index 93c88e0..b291df4 100644 --- a/src/gx/CMakeLists.txt +++ b/src/gx/CMakeLists.txt @@ -19,8 +19,8 @@ if(WHOA_SYSTEM_MAC) list(APPEND GX_SOURCES ${GLL_SOURCES}) endif() -# Build OpenGL/SDL graphics device on Windows and Linux -if(WHOA_SYSTEM_WIN OR WHOA_SYSTEM_LINUX) +# Build OpenGL/SDL graphics device if enabled +if(WHOA_BUILD_GLSDL) file(GLOB GLSDL_SOURCES "glsdl/*.cpp") list(APPEND GX_SOURCES ${GLSDL_SOURCES}) endif() @@ -53,8 +53,8 @@ if(WHOA_SYSTEM_WIN) ) endif() -# Link SDL3 and GLEW for Windows and Linux -if (WHOA_SYSTEM_WIN OR WHOA_SYSTEM_LINUX) +# Link SDL2 and GLEW for GLSDL +if (WHOA_BUILD_GLSDL) target_link_libraries(gx PRIVATE SDL2::SDL2-static diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 99f9b28..f0adf5e 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(freetype-2.0.9) add_subdirectory(lua-5.1.3) add_subdirectory(stormlib-9) -if(WHOA_SYSTEM_WIN OR WHOA_SYSTEM_LINUX) +if(WHOA_BUILD_GLSDL) set(SDL_SHARED OFF) set(SDL_STATIC ON) add_subdirectory(sdl-2.30.5) @@ -14,7 +14,7 @@ endif() # FMOD -if(DEFINED WHOA_BUILD_FMOD) +if(WHOA_BUILD_FMOD) add_library(fmod SHARED IMPORTED GLOBAL) # Determine which flavor of FMOD to use: # - macOS versions from 10.9 down prefer FMOD Ex @@ -36,7 +36,7 @@ if(DEFINED WHOA_BUILD_FMOD) if(WHOA_FMOD_EX) set(FMOD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fmodex-4.24.16") - else() + else() set(FMOD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fmodcore-2.02.18") endif()