651fa4d89b
- add target lib|exe <name>: another library or executable in a source directory named after it (P1204R0's rule applied per target); a new executable links the project's library - add test <name>: tests/<name>/driver.cpp for a library, or a run of an executable, with --arg and --expect - add dep <dependency>: link a library of this project (no cycles, no executables) or an installed package's imported target such as fmt::fmt, adding its find_package() - doctor: read-only check of the files against .canon.toml and the P1204R0 layout; errors for missing declared files or broken markers, warnings for unbuilt sources, undeclared tests, a hand-edited managed block, .h/.cc extensions and include/ or src/ directories - every add command takes --target; the CLI rejects options a command does not take - manifest: packages, test args, and validation of target names, shared source directories and dependencies - templates moved to canon/templates.hpp - tests: multi-target and exe-tests scenarios; every scenario ends with canon doctor; CANON_CHECK accepts expressions containing commas; the CLI test no longer reads a destroyed temporary Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35 lines
984 B
CMake
35 lines
984 B
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(hello 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 hello'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_executable(hello
|
|
hello/hello.cpp
|
|
)
|
|
target_include_directories(hello PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
if(BUILD_TESTING)
|
|
add_test(NAME basics COMMAND hello)
|
|
set_tests_properties(basics PROPERTIES PASS_REGULAR_EXPRESSION "Hello, World!")
|
|
|
|
add_test(NAME greets-paul COMMAND hello "Paul")
|
|
set_tests_properties(greets-paul PROPERTIES PASS_REGULAR_EXPRESSION "^Hello, Paul!")
|
|
|
|
add_test(NAME spaces COMMAND hello "two words")
|
|
set_tests_properties(spaces PROPERTIES PASS_REGULAR_EXPRESSION "Hello, two words!")
|
|
endif()
|
|
|
|
# <<< canon:managed <<<
|