Files
yaze/cmake/utils.cmake
scawful f54949bdd8 feat(build-system): enhance CMake configuration and introduce new utility files
- Refactored CMakeLists.txt to streamline project configuration and improve readability.
- Introduced new utility functions in `utils.cmake` for setting compiler flags and managing dependencies.
- Added `dependencies.cmake` to centralize third-party dependency management, enhancing modularity.
- Updated CI workflows to include new build options and improved logging for better feedback during configuration.
- Implemented precompiled headers in various libraries to speed up compilation times.

Benefits:
- Improved maintainability and clarity of the build system.
- Enhanced build performance through precompiled headers.
- Streamlined dependency management for easier integration of third-party libraries.
2025-10-11 02:44:17 -04:00

71 lines
2.3 KiB
CMake

# This file contains utility functions for the yaze build system.
# ============================================================================
# yaze_add_compiler_flags
#
# Sets standard compiler flags for C++ and C.
# Also handles platform-specific and compiler-specific flags.
# ============================================================================
function(yaze_add_compiler_flags)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
if(YAZE_SUPPRESS_WARNINGS)
if(MSVC)
add_compile_options(/w)
else()
add_compile_options(-w)
endif()
message(STATUS "✓ Warnings suppressed (use -v preset suffix for verbose builds)")
else()
message(STATUS "○ Verbose warnings enabled")
endif()
# Common interface target for shared settings
add_library(yaze_common INTERFACE)
target_compile_features(yaze_common INTERFACE cxx_std_23)
# Platform-specific definitions
if(YAZE_PLATFORM_LINUX)
target_compile_definitions(yaze_common INTERFACE linux stricmp=strcasecmp)
elseif(YAZE_PLATFORM_MACOS)
target_compile_definitions(yaze_common INTERFACE MACOS)
elseif(YAZE_PLATFORM_WINDOWS)
target_compile_definitions(yaze_common INTERFACE WINDOWS)
endif()
# Compiler-specific settings
if(MSVC)
target_compile_options(yaze_common INTERFACE
/EHsc
/W4 /permissive-
/bigobj
/utf-8
)
target_compile_definitions(yaze_common INTERFACE
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_WARNINGS
SILENCE_CXX23_DEPRECATIONS
_SILENCE_CXX23_DEPRECATION_WARNING
_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
NOMINMAX
WIN32_LEAN_AND_MEAN
strncasecmp=_strnicmp
strcasecmp=_stricmp
)
else()
target_compile_options(yaze_common INTERFACE
-Wall -Wextra -Wpedantic
-Wno-deprecated-declarations
-Wno-c++23-compat
)
target_compile_definitions(yaze_common INTERFACE
_SILENCE_CXX23_DEPRECATION_WARNING
_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
)
endif()
endfunction()