3a8b2efd-8df2-4277-9336-5d97408d6574
This commit is contained in:
113
CMakeLists.txt
Normal file
113
CMakeLists.txt
Normal file
@@ -0,0 +1,113 @@
|
||||
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)
|
||||
|
||||
# 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 PokemonSimTargets
|
||||
FILE PokemonSimTargets.cmake
|
||||
NAMESPACE PokemonSim::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokemonSim
|
||||
)
|
||||
|
||||
# Generate and install config files
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
write_basic_package_version_file(
|
||||
PokemonSimConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
configure_package_config_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/PokemonSimConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PokemonSimConfig.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokemonSim
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PokemonSimConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PokemonSimConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PokemonSim
|
||||
)
|
||||
|
||||
# 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)
|
||||
Reference in New Issue
Block a user