jsonnet
jsonnet copied to clipboard
CMake: Non-existent dependency warning when attempting to disable BUILD_JSONNET option
I'm about to integrate libjsonnet++
in a C++ project that should support processing of jsonnet files. The project is CMake based, so the projects CMakeLists.txt looks somewhat like that:
option (BUILD_JSONNET "Build jsonnet command-line tool." OFF)
option (BUILD_JSONNETFMT "Build jsonnetfmt command-line tool." OFF)
option (BUILD_TESTS "Build and run jsonnet tests." OFF)
add_subdirectory (ext/jsonnet)
add_executable (my_project src/main.cpp)
target_link_libraries (my_project PRIVATE libjsonnet++_static)
This generates a project that successfully compiles but generates the following warning at CMake configuration time:
CMake Warning (dev) at pdc/ext/jsonnet/cpp/CMakeLists.txt:31 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
The dependency target "jsonnet" of target "libjsonnet++_static" does not
exist.
This warning is for project developers. Use -Wno-dev to suppress it.
I deliberately don't want the jsonnet command line tool target to be created in order to keep the CMake targets of my project clean and tidy, so disabling it and only linking my project against libjsonnet++_static
seems like the right thing to do. Generally, I'm a bit surprised by these dependencies. Is it just an oversight for the configuration that I'm using or am using it in an unsupported configuration?
Looks like an oversight - we should add the dependency conditionally. Thanks for the bug report!
Actually looking closer it looks like it's just an entirely incorrect dependency and should be removed. I will do some more digging to try to work out if I've misunderstood something.