120 lines
3.2 KiB
CMake
120 lines
3.2 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
|
|
# Project definition
|
|
project(PokemonBattleSimulator
|
|
VERSION 0.1.0
|
|
DESCRIPTION "High-performance Pokemon battle simulator for Generation 1"
|
|
LANGUAGES CXX
|
|
)
|
|
|
|
# Set C++ standard
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
# Add custom CMake modules
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
|
|
|
# Build options
|
|
option(BUILD_TESTS "Build unit tests" ON)
|
|
option(BUILD_BENCHMARKS "Build performance benchmarks" OFF)
|
|
option(BUILD_EXAMPLES "Build example programs" ON)
|
|
option(ENABLE_SANITIZERS "Enable runtime sanitizers" OFF)
|
|
option(ENABLE_STATIC_ANALYSIS "Run static analysis tools" OFF)
|
|
option(ENABLE_COVERAGE "Generate code coverage reports" OFF)
|
|
|
|
# Include custom CMake modules
|
|
include(CompilerWarnings)
|
|
include(StaticAnalysis)
|
|
|
|
# Set default build type
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
# Configure compiler warnings
|
|
set_project_warnings()
|
|
|
|
# Enable static analysis if requested
|
|
if(ENABLE_STATIC_ANALYSIS)
|
|
enable_static_analysis()
|
|
endif()
|
|
|
|
# Find dependencies
|
|
find_package(Threads REQUIRED)
|
|
|
|
# Configure RapidJSON (header-only library)
|
|
set(RAPIDJSON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/rapidjson")
|
|
if(NOT EXISTS "${RAPIDJSON_INCLUDE_DIR}/rapidjson.h")
|
|
message(FATAL_ERROR "RapidJSON not found at ${RAPIDJSON_INCLUDE_DIR}. Please ensure rapidjson is properly installed in the thirdParty directory.")
|
|
endif()
|
|
|
|
# Add subdirectories
|
|
add_subdirectory(src)
|
|
|
|
# Conditionally build tests
|
|
if(BUILD_TESTS)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
# Conditionally build benchmarks
|
|
if(BUILD_BENCHMARKS)
|
|
add_subdirectory(benchmarks)
|
|
endif()
|
|
|
|
# Conditionally build examples
|
|
if(BUILD_EXAMPLES)
|
|
add_subdirectory(examples)
|
|
endif()
|
|
|
|
# Installation configuration
|
|
include(GNUInstallDirs)
|
|
|
|
# Install headers
|
|
install(DIRECTORY include/
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
|
|
)
|
|
|
|
# Export targets
|
|
install(EXPORT PokEngTargets
|
|
FILE PokEngTargets.cmake
|
|
NAMESPACE PokEng::
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokEng
|
|
)
|
|
|
|
# Generate and install config files
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
write_basic_package_version_file(
|
|
PokEngConfigVersion.cmake
|
|
VERSION ${PROJECT_VERSION}
|
|
COMPATIBILITY SameMajorVersion
|
|
)
|
|
|
|
configure_package_config_file(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/PokEngConfig.cmake.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/PokEngConfig.cmake
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokEng
|
|
)
|
|
|
|
install(FILES
|
|
${CMAKE_CURRENT_BINARY_DIR}/PokEngConfig.cmake
|
|
${CMAKE_CURRENT_BINARY_DIR}/PokEngConfigVersion.cmake
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokEng
|
|
)
|
|
|
|
# CPack configuration for packaging
|
|
include(cmake/packaging/DEB.cmake)
|
|
include(cmake/packaging/RPM.cmake)
|
|
|
|
set(CPACK_PACKAGE_NAME "pokemon-battle-simulator")
|
|
set(CPACK_PACKAGE_VENDOR "Pokemon Sim Team")
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "High-performance Pokemon battle simulator")
|
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
|
|
include(CPack)
|