Build / build (pull_request) Successful in 9m40s
- 🐞 on a custom target without an executable set debugs the program its command runs, as the build system has it (Ninja's edge, a Makefile's recipe): its arguments, directory and cmake -E env variables; what the target depends on is built first, not the target itself - Debug for custom targets in the status bar, the Targets view and the code lenses above add_custom_target - Dockerfile (Node, CMake, Ninja, g++, GDB), scripts/docker.sh to run a command in it, a dev container, and example/ to try the extension on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
843 B
CMake
26 lines
843 B
CMake
# A small project to try the extension on: F5 "Run Extension (example)".
|
|
cmake_minimum_required(VERSION 3.20)
|
|
project(example CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
add_library(greet src/greet.cpp)
|
|
target_include_directories(greet PUBLIC src)
|
|
|
|
add_executable(hello src/main.cpp)
|
|
target_link_libraries(hello PRIVATE greet)
|
|
|
|
enable_testing()
|
|
add_executable(greet_test tests/greet_test.cpp)
|
|
target_link_libraries(greet_test PRIVATE greet)
|
|
add_test(NAME greet COMMAND greet_test)
|
|
|
|
# Custom targets: ▶ builds them (runs their command), 🐞 debugs the program their command runs.
|
|
add_custom_target(run_hello
|
|
COMMAND hello CMake
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
COMMENT "Running hello")
|
|
add_custom_target(run_hello_env
|
|
COMMAND ${CMAKE_COMMAND} -E env GREETING=hi $<TARGET_FILE:hello> "with spaces"
|
|
COMMAND ${CMAKE_COMMAND} -E echo done)
|