-
Notifications
You must be signed in to change notification settings - Fork 145
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
Prefix PUBLIC_HEADER with CMAKE_CURRENT_SOURCE_DIR #332
base: main
Are you sure you want to change the base?
Prefix PUBLIC_HEADER with CMAKE_CURRENT_SOURCE_DIR #332
Conversation
This is required to install the project when using cmake FetchContent, or it will complain about the file json-schema.hpp not found (because it will use a relative path to the project that called FetchContent instead of json-schema-validator path
Could you share an example build? |
Sure, here is a minimal example:
main.cpp
Run
|
I am using cmake 3.26.5 on Rocky Linux 9 (RHEL 9) |
Ok I did some debugging. Try this CMakeLists.txt instead: cmake_minimum_required(VERSION 3.25...3.30)
project(Example)
include(FetchContent)
option(JSON_VALIDATOR_INSTALL "example: Override" ON)
option(JSON_Install "example: Override" ON)
FetchContent_Declare(JSON_SCHEMA_VALIDATOR
GIT_REPOSITORY https://github.com/pboettch/json-schema-validator
GIT_TAG 2.3.0
)
FetchContent_MakeAvailable(JSON_SCHEMA_VALIDATOR)
add_library(example main.cpp)
target_link_libraries(example PRIVATE nlohmann_json_schema_validator)
install(TARGETS
example
EXPORT
exampleConfig
)
install(EXPORT exampleConfig DESTINATION cmake) Explanation:
You reminded me of the weird edge-case that when you have a static library Edit: I've tried to revisit the problem and made MWE and I am afraid things can get quite messy if you want to support both static and shared library build |
This is required to install the project when using cmake FetchContent, or it will complain about the file json-schema.hpp not found (because it will use a relative path to the project that called FetchContent instead of json-schema-validator path