cmake: support for commands and targets
5nord opened this issue · comments
A test suite usually requires custom code generators for TTCN-3. It would be nice if CMake module FindNTT.cmake would be able to expand CMake targets or commands to their target directory automatically.
# boilerplate
find_package(Protobuf REQUIRED)
find_package(NTT REQUIRED)
# A "custom" code generator target, which generates
# TTCN-3 modules into $CMAKE_CURRENT_BINARY_DIR
protobuf_generate_ttcn3(proto_itf
foo.proto
bar.proto
)
...
Current Behaviour
...
add_ttcn3_suite(suite1 DEPENDS
# we have to hardcode the output directory target proto_itf, manually. :(
${CMAKE_CURRENT_BINARY_DIR}
)
Desired Behaviour
...
add_ttcn3_suite(suite1 DEPENDS
# it would be nice, if CMake would automatically figure the output directory :)
proto_itf
)
Implementation
I don't know how to implement desired behaviour. Properties, maybe?
Current implementation does not work, because custom commands do not provide generator expression TARGET_FILE_DIR
:
foreach(x ${_DEPENDS})
if (TARGET "${x}")
string(APPEND MANIFEST " - $<TARGET_FILE_DIR:${x}>\n")
Error:
CMake Error at /usr/share/cmake/Modules/FindNTT.cmake:216 (file):
Error evaluating generator expression:
$<TARGET_FILE_DIR:proto_itf>
Target "proto_itf" is not an executable or library.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days