add_custom_target does not allow slashes in the target name
cmake_minimum_required(VERSION 3.15)
project(test_install CXX)
add_custom_target("hello/world" COMMAND "echo" "hi")
Configuring says:
CMake Error at CMakeLists.txt:5 (add_custom_target):
add_custom_target called with invalid target name "hello/world". Target
names may not contain a slash. Use ADD_CUSTOM_COMMAND to generate files.
The desire is to achieve something like:
add_executable(tst_foo)
add_test(NAME "tst_foo" COMMAND tst_foo)
add_custom_target(tst_foo/check
COMMAND "${CMAKE_CTEST_COMMAND}" -V -R "^tst_foo$")
add_dependencies("tst_foo/check" "tst_foo")
and then just run "ninja tst_foo/check" to both build and run the test.
Ninja already provides foo/all, and various other slash-y target names, so the "/check" is more intuitive then adding a custom target like tst_foo_check
.