-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support both external and internal dependencies (#221)
* spdlog: Support an external spdlog * nlohmann_json: Support an internal submodule copy * external deps: rework option as USE_EXTERNAL_FOO and use a common macro * Use shallow submodules * Update README for new options to support both internal and external deps * Add missing test header dependencies to spdlog * Update clang-format action * Run Python checks only on our files Restrict glob to our package directory, so that submodule files are not checked * Ensure flake8 uses submodules Co-authored-by: Chuck Atkins <chuck.atkins@kitware.com>
- Loading branch information
1 parent
33ce283
commit 8fe67fc
Showing
11 changed files
with
102 additions
and
20 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,3 +1,8 @@ | ||
[submodule "submodules/nlohmann_json"] | ||
shallow = true | ||
path = submodules/nlohmann_json | ||
url = https://github.com/nlohmann/json.git | ||
[submodule "submodules/spdlog"] | ||
shallow = true | ||
path = submodules/spdlog | ||
url = https://github.com/gabime/spdlog.git |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# A helper function to add dependencies supporting both internal and external | ||
# versions. This adds a dependency with the following arguments: | ||
# _cmake_name - The name of the dependency's CMake pacakge used in | ||
# find_package(${_cmake_name}) | ||
# _opt_name - The configure option to create as USE_EXTERNAL_${_opt_name} | ||
# _sub_name - The name of the submodule the intal copy resides in at | ||
# submodules/${_sub_name} | ||
# | ||
# Note: The reason for all the manual logging is only some package configs | ||
# give useful output so we're just calling find_package(... QUIET) | ||
# and doing the logging ourselves. | ||
macro(_prmon_add_internal_external_dependency _cmake_name _opt_name _sub_name) | ||
set(USE_EXTERNAL_${_opt_name} AUTO CACHE STRING "Use an external ${_cmake_name}") | ||
set_property(CACHE USE_EXTERNAL_${_opt_name} PROPERTY | ||
STRINGS "ON;TRUE;AUTO;OFF;FALSE") | ||
mark_as_advanced(USE_EXTERNAL_${_opt_name}) | ||
if(USE_EXTERNAL_${_opt_name} STREQUAL AUTO) | ||
find_package(${_cmake_name} CONFIG QUIET) | ||
elseif(USE_EXTERNAL_${_opt_name}) | ||
find_package(${_cmake_name} CONFIG REQUIRED QUIET) | ||
endif() | ||
if(${_cmake_name}_FOUND) | ||
message(STATUS "Found ${_cmake_name}: ${${_cmake_name}_CONFIG} (found version \"${${_cmake_name}_VERSION}\")") | ||
else() # USE_EXTERNAL_${_opt_name} = OFF or AUTO and failed to find above | ||
if(USE_EXTERNAL_${_opt_name} STREQUAL AUTO) | ||
message(STATUS "External ${_cmake_name} not found, using internal submodule") | ||
else() | ||
message(STATUS "Forcing internal submodule for ${_cmake_name}") | ||
endif() | ||
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/submodules/${_sub_name}/CMakeLists.txt) | ||
message(FATAL_ERROR "${_cmake_name} submodule is not available") | ||
endif() | ||
add_subdirectory(submodules/${_sub_name} EXCLUDE_FROM_ALL) | ||
endif() | ||
endmacro() | ||
|
||
|
||
#--- nlohmann-json ------------------------------------------------------------- | ||
_prmon_add_internal_external_dependency(nlohmann_json NLOHMANN_JSON nlohmann_json) | ||
|
||
# Setup the imported target alias if an older un-aliased version is found | ||
if(TARGET nlohmann_json AND NOT TARGET nlohmann_json::nlohmann_json) | ||
add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json) | ||
endif() | ||
|
||
#--- spdlog -------------------------------------------------------------------- | ||
_prmon_add_internal_external_dependency(spdlog SPDLOG spdlog) |
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 was deleted.
Oops, something went wrong.
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
Submodule nlohmann_json
added at
4f8fba