Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Non-existent dependency warning when attempting to disable BUILD_JSONNET option #1107

Open
JanosGit opened this issue Jul 31, 2023 · 2 comments
Assignees

Comments

@JanosGit
Copy link

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?

@johnbartholomew
Copy link
Collaborator

Looks like an oversight - we should add the dependency conditionally. Thanks for the bug report!

@johnbartholomew
Copy link
Collaborator

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.

@johnbartholomew johnbartholomew self-assigned this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants