warfactoryracine/CMakeLists.txt
StillHammer 61ef2293ad Replace engine architecture with modular triple interface system
- Remove old 10-engine system (engines/ directory deleted)
- Implement C++ triple interface architecture:
  * IEngine: Execution coordination (Debug → Production)
  * IModuleSystem: Strategy pattern (Sequential → Threaded → Cluster)
  * IModule: Pure game logic interface (200-300 lines per module)
  * IIO: Communication transport (Intra → Local → Network)

- Add autonomous module structure:
  * modules/factory/: Production logic with autonomous build
  * modules/economy/: Market simulation with autonomous build
  * modules/logistic/: Supply chain with autonomous build
  * Each module: CLAUDE.md + CMakeLists.txt + shared/ + build/

- Benefits for Claude Code development:
  * Ultra-focused contexts (200 lines vs 50K+ lines)
  * Autonomous builds (cmake . from module directory)
  * Hot-swappable infrastructure without logic changes
  * Parallel development across multiple Claude instances

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-20 09:15:03 +08:00

332 lines
11 KiB
CMake

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 modular architecture
add_subdirectory(core)
add_subdirectory(modules)
# Build core system target
add_custom_target(warfactory-core
DEPENDS
warfactory-engine
warfactory-modules
COMMENT "Building Warfactory modular core"
)
# =============================================================================
# ADVANCED TESTING TARGETS
# =============================================================================
if(ENABLE_ADVANCED_TOOLS)
# Fuzzing targets for modular system
add_custom_target(fuzz-all-modules
COMMENT "Running fuzzing on all modules"
)
# Static analysis for modular system
add_custom_target(analyze-all-modules
COMMENT "Running static analysis on all modules"
)
# Coverage for modular system
add_custom_target(coverage-all-modules
COMMENT "Generating coverage reports for all modules"
)
# Concurrency analysis for modular system
add_custom_target(concurrency-all-modules
COMMENT "Running concurrency analysis on all modules"
)
# ABI validation for modular system
add_custom_target(abi-all-modules
COMMENT "Validating ABI for all modules"
)
# Master testing target
add_custom_target(test-everything
DEPENDS fuzz-all-modules analyze-all-modules coverage-all-modules
COMMENT "Run all advanced testing on modular system"
)
message(STATUS "🎯 Advanced testing targets configured")
message(STATUS " - Use 'make fuzz-all-modules' for fuzzing")
message(STATUS " - Use 'make analyze-all-modules' 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}/core ${CMAKE_SOURCE_DIR}/modules
COMMENT "Running Cppcheck on modular system"
)
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}/core ${CMAKE_SOURCE_DIR}/modules -name "*.cpp" -exec ${CLANG_TIDY_EXECUTABLE} {} +
COMMENT "Running clang-tidy on modular system"
)
add_dependencies(validate-all clang-tidy-all)
endif()
# Build rapide tous les modules
add_custom_target(build-all-fast
DEPENDS warfactory-core
COMMENT "Fast build of modular system"
)
# 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 warfactory-core
COMMENT "Clean rebuild of modular system"
)
# Documentation de tous les modules
add_custom_target(docs-all
COMMENT "Generating documentation for modular system"
)
# Tests de tous les modules
add_custom_target(test-all-modules
COMMAND ${CMAKE_CTEST_COMMAND} --parallel 4 --output-on-failure
COMMENT "Running tests for all modules"
)
# Performance benchmarks
add_custom_target(bench-all-modules
COMMENT "Running benchmarks for all modules"
)
# Claude Code workflow target - build + test + validate
add_custom_target(claude-workflow
DEPENDS build-all-fast validate-all test-all-modules
COMMENT "Complete Claude Code development workflow"
)
# 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 modular system")
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 modular system")
message(STATUS " - make claude-workflow : Full Claude development cycle")
message(STATUS " - make ci-simulation : Simulate CI/CD pipeline")
endif()
# CI/CD simulation
add_custom_target(ci-simulation
DEPENDS rebuild-all validate-all test-all-modules docs-all
COMMENT "Simulate CI/CD pipeline"
)
# Installation rules (to be updated when targets exist)
# install(TARGETS
# warfactory-core
# 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 - Modular 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 <warfactory@example.com>")
# 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 core modules libraries headers documentation)
# Description des composants
set(CPACK_COMPONENT_CORE_DISPLAY_NAME "Core System")
set(CPACK_COMPONENT_CORE_DESCRIPTION "Core modular system and runtime")
set(CPACK_COMPONENT_CORE_GROUP "Runtime")
set(CPACK_COMPONENT_MODULES_DISPLAY_NAME "Game Modules")
set(CPACK_COMPONENT_MODULES_DESCRIPTION "Pluggable game modules (Economy, Combat, etc.)")
set(CPACK_COMPONENT_MODULES_GROUP "Runtime")
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Development Libraries")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Static and shared libraries for module development")
set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header Files")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ header files for module 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"
)
# 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")