cmake_minimum_required(VERSION 3.20) project(Warfactory LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() # Load Warfactory modules include(cmake/WarfactoryDefenses.cmake) include(cmake/WarfactoryAutomation.cmake) # ============================================================================= # MULTIPLE BUILD CONFIGURATIONS # ============================================================================= # Debug avec sanitizers complets set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DDEBUG") # Release optimisé set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DRELEASE") # Testing avec coverage set(CMAKE_CXX_FLAGS_TESTING "-O0 -g --coverage -DTESTING") # Profiling pour performance analysis set(CMAKE_CXX_FLAGS_PROFILING "-O2 -g -pg -DPROFILING") # Available configurations set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Testing;Profiling" CACHE STRING "Build configurations" FORCE) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose build type" FORCE) endif() message(STATUS "🔧 Build configuration: ${CMAKE_BUILD_TYPE}") # Global include directories include_directories(include) # Output directories set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # Add subdirectories for all engines add_subdirectory(engines/Designer-Engine) add_subdirectory(engines/Economy-Engine) add_subdirectory(engines/Event-Engine) add_subdirectory(engines/Factory-Engine) add_subdirectory(engines/Intelligence-Engine) add_subdirectory(engines/Logistic-Engine) add_subdirectory(engines/MacroEntity-Engine) add_subdirectory(engines/Map-Engine) add_subdirectory(engines/Operation-Engine) add_subdirectory(engines/War-Engine) # Build all engines target add_custom_target(all-engines DEPENDS designer-engine economy-engine event-engine factory-engine intelligence-engine logistic-engine macroentity-engine map-engine operation-engine war-engine COMMENT "Building all Warfactory engines" ) # ============================================================================= # ADVANCED TESTING TARGETS # ============================================================================= if(ENABLE_ADVANCED_TOOLS) # Fuzzing targets for all engines add_custom_target(fuzz-all-engines COMMENT "Running fuzzing on all engines" ) # Static analysis for all engines add_custom_target(analyze-all-engines COMMENT "Running static analysis on all engines" ) # Coverage for all engines add_custom_target(coverage-all-engines COMMENT "Generating coverage reports for all engines" ) # Concurrency analysis for all engines add_custom_target(concurrency-all-engines COMMENT "Running concurrency analysis on all engines" ) # ABI validation for all engines add_custom_target(abi-all-engines COMMENT "Validating ABI for all engines" ) # Master testing target add_custom_target(test-everything DEPENDS fuzz-all-engines analyze-all-engines coverage-all-engines COMMENT "Run all advanced testing on all engines" ) message(STATUS "🎯 Advanced testing targets configured") message(STATUS " - Use 'make fuzz-all-engines' for fuzzing") message(STATUS " - Use 'make analyze-all-engines' for static analysis") message(STATUS " - Use 'make test-everything' for complete testing") endif() # ============================================================================= # AUTOMATION TARGETS POUR CLAUDE CODE # ============================================================================= # Validation complète du code add_custom_target(validate-all COMMAND echo "🔍 Running comprehensive code validation..." COMMENT "Running all validation tools" ) # Static analysis sur tout le projet if(TARGET cppcheck) add_custom_target(cppcheck-all COMMAND cppcheck --enable=all --inconclusive --std=c++20 --suppressions-list=${CMAKE_SOURCE_DIR}/cppcheck-suppressions.txt ${CMAKE_SOURCE_DIR}/engines/*/src ${CMAKE_SOURCE_DIR}/engines/*/include COMMENT "Running Cppcheck on all engines" ) add_dependencies(validate-all cppcheck-all) endif() # clang-tidy sur tout le projet find_program(CLANG_TIDY_EXECUTABLE clang-tidy) if(CLANG_TIDY_EXECUTABLE) add_custom_target(clang-tidy-all COMMAND find ${CMAKE_SOURCE_DIR}/engines -name "*.cpp" -exec ${CLANG_TIDY_EXECUTABLE} {} + COMMENT "Running clang-tidy on all engines" ) add_dependencies(validate-all clang-tidy-all) endif() # Build rapide tous les engines add_custom_target(build-all-fast DEPENDS all-engines COMMENT "Fast build of all engines" ) # Clean + rebuild complet add_custom_target(rebuild-all COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all-engines COMMENT "Clean rebuild of all engines" ) # Documentation de tous les engines add_custom_target(docs-all COMMENT "Generating documentation for all engines" ) # Tests de tous les engines add_custom_target(test-all-engines COMMAND ${CMAKE_CTEST_COMMAND} --parallel 4 --output-on-failure COMMENT "Running tests for all engines" ) # Performance benchmarks add_custom_target(bench-all-engines COMMENT "Running benchmarks for all engines" ) # Claude Code workflow target - build + test + validate add_custom_target(claude-workflow DEPENDS build-all-fast validate-all test-all-engines COMMENT "Complete Claude Code development workflow" ) # Builds rotatifs pour tous les engines en mode Debug if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_custom_target(rotary-builds-all DEPENDS economy-engine_test_rotary war-engine_test_rotary designer-engine_test_rotary factory-engine_test_rotary intelligence-engine_test_rotary logistic-engine_test_rotary macroentity-engine_test_rotary map-engine_test_rotary operation-engine_test_rotary event-engine_test_rotary COMMENT "Build all sanitizer variants for all engines" ) add_custom_target(rotary-tests-all DEPENDS economy-engine_run_rotary war-engine_run_rotary designer-engine_run_rotary factory-engine_run_rotary intelligence-engine_run_rotary logistic-engine_run_rotary macroentity-engine_run_rotary map-engine_run_rotary operation-engine_run_rotary event-engine_run_rotary COMMENT "Run rotary sanitizer testing for all engines" ) # Claude workflow étendu avec sanitizers rotatifs add_custom_target(claude-workflow-rotary DEPENDS claude-workflow rotary-builds-all COMMENT "Complete Claude workflow with rotary sanitizer builds" ) message(STATUS "🔄 Rotary sanitizer targets configured:") message(STATUS " - make rotary-builds-all : Build all sanitizer variants") message(STATUS " - make rotary-tests-all : Run all sanitizer tests") message(STATUS " - make claude-workflow-rotary : Full workflow + rotary") endif() # CI/CD simulation add_custom_target(ci-simulation DEPENDS rebuild-all validate-all test-all-engines docs-all COMMENT "Simulate CI/CD pipeline" ) # Build workflow adaptatif selon FAST_BUILD if(FAST_BUILD) add_custom_target(claude-workflow-fast DEPENDS build-all-fast COMMENT "Fast Claude Code development workflow (daily iteration)" ) message(STATUS "🤖 Fast build targets configured:") message(STATUS " - make build-all-fast : Quick build all engines") message(STATUS " - make claude-workflow-fast : Fast Claude development cycle") else() message(STATUS "🤖 Full automation targets configured:") message(STATUS " - make validate-all : Comprehensive validation") message(STATUS " - make build-all-fast : Quick build all engines") message(STATUS " - make claude-workflow : Full Claude development cycle") message(STATUS " - make ci-simulation : Simulate CI/CD pipeline") endif() # Installation rules install(TARGETS designer-engine economy-engine event-engine factory-engine intelligence-engine logistic-engine macroentity-engine map-engine operation-engine war-engine DESTINATION bin ) # ============================================================================= # PACKAGING AUTOMATIQUE AVEC CPACK # ============================================================================= include(CPack) # Configuration générale du package set(CPACK_PACKAGE_NAME "Warfactory") set(CPACK_PACKAGE_VENDOR "Warfactory Project") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Factorio-inspired industrial military simulation - Multi-engine architecture") set(CPACK_PACKAGE_VERSION_MAJOR 1) set(CPACK_PACKAGE_VERSION_MINOR 0) set(CPACK_PACKAGE_VERSION_PATCH 0) set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_CONTACT "warfactory@example.com") # Générateurs de packages set(CPACK_GENERATOR "TGZ;ZIP") # Configuration spécifique Linux if(UNIX AND NOT APPLE) list(APPEND CPACK_GENERATOR "DEB" "RPM") # Configuration DEB set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libstdc++6, libgcc1") set(CPACK_DEBIAN_PACKAGE_SECTION "games") set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Warfactory Team ") # Configuration RPM set(CPACK_RPM_PACKAGE_GROUP "Applications/Games") set(CPACK_RPM_PACKAGE_LICENSE "MIT") set(CPACK_RPM_PACKAGE_REQUIRES "glibc, libstdc++, libgcc") endif() # Configuration spécifique Windows if(WIN32) list(APPEND CPACK_GENERATOR "NSIS" "WIX") set(CPACK_NSIS_DISPLAY_NAME "Warfactory Game") set(CPACK_NSIS_PACKAGE_NAME "Warfactory") set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/warfactory/warfactory") set(CPACK_NSIS_HELP_LINK "https://github.com/warfactory/warfactory/issues") set(CPACK_NSIS_MODIFY_PATH ON) endif() # Configuration spécifique macOS if(APPLE) list(APPEND CPACK_GENERATOR "Bundle" "DragNDrop") set(CPACK_BUNDLE_NAME "Warfactory") set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/assets/warfactory.icns") set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/assets/Info.plist") endif() # Composants pour installation sélective set(CPACK_COMPONENTS_ALL engines libraries headers documentation) # Description des composants set(CPACK_COMPONENT_ENGINES_DISPLAY_NAME "Game Engines") set(CPACK_COMPONENT_ENGINES_DESCRIPTION "Core game engines (Economy, War, Factory, etc.)") set(CPACK_COMPONENT_ENGINES_GROUP "Runtime") set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Development Libraries") set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Static and shared libraries for engine development") set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header Files") set(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ header files for engine APIs") set(CPACK_COMPONENT_HEADERS_GROUP "Development") set(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation") set(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "API documentation and user guides") set(CPACK_COMPONENT_DOCUMENTATION_GROUP "Documentation") # Groupes de composants set(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Runtime components needed to play the game") set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Development tools and libraries") set(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION "Documentation and help files") # Source package (pour distribution du code source) set(CPACK_SOURCE_GENERATOR "TGZ;ZIP") set(CPACK_SOURCE_IGNORE_FILES "/\\.git/" "/build/" "/\\.vscode/" "/\\.idea/" "\\.DS_Store" "Thumbs\\.db" "\\.gitignore" "\\.gitmodules" ) # Installation des composants install(TARGETS designer-engine economy-engine event-engine factory-engine intelligence-engine logistic-engine macroentity-engine map-engine operation-engine war-engine COMPONENT engines DESTINATION bin ) # Si les libraries sont créées par l'automation if(TARGET designer-engine-lib) install(TARGETS designer-engine-lib economy-engine-lib event-engine-lib factory-engine-lib intelligence-engine-lib logistic-engine-lib macroentity-engine-lib map-engine-lib operation-engine-lib war-engine-lib COMPONENT libraries DESTINATION lib ) endif() # Headers install(DIRECTORY include/ COMPONENT headers DESTINATION include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" ) # Documentation (si générée) install(DIRECTORY ${CMAKE_BINARY_DIR}/docs/ COMPONENT documentation DESTINATION share/doc/warfactory OPTIONAL ) # Targets de packaging add_custom_target(package-all COMMAND ${CMAKE_CPACK_COMMAND} --config CPackConfig.cmake COMMENT "Creating all packages" ) add_custom_target(package-source COMMAND ${CMAKE_CPACK_COMMAND} --config CPackSourceConfig.cmake COMMENT "Creating source package" ) add_custom_target(package-binary COMMAND ${CMAKE_CPACK_COMMAND} -G "TGZ;ZIP" COMMENT "Creating binary packages" ) message(STATUS "📦 CPack packaging configured:") message(STATUS " - make package : Default package") message(STATUS " - make package-all : All package formats") message(STATUS " - make package-source : Source distribution") message(STATUS " - make package-binary : Binary distribution")