mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 20:19:20 +02:00
The track layout library came in as a subproject of its own -- its own CMakeLists, its own install and export rules, its own include tree -- which only made the build harder to follow now that everything else is a module. It is part of the editor, so it lives where the editor lives. - editor/plan_*.cppm / plan_*.cpp: the fifteen interface units and twelve implementation units, flat in editor/ beside editorTerrain and orthophoto, with the plan_ prefix keeping them clear of what was already there (editor/turnouts is the preset catalogue, so the geometry is plan_turnout_geometry). - modules are named eu07.editor.plan_*, like every other module in the tree. - namespaces move under the editor's own: editor::plan, editor::plan::geometry, ::io, ::render. The library's old name is gone from the sources and the docs. - every moved file carries the MPL header the rest of the tree carries; it had none. version.hpp went with the subproject: macros only, and unused. - the umbrella header is dropped -- nothing imported it. - the unit tests survive the fold: editor/tests, behind EU07_EDITOR_PLAN_TESTS (off by default), compiles the interfaces a second time into a small library of its own, because a test can only import modules from a target it links and linking the game would drag the whole simulator in. The code under test needs nothing but a compiler. 7/7 pass. - a switch may now be written with two dashes as well: --editor beside -editor. Builds with clang 22 (-DWITH_BETTER_RENDERER=OFF); -editor and --editor both come up in the editor on empty ground.
53 lines
2.0 KiB
CMake
53 lines
2.0 KiB
CMake
# Unit tests for the plan library (the geometry and the solver behind the track
|
|
# layout tool). They are off by default: switched on, the interface units are
|
|
# compiled a second time into a small library of their own, because a test
|
|
# executable can only import modules from a target it links, and linking the game
|
|
# would drag the whole simulator in. The code under test needs nothing but a
|
|
# C++20 compiler - no glm, no engine, no imgui.
|
|
option(EU07_EDITOR_PLAN_TESTS "Build the editor plan library unit tests" OFF)
|
|
if (NOT EU07_EDITOR_PLAN_TESTS)
|
|
return()
|
|
endif()
|
|
|
|
enable_testing()
|
|
|
|
set(PLAN_INTERFACES
|
|
../plan_segment.cppm
|
|
../plan_turnout_geometry.cppm
|
|
../plan_model.cppm
|
|
../plan_solution.cppm
|
|
../plan_chain.cppm
|
|
../plan_join.cppm
|
|
../plan_layout.cppm
|
|
../plan_render.cppm
|
|
../plan_sketch.cppm
|
|
../plan_tilecache.cppm
|
|
../plan_document_io.cppm
|
|
../plan_scn_export.cppm
|
|
../plan_scene.cppm
|
|
../plan_track_renderer.cppm
|
|
../plan_rail_renderer.cppm)
|
|
|
|
file(GLOB PLAN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../plan_*.cpp")
|
|
|
|
add_library(editor_plan STATIC ${PLAN_SOURCES})
|
|
target_sources(editor_plan
|
|
PUBLIC FILE_SET CXX_MODULES
|
|
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/..
|
|
FILES ${PLAN_INTERFACES})
|
|
set_target_properties(editor_plan PROPERTIES
|
|
CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF
|
|
POSITION_INDEPENDENT_CODE ON FOLDER "editor")
|
|
|
|
foreach(name chain hold lines graph format turnout tile_cache)
|
|
add_executable(editor_plan_test_${name} test_${name}.cpp)
|
|
target_link_libraries(editor_plan_test_${name} PRIVATE editor_plan)
|
|
target_include_directories(editor_plan_test_${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
set_target_properties(editor_plan_test_${name} PROPERTIES
|
|
CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF FOLDER "editor")
|
|
add_test(NAME plan_${name} COMMAND editor_plan_test_${name})
|
|
endforeach()
|
|
|
|
# test_scn.cpp and test_join.cpp are missing: they were never committed, along
|
|
# with the join module those two exercised (see the stub in plan_join.cpp).
|