d38e1466da
canon add module <path> creates <stem>/<path>.hpp, .cpp and .test.cpp (--no-test skips the test), records the module in .canon.toml, adds the source to the project's target and re-renders the managed block of CMakeLists.txt. canon add unit-test adds the test later. Both work from any directory inside the project. - toml: a reader for the TOML subset canon writes, with line numbers in errors, so canon stays dependency-free - manifest: strict parsing (unknown keys, wrong types, bad references) - project: finds .canon.toml by walking up from the current directory - plan/executor: update_file refuses to write if the file changed after it was read, and the report skips directories that already exist - tests: shared scenarios drive both the golden and end-to-end tests; goldens now live in tests/golden/<scenario>/ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
46 lines
1.4 KiB
CMake
46 lines
1.4 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(libhello VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
option(BUILD_TESTING "Build libhello's tests" ON)
|
|
if(BUILD_TESTING)
|
|
enable_testing()
|
|
endif()
|
|
|
|
# Add your own CMake outside the managed block below.
|
|
|
|
# >>> canon:managed >>>
|
|
# Rendered from .canon.toml; canon rewrites everything between these markers.
|
|
|
|
add_library(libhello
|
|
hello/hello.cpp
|
|
hello/core.cpp
|
|
hello/details/utility.cpp
|
|
)
|
|
set_target_properties(libhello PROPERTIES PREFIX "")
|
|
target_include_directories(libhello PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_features(libhello PUBLIC cxx_std_23)
|
|
|
|
if(BUILD_TESTING)
|
|
add_executable(hello.hello.test hello/hello.test.cpp)
|
|
target_link_libraries(hello.hello.test PRIVATE libhello)
|
|
add_test(NAME hello/hello.test COMMAND hello.hello.test)
|
|
|
|
add_executable(hello.core.test hello/core.test.cpp)
|
|
target_link_libraries(hello.core.test PRIVATE libhello)
|
|
add_test(NAME hello/core.test COMMAND hello.core.test)
|
|
|
|
add_executable(hello.details.utility.test hello/details/utility.test.cpp)
|
|
target_link_libraries(hello.details.utility.test PRIVATE libhello)
|
|
add_test(NAME hello/details/utility.test COMMAND hello.details.utility.test)
|
|
|
|
add_executable(tests.basics tests/basics/driver.cpp)
|
|
target_link_libraries(tests.basics PRIVATE libhello)
|
|
add_test(NAME basics COMMAND tests.basics)
|
|
endif()
|
|
|
|
# <<< canon:managed <<<
|