Files
aevolution/CMakeLists.txt
T

452 lines
26 KiB
CMake

cmake_minimum_required(VERSION 3.28)
project(AeternalisEvolution VERSION 0.1.0 LANGUAGES CXX)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Use an out-of-source build, e.g. cmake --preset debug")
endif()
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <expected>
#if !defined(__cpp_lib_expected) || __cpp_lib_expected < 202202L
#error std::expected is required
#endif
int main() { std::expected<int, int> result{42}; return *result == 42 ? 0 : 1; }"
EVO_HAS_EXPECTED)
if(NOT EVO_HAS_EXPECTED)
message(FATAL_ERROR "This compiler/standard-library pair lacks the required C++23 std::expected")
endif()
option(EVO_WARNINGS_AS_ERRORS "Treat owned-code warnings as errors" ON)
option(EVO_ENABLE_TIDY "Run clang-tidy during compilation" OFF)
option(EVO_BUILD_FUZZER "Build the Clang libFuzzer snapshot target" OFF)
option(EVO_BUILD_ECS_EXPERIMENT "Build the isolated EnTT comparison (explicit preparation required)" OFF)
option(EVO_BUILD_POSTGRES "Build the isolated Linux PostgreSQL persistence adapter" OFF)
option(EVO_BUILD_CLIENT_PROBE "Build the isolated M9.1 SDL dependency probe" OFF)
option(EVO_BUILD_CLIENT "Build the native M9 engineering client" OFF)
set(EVO_SANITIZER "none" CACHE STRING "none, address (ASan/UBSan), or thread")
set_property(CACHE EVO_SANITIZER PROPERTY STRINGS none address thread)
include(cmake/ProjectOptions.cmake)
set(evo_simulation_sources src/simulation/world.cpp src/simulation/snapshot.cpp src/simulation/scheduler.cpp src/simulation/spatial.cpp)
add_library(evo_simulation STATIC ${evo_simulation_sources})
add_library(evo::simulation ALIAS evo_simulation)
target_include_directories(evo_simulation PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(evo_simulation PUBLIC cxx_std_23)
evo_owned_target(evo_simulation)
set(evo_world_sources src/world/coordinates.cpp src/world/generation.cpp src/world/chunks.cpp src/world/edits.cpp src/world/codec.cpp src/world/local_files.cpp src/world/environment_units.cpp src/world/fields.cpp src/world/environment.cpp src/world/transfers.cpp src/world/transfer_codec.cpp)
add_library(evo_world STATIC ${evo_world_sources})
add_library(evo::world ALIAS evo_world)
target_include_directories(evo_world PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(evo_world PUBLIC cxx_std_23)
evo_owned_target(evo_world)
add_library(evo_accounting STATIC src/accounting/ledger.cpp)
add_library(evo::accounting ALIAS evo_accounting)
target_include_directories(evo_accounting PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(evo_accounting PUBLIC cxx_std_23)
evo_owned_target(evo_accounting)
add_library(evo_biology STATIC src/biology/genome.cpp src/biology/development.cpp src/biology/metabolism.cpp src/biology/mutation.cpp src/biology/lineage.cpp)
add_library(evo::biology ALIAS evo_biology)
target_include_directories(evo_biology PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(evo_biology PUBLIC evo::accounting)
target_compile_features(evo_biology PUBLIC cxx_std_23)
evo_owned_target(evo_biology)
add_library(evo_ecology STATIC src/ecology/cohort.cpp src/ecology/collapse.cpp src/ecology/population.cpp src/ecology/materialize.cpp)
add_library(evo::ecology ALIAS evo_ecology)
target_include_directories(evo_ecology PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(evo_ecology PUBLIC evo::accounting evo::biology)
target_compile_features(evo_ecology PUBLIC cxx_std_23)
evo_owned_target(evo_ecology)
add_library(evo_processes STATIC src/processes/producer.cpp src/processes/feeding.cpp src/processes/ecosystem.cpp src/processes/genome_strategy.cpp src/processes/ensemble.cpp src/processes/environmental_community.cpp src/processes/environmental_codec.cpp src/processes/environmental_schedule.cpp src/processes/lineage_region.cpp src/processes/development_opening.cpp)
add_library(evo::processes ALIAS evo_processes)
target_link_libraries(evo_processes PUBLIC evo::accounting evo::biology evo::world)
evo_owned_target(evo_processes)
add_executable(evo-sim apps/evo-sim/main.cpp)
target_link_libraries(evo-sim PRIVATE evo::simulation evo::processes)
evo_owned_target(evo-sim)
# Portable host-side lease timing contract; no database or simulation dependency.
add_library(evo_region_lease STATIC src/persistence/region_lease.cpp)
add_library(evo::region_lease ALIAS evo_region_lease)
target_include_directories(evo_region_lease PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(evo_region_lease PUBLIC cxx_std_23)
evo_owned_target(evo_region_lease)
# Portable host status and bounded operational exposition (M7.8).
add_library(evo_ops STATIC src/server/ops.cpp)
add_library(evo::ops ALIAS evo_ops)
target_include_directories(evo_ops PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(evo_ops PUBLIC cxx_std_23)
evo_owned_target(evo_ops)
# Portable checkpoint manifest codec and environmental-v1 payload validation.
add_library(evo_region_checkpoint STATIC src/persistence/region_checkpoint.cpp src/persistence/region_batch.cpp)
add_library(evo::region_checkpoint ALIAS evo_region_checkpoint)
target_link_libraries(evo_region_checkpoint PUBLIC evo::region_lease evo::processes)
evo_owned_target(evo_region_checkpoint)
include(CTest)
if(EVO_BUILD_CLIENT_PROBE OR EVO_BUILD_CLIENT)
include(cmake/ClientProbe.cmake)
endif()
if(EVO_BUILD_POSTGRES)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(FATAL_ERROR "The initial PostgreSQL adapter is qualified on Linux only")
endif()
find_package(PostgreSQL 18.6 EXACT REQUIRED)
find_package(Threads REQUIRED)
add_library(evo_postgres STATIC src/persistence/postgres.cpp src/persistence/region_lease_store.cpp)
add_library(evo::postgres ALIAS evo_postgres)
target_include_directories(evo_postgres PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(evo_postgres PUBLIC evo::region_lease PRIVATE PostgreSQL::PostgreSQL)
evo_owned_target(evo_postgres)
# SHA-256 via system OpenSSL libcrypto (already required by libpq TLS; ADR-0061).
find_package(OpenSSL 3 REQUIRED COMPONENTS Crypto)
add_library(evo_region_store STATIC src/persistence/sha256.cpp src/persistence/object_store.cpp
src/persistence/checkpoint_store.cpp src/persistence/region_clone.cpp)
add_library(evo::region_store ALIAS evo_region_store)
target_link_libraries(evo_region_store PUBLIC evo::postgres evo::region_checkpoint
PRIVATE OpenSSL::Crypto)
evo_owned_target(evo_region_store)
# M7.6 authoritative region host and its process (ADR-0064).
add_library(evo_region_host STATIC src/server/region_host.cpp src/server/ops_http.cpp)
add_library(evo::region_host ALIAS evo_region_host)
target_link_libraries(evo_region_host PUBLIC evo::region_store evo::ops)
evo_owned_target(evo_region_host)
add_executable(evo-server apps/evo-server/main.cpp)
target_link_libraries(evo-server PRIVATE evo::region_host)
evo_owned_target(evo-server)
# M7.9 clone and history audit tool (ADR-0067).
add_executable(evo-world-clone apps/evo-world-clone/main.cpp)
target_link_libraries(evo-world-clone PRIVATE evo::region_store)
evo_owned_target(evo-world-clone)
if(BUILD_TESTING)
# Contention tests use one thread and one connection per contender.
add_executable(evo-postgres-tests tests/postgres_tests.cpp tests/region_lease_store_tests.cpp
tests/region_checkpoint_store_tests.cpp tests/region_host_tests.cpp
tests/region_server_process_tests.cpp tests/region_recovery_tests.cpp
tests/region_ops_tests.cpp tests/region_clone_tests.cpp
tests/region_migration_tests.cpp tests/region_store_tests.cpp
tests/region_load_tests.cpp tests/region_upgrade_tests.cpp)
target_link_libraries(evo-postgres-tests PRIVATE evo::region_host Threads::Threads)
add_dependencies(evo-postgres-tests evo-server evo-world-clone) # Spawned by process tests.
evo_owned_target(evo-postgres-tests)
# Intentionally not an ordinary CTest: tools/ci/postgres-check.sh owns its private DB.
endif()
endif()
if(BUILD_TESTING)
add_executable(evo-region-lease-tests tests/region_lease_tests.cpp)
target_link_libraries(evo-region-lease-tests PRIVATE evo::region_lease)
evo_owned_target(evo-region-lease-tests)
add_test(NAME region-lease-contracts COMMAND evo-region-lease-tests)
set_tests_properties(region-lease-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-lineage-region-tests tests/lineage_region_tests.cpp)
target_link_libraries(evo-lineage-region-tests PRIVATE evo::processes)
evo_owned_target(evo-lineage-region-tests)
add_test(NAME lineage-region-contracts COMMAND evo-lineage-region-tests)
set_tests_properties(lineage-region-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-ops-tests tests/ops_tests.cpp)
target_link_libraries(evo-ops-tests PRIVATE evo::ops)
evo_owned_target(evo-ops-tests)
add_test(NAME ops-contracts COMMAND evo-ops-tests)
set_tests_properties(ops-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-region-batch-tests tests/region_batch_tests.cpp)
target_link_libraries(evo-region-batch-tests PRIVATE evo::region_checkpoint)
evo_owned_target(evo-region-batch-tests)
add_test(NAME region-batch-contracts COMMAND evo-region-batch-tests)
set_tests_properties(region-batch-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-region-checkpoint-tests tests/region_checkpoint_tests.cpp)
target_link_libraries(evo-region-checkpoint-tests PRIVATE evo::region_checkpoint)
evo_owned_target(evo-region-checkpoint-tests)
add_test(NAME region-checkpoint-contracts COMMAND evo-region-checkpoint-tests)
set_tests_properties(region-checkpoint-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-environmental-qualification tests/environmental_qualification.cpp)
target_link_libraries(evo-environmental-qualification PRIVATE evo::processes)
evo_owned_target(evo-environmental-qualification)
add_test(NAME environmental-qualification COMMAND evo-environmental-qualification)
set_tests_properties(environmental-qualification PROPERTIES TIMEOUT 120)
add_executable(evo-environmental-community-tests tests/environmental_community_tests.cpp)
target_link_libraries(evo-environmental-community-tests PRIVATE evo::processes)
evo_owned_target(evo-environmental-community-tests)
add_test(NAME environmental-community-contracts COMMAND evo-environmental-community-tests)
set_tests_properties(environmental-community-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-environment-transfers-tests tests/environment_transfers_tests.cpp)
target_link_libraries(evo-environment-transfers-tests PRIVATE evo::world)
evo_owned_target(evo-environment-transfers-tests)
add_test(NAME environment-transfers-contracts COMMAND evo-environment-transfers-tests)
set_tests_properties(environment-transfers-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-environment-views-tests tests/environment_views_tests.cpp)
target_link_libraries(evo-environment-views-tests PRIVATE evo::world)
evo_owned_target(evo-environment-views-tests)
add_test(NAME environment-views-contracts COMMAND evo-environment-views-tests)
set_tests_properties(environment-views-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-world-fields-tests tests/world_fields_tests.cpp)
target_link_libraries(evo-world-fields-tests PRIVATE evo::world)
evo_owned_target(evo-world-fields-tests)
add_test(NAME world-fields-contracts COMMAND evo-world-fields-tests)
set_tests_properties(world-fields-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-environment-units-tests tests/environment_units_tests.cpp)
target_link_libraries(evo-environment-units-tests PRIVATE evo::world evo::accounting)
evo_owned_target(evo-environment-units-tests)
add_test(NAME environment-units-contracts COMMAND evo-environment-units-tests)
set_tests_properties(environment-units-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-world-codec-fuzz-smoke tests/fuzz/world_codec_fuzz.cpp tests/fuzz/world_codec_smoke.cpp)
target_link_libraries(evo-world-codec-fuzz-smoke PRIVATE evo::world)
evo_owned_target(evo-world-codec-fuzz-smoke)
add_test(NAME world-codec-fuzz-smoke COMMAND evo-world-codec-fuzz-smoke)
set_tests_properties(world-codec-fuzz-smoke PROPERTIES TIMEOUT 120)
add_executable(evo-world-codec-tests tests/world_codec_tests.cpp)
target_link_libraries(evo-world-codec-tests PRIVATE evo::world)
evo_owned_target(evo-world-codec-tests)
add_test(NAME world-codec-contracts COMMAND evo-world-codec-tests)
set_tests_properties(world-codec-contracts PROPERTIES TIMEOUT 120)
add_executable(evo-world-local-files-tests tests/world_local_files_tests.cpp)
target_link_libraries(evo-world-local-files-tests PRIVATE evo::world)
evo_owned_target(evo-world-local-files-tests)
add_test(NAME world-local-files-contracts COMMAND evo-world-local-files-tests)
set_tests_properties(world-local-files-contracts PROPERTIES TIMEOUT 120)
add_executable(evo-world-edit-tests tests/world_edit_tests.cpp)
target_link_libraries(evo-world-edit-tests PRIVATE evo::world)
evo_owned_target(evo-world-edit-tests)
add_test(NAME world-edit-contracts COMMAND evo-world-edit-tests)
set_tests_properties(world-edit-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-world-chunk-tests tests/world_chunk_tests.cpp)
target_link_libraries(evo-world-chunk-tests PRIVATE evo::world)
evo_owned_target(evo-world-chunk-tests)
add_test(NAME world-chunk-contracts COMMAND evo-world-chunk-tests)
set_tests_properties(world-chunk-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-world-generation-tests tests/world_generation_tests.cpp)
target_link_libraries(evo-world-generation-tests PRIVATE evo::world)
evo_owned_target(evo-world-generation-tests)
add_test(NAME world-generation-contracts COMMAND evo-world-generation-tests)
set_tests_properties(world-generation-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-world-coordinate-tests tests/world_coordinates_tests.cpp)
target_link_libraries(evo-world-coordinate-tests PRIVATE evo::world)
evo_owned_target(evo-world-coordinate-tests)
add_test(NAME world-coordinate-contracts COMMAND evo-world-coordinate-tests)
set_tests_properties(world-coordinate-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-feeding-tests tests/feeding_tests.cpp)
target_link_libraries(evo-feeding-tests PRIVATE evo::processes)
evo_owned_target(evo-feeding-tests)
add_test(NAME feeding-contracts COMMAND evo-feeding-tests)
set_tests_properties(feeding-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-ecosystem-tests tests/ecosystem_tests.cpp)
target_link_libraries(evo-ecosystem-tests PRIVATE evo::processes)
evo_owned_target(evo-ecosystem-tests)
add_test(NAME ecosystem-contracts COMMAND evo-ecosystem-tests)
set_tests_properties(ecosystem-contracts PROPERTIES TIMEOUT 300)
add_executable(evo-genome-tests tests/genome_tests.cpp)
target_link_libraries(evo-genome-tests PRIVATE evo::biology)
evo_owned_target(evo-genome-tests)
add_test(NAME genome-contracts COMMAND evo-genome-tests)
set_tests_properties(genome-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-development-tests tests/development_tests.cpp)
target_link_libraries(evo-development-tests PRIVATE evo::biology)
evo_owned_target(evo-development-tests)
add_test(NAME development-contracts COMMAND evo-development-tests)
set_tests_properties(development-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-metabolism-tests tests/metabolism_tests.cpp)
target_link_libraries(evo-metabolism-tests PRIVATE evo::processes)
evo_owned_target(evo-metabolism-tests)
add_test(NAME metabolism-contracts COMMAND evo-metabolism-tests)
set_tests_properties(metabolism-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-mutation-tests tests/mutation_tests.cpp)
target_link_libraries(evo-mutation-tests PRIVATE evo::biology)
evo_owned_target(evo-mutation-tests)
add_test(NAME mutation-contracts COMMAND evo-mutation-tests)
set_tests_properties(mutation-contracts PROPERTIES TIMEOUT 120)
add_executable(evo-lineage-tests tests/lineage_tests.cpp)
target_link_libraries(evo-lineage-tests PRIVATE evo::biology)
evo_owned_target(evo-lineage-tests)
add_test(NAME lineage-contracts COMMAND evo-lineage-tests)
set_tests_properties(lineage-contracts PROPERTIES TIMEOUT 120)
add_executable(evo-ensemble-tests tests/ensemble_tests.cpp)
target_link_libraries(evo-ensemble-tests PRIVATE evo::processes)
evo_owned_target(evo-ensemble-tests)
add_test(NAME ensemble-contracts COMMAND evo-ensemble-tests)
set_tests_properties(ensemble-contracts PROPERTIES TIMEOUT 300)
add_executable(evo-producer-tests tests/producer_tests.cpp)
target_link_libraries(evo-producer-tests PRIVATE evo::processes)
evo_owned_target(evo-producer-tests)
add_test(NAME producer-contracts COMMAND evo-producer-tests)
set_tests_properties(producer-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-cohort-tests tests/cohort_tests.cpp)
target_link_libraries(evo-cohort-tests PRIVATE evo::ecology)
evo_owned_target(evo-cohort-tests)
add_test(NAME cohort-contracts COMMAND evo-cohort-tests)
set_tests_properties(cohort-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-collapse-tests tests/collapse_tests.cpp)
target_link_libraries(evo-collapse-tests PRIVATE evo::ecology)
evo_owned_target(evo-collapse-tests)
add_test(NAME collapse-contracts COMMAND evo-collapse-tests)
set_tests_properties(collapse-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-population-tests tests/population_tests.cpp)
target_link_libraries(evo-population-tests PRIVATE evo::ecology)
evo_owned_target(evo-population-tests)
add_test(NAME population-contracts COMMAND evo-population-tests)
set_tests_properties(population-contracts PROPERTIES TIMEOUT 120)
add_executable(evo-materialize-tests tests/materialize_tests.cpp)
target_link_libraries(evo-materialize-tests PRIVATE evo::ecology)
evo_owned_target(evo-materialize-tests)
add_test(NAME materialize-contracts COMMAND evo-materialize-tests)
set_tests_properties(materialize-contracts PROPERTIES TIMEOUT 120)
add_executable(evo-equivalence-tests tests/equivalence_tests.cpp)
target_link_libraries(evo-equivalence-tests PRIVATE evo::ecology)
evo_owned_target(evo-equivalence-tests)
add_test(NAME resolution-equivalence COMMAND evo-equivalence-tests)
set_tests_properties(resolution-equivalence PROPERTIES TIMEOUT 600)
add_executable(evo-ledger-tests tests/ledger_tests.cpp)
target_link_libraries(evo-ledger-tests PRIVATE evo::accounting)
evo_owned_target(evo-ledger-tests)
add_test(NAME ledger-contracts COMMAND evo-ledger-tests)
set_tests_properties(ledger-contracts PROPERTIES TIMEOUT 60)
add_executable(evo-tests tests/simulation_tests.cpp)
target_link_libraries(evo-tests PRIVATE evo::simulation)
evo_owned_target(evo-tests)
add_test(NAME simulation-contracts COMMAND evo-tests)
add_test(NAME test-harness-failure COMMAND evo-tests --self-test-failure)
set_tests_properties(test-harness-failure PROPERTIES WILL_FAIL TRUE)
add_test(NAME cli-replay COMMAND evo-sim --seed 123456 --ticks 1000 --entities 8 --verify-replay)
set_tests_properties(cli-replay PROPERTIES PASS_REGULAR_EXPRESSION "d61ad5bf0c928c76")
add_test(NAME cli-invalid-number COMMAND evo-sim --ticks -1)
set_tests_properties(cli-invalid-number PROPERTIES WILL_FAIL TRUE)
add_test(NAME cli-ecosystem COMMAND evo-sim --ecosystem --seed 0 --episodes 32)
set_tests_properties(cli-ecosystem PROPERTIES TIMEOUT 120
PASS_REGULAR_EXPRESSION "2cd4a15f9fbe9949")
# An option belonging to the other mode must be rejected, never accepted and ignored.
add_test(NAME cli-ecosystem-conflict COMMAND evo-sim --ecosystem --verify-replay)
add_test(NAME cli-ecosystem-rejects-ticks COMMAND evo-sim --ecosystem --seed 0 --ticks 1)
add_test(NAME cli-ecosystem-rejects-entities COMMAND evo-sim --ecosystem --entities 4)
add_test(NAME cli-ecosystem-rejects-save COMMAND evo-sim --ecosystem --save episodes.evo)
add_test(NAME cli-episodes-require-ecosystem COMMAND evo-sim --episodes 2 --tick-limit 1)
add_test(NAME cli-tick-limit-requires-ecosystem COMMAND evo-sim --ticks 10 --tick-limit 1)
add_test(NAME cli-ecosystem-rejects-seeds-per-cell COMMAND evo-sim --ecosystem --seeds-per-cell 4)
set_tests_properties(cli-ecosystem-conflict cli-ecosystem-rejects-ticks
cli-ecosystem-rejects-entities cli-ecosystem-rejects-save
cli-episodes-require-ecosystem cli-tick-limit-requires-ecosystem
cli-ecosystem-rejects-seeds-per-cell
PROPERTIES WILL_FAIL TRUE)
add_test(NAME cli-ensemble COMMAND evo-sim --ensemble --seed 0 --seeds-per-cell 4
--strategies 3 --tick-limit 400)
# Repinned when survivors stopped being recorded as deaths and the report gained
# deaths/survivors/observed_ticks with a summed shortfall. The reported facts
# changed, so the old value describes a report this build no longer produces.
set_tests_properties(cli-ensemble PROPERTIES TIMEOUT 120
PASS_REGULAR_EXPRESSION "5ec59d390909b526")
# The two measurement modes are separate workloads, and neither may borrow the
# other's options: --episodes counts episodes, --seeds-per-cell counts seeds.
add_test(NAME cli-ensemble-conflict COMMAND evo-sim --ensemble --verify-replay)
add_test(NAME cli-ensemble-excludes-ecosystem COMMAND evo-sim --ensemble --ecosystem)
add_test(NAME cli-ensemble-rejects-episodes COMMAND evo-sim --ensemble --episodes 2)
add_test(NAME cli-ensemble-rejects-ticks COMMAND evo-sim --ensemble --ticks 1)
add_test(NAME cli-ensemble-rejects-entities COMMAND evo-sim --ensemble --entities 4)
# Halves need at least one seed each, and the driver caps strategies at four.
add_test(NAME cli-ensemble-rejects-single-seed COMMAND evo-sim --ensemble --seeds-per-cell 1)
add_test(NAME cli-ensemble-rejects-excess-strategies COMMAND evo-sim --ensemble --strategies 5)
add_test(NAME cli-seeds-per-cell-requires-ensemble COMMAND evo-sim --seeds-per-cell 4)
add_test(NAME cli-strategies-requires-ensemble COMMAND evo-sim --strategies 3)
set_tests_properties(cli-ensemble-conflict cli-ensemble-excludes-ecosystem
cli-ensemble-rejects-episodes cli-ensemble-rejects-ticks cli-ensemble-rejects-entities
cli-ensemble-rejects-single-seed cli-ensemble-rejects-excess-strategies
cli-seeds-per-cell-requires-ensemble cli-strategies-requires-ensemble
PROPERTIES WILL_FAIL TRUE)
add_test(NAME cli-file-integration COMMAND "${CMAKE_COMMAND}"
"-DEVO_SIM=$<TARGET_FILE:evo-sim>" "-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/cli-integration"
-P "${CMAKE_CURRENT_SOURCE_DIR}/tests/cli_integration.cmake")
set_tests_properties(simulation-contracts cli-replay cli-file-integration PROPERTIES TIMEOUT 60)
endif()
add_executable(evo-benchmark tests/benchmarks/simulation_benchmark.cpp)
target_link_libraries(evo-benchmark PRIVATE evo::simulation)
evo_owned_target(evo-benchmark)
add_executable(evo-world-proof apps/evo-tools/world_proof.cpp)
target_link_libraries(evo-world-proof PRIVATE evo::world)
evo_owned_target(evo-world-proof)
if(BUILD_TESTING)
add_test(NAME world-process-restart COMMAND "${CMAKE_COMMAND}"
"-DEVO_WORLD_PROOF=$<TARGET_FILE:evo-world-proof>"
"-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/world-proof"
-P "${CMAKE_CURRENT_SOURCE_DIR}/tests/world_process_restart.cmake")
set_tests_properties(world-process-restart PROPERTIES TIMEOUT 120)
endif()
add_executable(evo-resolution-benchmark tests/benchmarks/resolution_benchmark.cpp)
target_link_libraries(evo-resolution-benchmark PRIVATE evo::ecology)
evo_owned_target(evo-resolution-benchmark)
if(BUILD_TESTING)
add_test(NAME resolution-sensitivity COMMAND evo-resolution-benchmark --verify)
set_tests_properties(resolution-sensitivity PROPERTIES TIMEOUT 120)
endif()
add_executable(evo-chunk-layout experiments/world/chunk_layout.cpp)
target_link_libraries(evo-chunk-layout PRIVATE evo::world)
evo_owned_target(evo-chunk-layout)
if(BUILD_TESTING)
add_test(NAME chunk-layout-contracts COMMAND evo-chunk-layout --verify)
set_tests_properties(chunk-layout-contracts PROPERTIES TIMEOUT 120)
endif()
add_executable(evo-spatial-benchmark tests/benchmarks/spatial_benchmark.cpp)
target_link_libraries(evo-spatial-benchmark PRIVATE evo::simulation)
evo_owned_target(evo-spatial-benchmark)
if(EVO_BUILD_FUZZER)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR MSVC OR EVO_SANITIZER STREQUAL "thread")
message(FATAL_ERROR "Fuzzing requires Linux Clang and is incompatible with TSan")
endif()
add_executable(evo-world-codec-fuzz tests/fuzz/world_codec_fuzz.cpp ${evo_world_sources})
target_include_directories(evo-world-codec-fuzz PRIVATE include)
evo_owned_target(evo-world-codec-fuzz)
target_compile_options(evo-world-codec-fuzz PRIVATE -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer)
target_link_options(evo-world-codec-fuzz PRIVATE -fsanitize=fuzzer,address,undefined)
# Compile the kernel itself with coverage and sanitizer instrumentation.
add_executable(evo-snapshot-fuzz tests/fuzz/snapshot_fuzz.cpp ${evo_simulation_sources})
target_include_directories(evo-snapshot-fuzz PRIVATE include)
evo_owned_target(evo-snapshot-fuzz)
target_compile_options(evo-snapshot-fuzz PRIVATE -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer)
target_link_options(evo-snapshot-fuzz PRIVATE -fsanitize=fuzzer,address,undefined)
endif()
if(EVO_BUILD_ECS_EXPERIMENT)
include(tools/entt-pin.cmake)
set(entt_root "${CMAKE_SOURCE_DIR}/build/external/entt")
if(NOT EXISTS "${entt_root}/include/entt/entt.hpp" OR NOT EXISTS "${entt_root}/LICENSE")
message(FATAL_ERROR "Run cmake -P tools/prepare-entt.cmake explicitly before configuring the experiment")
endif()
file(SHA256 "${entt_root}/include/entt/entt.hpp" entt_header_hash)
file(SHA256 "${entt_root}/LICENSE" entt_license_hash)
if(NOT entt_header_hash STREQUAL EVO_ENTT_HEADER_SHA256 OR NOT entt_license_hash STREQUAL EVO_ENTT_LICENSE_SHA256)
message(FATAL_ERROR "Experimental EnTT dependency failed integrity validation")
endif()
add_executable(evo-ecs-experiment experiments/ecs/comparison.cpp)
target_include_directories(evo-ecs-experiment PRIVATE include)
target_include_directories(evo-ecs-experiment SYSTEM PRIVATE "${entt_root}/include")
evo_owned_target(evo-ecs-experiment)
if(BUILD_TESTING)
add_test(NAME ecs-experiment-contracts COMMAND evo-ecs-experiment --verify)
set_tests_properties(ecs-experiment-contracts PROPERTIES TIMEOUT 120)
endif()
endif()
find_program(EVO_CLANG_FORMAT NAMES clang-format-19 clang-format)
add_custom_target(format-check COMMAND "${CMAKE_COMMAND}"
"-DFORMATTER=${EVO_CLANG_FORMAT}" "-DSOURCE_ROOT=${CMAKE_CURRENT_SOURCE_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/tools/check-format.cmake" VERBATIM)