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>
68 lines
2.2 KiB
CMake
68 lines
2.2 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.
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
add_library(libhello
|
|
hello/hello.cpp
|
|
)
|
|
set_target_properties(libhello PROPERTIES PREFIX "")
|
|
target_include_directories(libhello PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_features(libhello PUBLIC cxx_std_23)
|
|
target_link_libraries(libhello PUBLIC libextra)
|
|
|
|
add_executable(hello-cli
|
|
hello-cli/hello-cli.cpp
|
|
hello-cli/args.cpp
|
|
)
|
|
target_include_directories(hello-cli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_link_libraries(hello-cli PRIVATE libhello Threads::Threads)
|
|
|
|
add_library(libextra
|
|
extra/extra.cpp
|
|
)
|
|
set_target_properties(libextra PROPERTIES PREFIX "")
|
|
target_include_directories(libextra PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_features(libextra 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-cli.args.test hello-cli/args.test.cpp hello-cli/args.cpp)
|
|
target_include_directories(hello-cli.args.test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_link_libraries(hello-cli.args.test PRIVATE libhello Threads::Threads)
|
|
add_test(NAME hello-cli/args.test COMMAND hello-cli.args.test)
|
|
|
|
add_executable(extra.extra.test extra/extra.test.cpp)
|
|
target_link_libraries(extra.extra.test PRIVATE libextra)
|
|
add_test(NAME extra/extra.test COMMAND extra.extra.test)
|
|
|
|
add_executable(tests.basics tests/basics/driver.cpp)
|
|
target_link_libraries(tests.basics PRIVATE libhello)
|
|
add_test(NAME basics COMMAND tests.basics)
|
|
|
|
add_test(NAME hello-cli COMMAND hello-cli)
|
|
|
|
add_executable(tests.edge-cases tests/edge-cases/driver.cpp)
|
|
target_link_libraries(tests.edge-cases PRIVATE libhello)
|
|
add_test(NAME edge-cases COMMAND tests.edge-cases)
|
|
endif()
|
|
|
|
# <<< canon:managed <<<
|