Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .vs/slnx.sqlite
Binary file not shown.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ source_group(TREE ${SRC_DIR} PREFIX "src" FILES ${SRC_MAIN} )

target_include_directories(SCAPI PRIVATE
"${SRC_DIR}"
"${json_SOURCE_DIR}/single_include"
)

target_link_libraries(SCAPI PRIVATE botan pugixml cpr json)
target_link_libraries(SCAPI PRIVATE botan pugixml cpr nlohmann_json::nlohmann_json)

# Warnings as errors
set_property(TARGET SCAPI PROPERTY COMPILE_WARNING_AS_ERROR ON)
Expand Down
31 changes: 30 additions & 1 deletion scripts/json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,33 @@ FetchContent_Declare(
GIT_PROGRESS TRUE
)
message("json")
FetchContent_MakeAvailable(json)

FetchContent_MakeAvailable(json)

# Some nlohmann json CMake scripts add a reference to a natvis file
# which may be missing in certain FetchContent sources. Create an empty
# natvis file for MSVC builds to avoid "Cannot find source file" errors.
if(MSVC)
if(NOT EXISTS "${json_SOURCE_DIR}/nlohmann_json.natvis")
file(WRITE "${json_SOURCE_DIR}/nlohmann_json.natvis" "<Natvis></Natvis>\n")
endif()
endif()

# Remove any .natvis INTERFACE source added by the nlohmann_json target to avoid
# CMake complaining about missing files when the natvis is not present in the
# fetchcontent checkout. This filters SOURCES on the imported target.
if(TARGET nlohmann_json)
get_target_property(_json_sources nlohmann_json SOURCES)
if(_json_sources)
set(_filtered_json_sources)
foreach(_s IN LISTS _json_sources)
if(NOT _s MATCHES ".*\\.natvis$")
list(APPEND _filtered_json_sources "${_s}")
endif()
endforeach()
if(_filtered_json_sources)
# overwrite SOURCES property without natvis entries
set_property(TARGET nlohmann_json PROPERTY SOURCES "${_filtered_json_sources}")
endif()
endif()
endif()