-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable externally installed nlohmann-json and spdlog dependencies Closes #42 See merge request tuda-sc/projects/metacg!64
- Loading branch information
Showing
5 changed files
with
73 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,23 @@ | ||
include(ExternalProject) | ||
include(FetchContent) | ||
|
||
if(DEFINED JSON_INCLUDE) | ||
message("JSON_INCLUDE predefined: ${JSON_INCLUDE}") | ||
if(METACG_USE_EXTERNAL_JSON) | ||
message("Using externally found json library") | ||
# Taken from https://cmake.org/cmake/help/v3.16/command/find_package.html#version-selection Should enable to use the | ||
# highest available version number, should the package provide sorting | ||
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) | ||
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) | ||
find_package( | ||
nlohmann_json | ||
3.10 | ||
REQUIRED | ||
) | ||
else() | ||
find_path(JSON_LIBRARY NAMES json) | ||
if(JSON_LIBRARY) | ||
set(JSON_INCLUDE ${JSON_LIBRARY}/json/single_include) | ||
message("JSON found in ${JSON_INCLUDE}") | ||
else() | ||
message("JSON library not found, download into extern during make") | ||
ExternalProject_Add( | ||
json | ||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/json | ||
GIT_REPOSITORY "https://github.com/nlohmann/json.git" | ||
GIT_TAG master | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
INSTALL_COMMAND "" | ||
TEST_COMMAND "" | ||
GIT_SHALLOW true | ||
) | ||
set(JSON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/extern/json/single_include) | ||
endif() | ||
message("Using fetched release version of json library") | ||
|
||
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz) | ||
FetchContent_MakeAvailable(json) | ||
endif() | ||
|
||
function(add_json target) | ||
add_dependencies(${target} json) | ||
|
||
target_include_directories(${target} SYSTEM PUBLIC ${JSON_INCLUDE}) | ||
target_link_libraries(${target} nlohmann_json::nlohmann_json) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
include(FetchContent) | ||
|
||
if(METACG_USE_EXTERNAL_SPDLOG) | ||
message("Using externally found spdlog library") | ||
find_package( | ||
spdlog | ||
1.8.2 | ||
REQUIRED | ||
) | ||
else() | ||
message("Using fetched release version of spdlog library") | ||
|
||
FetchContent_Declare(spdlog URL https://github.com/gabime/spdlog/archive/refs/tags/v1.8.2.tar.gz) | ||
FetchContent_MakeAvailable(spdlog) | ||
|
||
# Only install when spdlog is desired as automatically downloaded library | ||
install( | ||
TARGETS spdlog | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
) | ||
endif() | ||
|
||
function(add_spdlog_libraries target) | ||
target_link_libraries(${target} spdlog::spdlog) | ||
endfunction() |
This file was deleted.
Oops, something went wrong.