cmake: Avoid exposing implementation dependencies publicly (#102)

The `CPPDAP_JSON_{NLOHMANN,RAPID}` compile definition is used only in
cppdap's implementation sources, and does not need to be defined by
dependents including our headers.

Also avoid exposing `nlohmann_json::nlohmann_json` as a public link
dependency of our installed package.  It is used only when compiling
cppdap.
This commit is contained in:
Brad King 2023-03-23 13:56:22 -04:00 committed by GitHub
parent bf1f56547c
commit 558886e7e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,7 +136,7 @@ endif()
function(cppdap_set_json_links target)
if (CPPDAP_USE_EXTERNAL_NLOHMANN_JSON_PACKAGE)
target_link_libraries(${target} PRIVATE nlohmann_json nlohmann_json::nlohmann_json)
target_link_libraries(${target} PRIVATE "$<BUILD_INTERFACE:nlohmann_json::nlohmann_json>")
elseif(CPPDAP_USE_EXTERNAL_RAPIDJSON_PACKAGE)
target_link_libraries(${target} PRIVATE rapidjson)
else()
@ -164,7 +164,7 @@ function(cppdap_set_target_options target)
# Add define for JSON library in use
target_compile_definitions(${target}
PUBLIC "CPPDAP_JSON_${CPPDAP_JSON_LIBRARY_UPPER}=1"
PRIVATE "CPPDAP_JSON_${CPPDAP_JSON_LIBRARY_UPPER}=1"
)
# Treat all warnings as errors