From 4189578421a61ab3d44a1c9dcfa6572b4d30b2da Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Thu, 5 Jun 2025 11:10:18 +1000 Subject: [PATCH 01/12] bugfix --- cmake/submodule.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/submodule.cmake b/cmake/submodule.cmake index da47f29..64b309c 100644 --- a/cmake/submodule.cmake +++ b/cmake/submodule.cmake @@ -26,7 +26,7 @@ else() warthog_top_level() endif() if(${_is_top}) - if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${dirname}/.git") + if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${dirname}/CMakeLists.txt") message(SEND_ERROR "Failed to find submodule ${dirname}") else() add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${dirname}" EXCLUDE_FROM_ALL) From b8edd972a74f0b6433ea5c8494626013ab2e27cc Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Thu, 5 Jun 2025 11:11:21 +1000 Subject: [PATCH 02/12] renamed to connect with warthog for user --- cmake/{submodule.cmake => warthog.cmake} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmake/{submodule.cmake => warthog.cmake} (100%) diff --git a/cmake/submodule.cmake b/cmake/warthog.cmake similarity index 100% rename from cmake/submodule.cmake rename to cmake/warthog.cmake From 5ed3cfd3cf089e3c575891c1f4790107114ad28a Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Thu, 5 Jun 2025 16:11:57 +1000 Subject: [PATCH 03/12] update readme with submodule or subtree command --- README.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 453f0b5..1860857 100644 --- a/README.md +++ b/README.md @@ -22,25 +22,82 @@ Requires `warthog-core` as a dependency. # Using warthog -Warthog dependencies are setup using git-submodules, use commands below are used to initialise and update respectively: - git submodule init - git submodule update +It is recommended to use warthog not as a fork, but included in an external repo. +This can be setup with either a submodule (can't be modified unless forked submodule) +or subtree. -All dependencies should be placed in `/extern`. -If not project forked, we suggest setting the project up as below: +Helper functions from `/cmake/warthog.cmake`, calling `warthog_submodule(warthog-core)` will +add `warthog-core` using the command `add_subdirectory(extern/warthog-core EXCLUDE_FROM_ALL)`, +but only if called by the root project (can be overridden with `WARTHOG_SUBMODULE_ROOT_ONLY`). +This means that all warthog dependencies should be added by the root project using the +`warthog_submodule`, and placed in `/extern/` using either submodules or subtrees. + +## CMake + +Basic repo example from creation is below: + + git remote add warthog-core https://github.com/ShortestPathLab/warthog-core.git + git fetch warthog-core + git checkout warthog-core/main cmake/warthog.cmake + +Use this base CMake file `CMakeLists.txt` -1. Copy `/cmake/submodule.cmake` to your repo -2. Submodule or subtree all your warthog dependencies and their dependencies into `/extern` -3. In `/CMakeLists.txt`, setup as below: ``` -include(cmake/submodule.cmake) -warthog_submodule(warthog-[module]) # repeat for each [module] +cmake_minimum_required(VERSION 3.13) + +project(App + VERSION 0.0.1 + LANGUAGES CXX C) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) + +# warthog submodules +warthog_submodule(warthog-core) + +add_executable(app main.cpp) +target_link_libraries(app PUBLIC warthog::core) ``` -With (2) we flatten dependencies to top-level project. -With (3) `warthog_submodule` will add `add_subdirectoy` if your CMake is the top level config. +## Submodule + +Submodule dependencies are useful for avoiding diamond dependencies, +i.e. ensuring there is only a single copy of warthog-core in use. + +Commands for adding submodules for each repo are found below: + + git submodule add https://github.com/ShortestPathLab/warthog-core.git extern/warthog-core + git submodule add https://github.com/ShortestPathLab/warthog-jps.git extern/warthog-jps + +To update the version of warthog, for warthog module `$module`: + + cd extern/$module + git fetch + git checkout|git switch + cd .. + git add $module + +This will update the submodule to the checkout commit. +Initialise or update the submodule on other clones with +the following commands: + + git submodule init # after clone + git submodule update # after pull + +## Subtree + +Subtree will make the module a part of your repo, allowing +for local editing without forking. + +The setup for each module: + + git subtree -P extern/warthog-core add https://github.com/ShortestPathLab/warthog-core.git main|branch|commit --squash + git subtree -P extern/warthog-jps add https://github.com/ShortestPathLab/warthog-jps.git main|branch|commit --squash + +The update commands: -An informal project not designed to be a dependency does not require this, and can just `add_subdirectory` to all dependencies. + git subtree -P extern/warthog-core pull https://github.com/ShortestPathLab/warthog-core.git main|branch|commit --squash + git subtree -P extern/warthog-jps pull https://github.com/ShortestPathLab/warthog-jps.git main|branch|commit --squash # Resources From 578256f85c1f40e1c2663b35fdec589fcf3d2d28 Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Thu, 21 Aug 2025 15:23:11 +1000 Subject: [PATCH 04/12] test new module system --- CMakeLists.txt | 2 +- cmake/warthog.cmake | 48 +++++++++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8680923..0d3927c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ option(WARTHOG_BMI "Enable support cpu BMI for WARTHOG_INTRIN_HAS(BMI)" OFF) option(WARTHOG_BMI2 "Enable support cpu BMI2 for WARTHOG_INTRIN_HAS(BMI2), use for Zen 3+" OFF) option(WARTHOG_INTRIN_ALL "Enable march=native and support x86 intrinsics if able (based on system), supersedes all manual instruction sets" OFF) -include(cmake/submodule.cmake) +include(cmake/warthog.cmake) add_library(warthog_compile INTERFACE) add_library(warthog::compile ALIAS warthog_compile) diff --git a/cmake/warthog.cmake b/cmake/warthog.cmake index 64b309c..9642ceb 100644 --- a/cmake/warthog.cmake +++ b/cmake/warthog.cmake @@ -2,34 +2,56 @@ cmake_minimum_required(VERSION 3.13) # include this file to check submodule include +if(COMMAND warthog_submodule) + return() # do not redefine +endif() + +include(FetchContent) + set(WARTHOG_SUBMODULE_ROOT_ONLY ON CACHE BOOL "add submodule if present only allowed for root project") function(warthog_top_level) -set(_is_top OFF) +set(_warthog_is_top OFF) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.21) if(${PROJECT_IS_TOP_LEVEL}) - set(_is_top ON) + set(_warthog_is_top ON) endif() else() if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) - set(_is_top ON) + set(_warthog_is_top ON) endif() endif() -set(_is_top ${_is_top} PARENT_SCOPE) +set(_warthog_is_top ${_is_top} PARENT_SCOPE) endfunction() -function(warthog_submodule dirname) -set(_is_top OFF) -if(NOT ${WARTHOG_SUBMODULE_ROOT_ONLY}) - set(_is_top ON) +# warthog_submodule submodule [override_top] +# adds a submodule to warthog +# has checks to insure submodule is only added once +# if called from the top level project (or optional variable override_top is true) +# then if extern/${submodule}/CMakeLists.txt exists, adds that version instead +# intended for use with git submodule/subtree. +# otherwise, fetchcontent ${submodule} is made available +# user must add FetchContent_Declare +function(warthog_submodule submodule) +get_property(_submodule_added GLOBAL PROPERTY WARTHOG_${submodule} SET) +if(${_submodule_added}) # submodule already added + return() +endif() +if(${ARGC} GREATER 1 AND ${ARGV1}) + set(is_top_level TRUE) else() warthog_top_level() + set(is_top_level _warthog_is_top) endif() -if(${_is_top}) - if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${dirname}/CMakeLists.txt") - message(SEND_ERROR "Failed to find submodule ${dirname}") - else() - add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${dirname}" EXCLUDE_FROM_ALL) +if(${is_top_level}) + if(EXISTS "${PROJECT_SOURCE_DIR}/extern/${submodule}/CMakeLists.txt") + # submodule or subtree, include and exit + add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${submodule}") + set_property(GLOBAL PROPERTY WARTHOG_${submodule}) + return() endif() endif() +# failed to add submodule, fetch if able +FetchContent_MakeAvailable(${submodule}) +set_property(GLOBAL PROPERTY WARTHOG_${submodule}) endfunction() From c1caa1393bf1bdcf54c7f1b9d4f0f1c12bfbf391 Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Thu, 21 Aug 2025 15:53:16 +1000 Subject: [PATCH 05/12] bugs in warthog.cmake --- cmake/warthog.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cmake/warthog.cmake b/cmake/warthog.cmake index 9642ceb..1625b57 100644 --- a/cmake/warthog.cmake +++ b/cmake/warthog.cmake @@ -11,14 +11,14 @@ include(FetchContent) set(WARTHOG_SUBMODULE_ROOT_ONLY ON CACHE BOOL "add submodule if present only allowed for root project") function(warthog_top_level) -set(_warthog_is_top OFF) +set(_is_top OFF) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.21) if(${PROJECT_IS_TOP_LEVEL}) - set(_warthog_is_top ON) + set(_is_top ON) endif() else() if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) - set(_warthog_is_top ON) + set(_is_top ON) endif() endif() set(_warthog_is_top ${_is_top} PARENT_SCOPE) @@ -37,21 +37,23 @@ get_property(_submodule_added GLOBAL PROPERTY WARTHOG_${submodule} SET) if(${_submodule_added}) # submodule already added return() endif() -if(${ARGC} GREATER 1 AND ${ARGV1}) - set(is_top_level TRUE) +if((${ARGC} GREATER 1) AND (${ARGV1})) + set(is_top_level ON) else() warthog_top_level() - set(is_top_level _warthog_is_top) + set(is_top_level ${_warthog_is_top}) endif() if(${is_top_level}) + message("hello") + message("${PROJECT_SOURCE_DIR}/extern/${submodule}/CMakeLists.txt") if(EXISTS "${PROJECT_SOURCE_DIR}/extern/${submodule}/CMakeLists.txt") # submodule or subtree, include and exit add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${submodule}") - set_property(GLOBAL PROPERTY WARTHOG_${submodule}) + set_property(GLOBAL PROPERTY WARTHOG_${submodule} 1) return() endif() endif() # failed to add submodule, fetch if able FetchContent_MakeAvailable(${submodule}) -set_property(GLOBAL PROPERTY WARTHOG_${submodule}) +set_property(GLOBAL PROPERTY WARTHOG_${submodule} 1) endfunction() From 10f405600b513531c5b2fd44d48f851ee2b9bd3c Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Thu, 21 Aug 2025 16:18:33 +1000 Subject: [PATCH 06/12] update readme --- README.md | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1860857..ef34b00 100644 --- a/README.md +++ b/README.md @@ -23,24 +23,38 @@ Requires `warthog-core` as a dependency. # Using warthog It is recommended to use warthog not as a fork, but included in an external repo. -This can be setup with either a submodule (can't be modified unless forked submodule) -or subtree. +This setup support FetchContent, git submodule and git subtree. -Helper functions from `/cmake/warthog.cmake`, calling `warthog_submodule(warthog-core)` will -add `warthog-core` using the command `add_subdirectory(extern/warthog-core EXCLUDE_FROM_ALL)`, -but only if called by the root project (can be overridden with `WARTHOG_SUBMODULE_ROOT_ONLY`). -This means that all warthog dependencies should be added by the root project using the -`warthog_submodule`, and placed in `/extern/` using either submodules or subtrees. +File `/cmake/warthog.cmake` from warthog core should be copied to user repo and `include` in CMake. +Calling `warthog_submodule(warthog-core)` will then add `warthog-core` to your CMake in the following order: +1. `add_subdirectory(/extern/warthog-core)` if `/extern/warthog-core/CMakeLists.txt` exists (submodule/subtree) +2. `FetchContent_MakeAvailable(warthog-core)` otherwise +3. Error if user did not declare `warthog-core` content + +The `warthog_submodule` call only adds a module once, the following calls will be ignored. +The submodule/subtree version only works if called in the top level project by default; +if this method is preferred, then it should be added to the top level `/extern/`, can be overridden +with code `warthog_submodule(warthog-core ON)`. + +Declare of warthog-core can be done using the following code: +``` +FetchContent_Declare(warthog-core + GIT_REPOSITORY https://github.com/ShortestPathLab/warthog-core.git + GIT_TAG main) +``` +This will fetch the most up-to-date release of warthog-core. +Change GIT_TAG to a tag/commit to select use a specific version of warthog-core. ## CMake -Basic repo example from creation is below: +Setup a basic project using the following the commands: + git init git remote add warthog-core https://github.com/ShortestPathLab/warthog-core.git git fetch warthog-core git checkout warthog-core/main cmake/warthog.cmake -Use this base CMake file `CMakeLists.txt` +Example `CMakeLists.txt`: ``` cmake_minimum_required(VERSION 3.13) @@ -52,7 +66,12 @@ project(App set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) -# warthog submodules +# warthog modules +include(cmake/warthog.cmake) + +FetchContent_Declare(warthog-core + GIT_REPOSITORY https://github.com/ShortestPathLab/warthog-core.git + GIT_TAG main) warthog_submodule(warthog-core) add_executable(app main.cpp) @@ -61,9 +80,6 @@ target_link_libraries(app PUBLIC warthog::core) ## Submodule -Submodule dependencies are useful for avoiding diamond dependencies, -i.e. ensuring there is only a single copy of warthog-core in use. - Commands for adding submodules for each repo are found below: git submodule add https://github.com/ShortestPathLab/warthog-core.git extern/warthog-core From ddab1de5bb4050cdf87ea9cadda950adb2e68526 Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Tue, 26 Aug 2025 12:36:23 +1000 Subject: [PATCH 07/12] removed debug messages --- cmake/warthog.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/warthog.cmake b/cmake/warthog.cmake index 1625b57..3adb6e5 100644 --- a/cmake/warthog.cmake +++ b/cmake/warthog.cmake @@ -44,8 +44,6 @@ else() set(is_top_level ${_warthog_is_top}) endif() if(${is_top_level}) - message("hello") - message("${PROJECT_SOURCE_DIR}/extern/${submodule}/CMakeLists.txt") if(EXISTS "${PROJECT_SOURCE_DIR}/extern/${submodule}/CMakeLists.txt") # submodule or subtree, include and exit add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${submodule}") From 5629ee27150dc1e1ef2c69d3dabe241990703a49 Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Tue, 26 Aug 2025 15:47:36 +1000 Subject: [PATCH 08/12] added default FetchContent_Declare --- CMakeLists.txt | 2 ++ README.md | 28 +++++++++++++---------- cmake/warthog.cmake | 55 ++++++++++++++++++++++++++++++--------------- 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d3927c..2814b58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(Warthog VERSION 0.5.0 LANGUAGES CXX C) +set_property(GLOBAL PROPERTY WARTHOG_${module} ON) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) diff --git a/README.md b/README.md index ef34b00..4915135 100644 --- a/README.md +++ b/README.md @@ -28,22 +28,28 @@ This setup support FetchContent, git submodule and git subtree. File `/cmake/warthog.cmake` from warthog core should be copied to user repo and `include` in CMake. Calling `warthog_submodule(warthog-core)` will then add `warthog-core` to your CMake in the following order: 1. `add_subdirectory(/extern/warthog-core)` if `/extern/warthog-core/CMakeLists.txt` exists (submodule/subtree) -2. `FetchContent_MakeAvailable(warthog-core)` otherwise -3. Error if user did not declare `warthog-core` content +2. `FetchContent_Declare` then `FetchContent_MakeAvailable(warthog-core)` otherwise +3. Error if cannot find `warthog-core` content -The `warthog_submodule` call only adds a module once, the following calls will be ignored. +The `warthog_module` call only adds a module once, the following calls will be ignored. The submodule/subtree version only works if called in the top level project by default; if this method is preferred, then it should be added to the top level `/extern/`, can be overridden -with code `warthog_submodule(warthog-core ON)`. +with code `warthog_module(warthog-core ON)`. Declare of warthog-core can be done using the following code: ``` +warthog_module_declare(warthog-core [main|branch|tag|commit]) +``` +or: +``` FetchContent_Declare(warthog-core GIT_REPOSITORY https://github.com/ShortestPathLab/warthog-core.git - GIT_TAG main) + GIT_TAG [main|branch|tag|commit]) ``` -This will fetch the most up-to-date release of warthog-core. -Change GIT_TAG to a tag/commit to select use a specific version of warthog-core. +This will declare what warthog-core version to fetched. +The `warthog_module_declare` version makes it simple, although it only supports known warthog libraries. +The optional second parameter sets the version to pull, by default is `main` branch. +This system only support warthog 0.5 or greater. ## CMake @@ -69,10 +75,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE) # warthog modules include(cmake/warthog.cmake) -FetchContent_Declare(warthog-core - GIT_REPOSITORY https://github.com/ShortestPathLab/warthog-core.git - GIT_TAG main) -warthog_submodule(warthog-core) +warthog_module_declare(warthog-core v0.5) # is optional, remove for default of main +warthog_module(warthog-core) add_executable(app main.cpp) target_link_libraries(app PUBLIC warthog::core) @@ -80,7 +84,7 @@ target_link_libraries(app PUBLIC warthog::core) ## Submodule -Commands for adding submodules for each repo are found below: +Commands for adding a module as a submodules for each repo are found below: git submodule add https://github.com/ShortestPathLab/warthog-core.git extern/warthog-core git submodule add https://github.com/ShortestPathLab/warthog-jps.git extern/warthog-jps diff --git a/cmake/warthog.cmake b/cmake/warthog.cmake index 3adb6e5..0ccf8e1 100644 --- a/cmake/warthog.cmake +++ b/cmake/warthog.cmake @@ -2,13 +2,17 @@ cmake_minimum_required(VERSION 3.13) # include this file to check submodule include -if(COMMAND warthog_submodule) +# set here as only +set(warthog_https_warthog-core "https://github.com/ShortestPathLab/warthog-core.git" CACHE INTERNAL "") +set(warthog_https_warthog-jps "https://github.com/ShortestPathLab/warthog-jps.git" CACHE INTERNAL "") + +if(COMMAND warthog_module) return() # do not redefine endif() include(FetchContent) -set(WARTHOG_SUBMODULE_ROOT_ONLY ON CACHE BOOL "add submodule if present only allowed for root project") +set(WARTHOG_MODULE_ROOT_ONLY ON CACHE BOOL "add submodule if present only allowed for root project") function(warthog_top_level) set(_is_top OFF) @@ -24,17 +28,17 @@ endif() set(_warthog_is_top ${_is_top} PARENT_SCOPE) endfunction() -# warthog_submodule submodule [override_top] -# adds a submodule to warthog -# has checks to insure submodule is only added once +# warthog_module module [override_top] +# adds a module to warthog +# has checks to insure module is only added once # if called from the top level project (or optional variable override_top is true) -# then if extern/${submodule}/CMakeLists.txt exists, adds that version instead -# intended for use with git submodule/subtree. -# otherwise, fetchcontent ${submodule} is made available +# then if extern/${module}/CMakeLists.txt exists, adds that version instead +# intended for use with git module/subtree. +# otherwise, fetchcontent ${module} is made available # user must add FetchContent_Declare -function(warthog_submodule submodule) -get_property(_submodule_added GLOBAL PROPERTY WARTHOG_${submodule} SET) -if(${_submodule_added}) # submodule already added +function(warthog_module module) +get_property(_module_added GLOBAL PROPERTY WARTHOG_${module} SET) +if(${_module_added}) # module already added return() endif() if((${ARGC} GREATER 1) AND (${ARGV1})) @@ -44,14 +48,29 @@ else() set(is_top_level ${_warthog_is_top}) endif() if(${is_top_level}) - if(EXISTS "${PROJECT_SOURCE_DIR}/extern/${submodule}/CMakeLists.txt") - # submodule or subtree, include and exit - add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${submodule}") - set_property(GLOBAL PROPERTY WARTHOG_${submodule} 1) + if(EXISTS "${PROJECT_SOURCE_DIR}/extern/${module}/CMakeLists.txt") + # module or subtree, include and exit + add_subdirectory("${PROJECT_SOURCE_DIR}/extern/${module}") + set_property(GLOBAL PROPERTY WARTHOG_${module} ON) return() endif() endif() -# failed to add submodule, fetch if able -FetchContent_MakeAvailable(${submodule}) -set_property(GLOBAL PROPERTY WARTHOG_${submodule} 1) +# failed to add module, fetch if able +warthog_module_declare(${module}) +FetchContent_MakeAvailable(${module}) +set_property(GLOBAL PROPERTY WARTHOG_${module} ON) +endfunction() + +function(warthog_module_declare module) +if(NOT DEFINED warthog_https_${module}) + return() +endif() +if((${ARGC} GREATER 1) AND (${ARGV1})) + set(git_tag ${ARGV1}) +else() + set(git_tag "main") +endif() +FetchContent_Declare(${module} + GIT_REPOSITORY warthog_https_${module} + GIT_TAG ${git_tag}) endfunction() From 32c76c7687c67d79521f1f889edf16c8907f8f92 Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Tue, 26 Aug 2025 15:51:53 +1000 Subject: [PATCH 09/12] updated example version number --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4915135..96c91d9 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE) # warthog modules include(cmake/warthog.cmake) -warthog_module_declare(warthog-core v0.5) # is optional, remove for default of main +warthog_module_declare(warthog-core v0.5.0) # is optional, remove for default of main warthog_module(warthog-core) add_executable(app main.cpp) From bc33395dcba8780d5c9dcd9e139fd55a7cfefc6e Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Tue, 26 Aug 2025 16:01:56 +1000 Subject: [PATCH 10/12] module tag bugfix --- cmake/warthog.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/warthog.cmake b/cmake/warthog.cmake index 0ccf8e1..635f050 100644 --- a/cmake/warthog.cmake +++ b/cmake/warthog.cmake @@ -65,12 +65,12 @@ function(warthog_module_declare module) if(NOT DEFINED warthog_https_${module}) return() endif() -if((${ARGC} GREATER 1) AND (${ARGV1})) +if((${ARGC} GREATER 1)) set(git_tag ${ARGV1}) else() set(git_tag "main") endif() FetchContent_Declare(${module} - GIT_REPOSITORY warthog_https_${module} + GIT_REPOSITORY ${warthog_https_${module}} GIT_TAG ${git_tag}) endfunction() From 7fcdeaac65fde82c84ae6d3db3076045e0ef20ca Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Tue, 26 Aug 2025 21:36:51 +1000 Subject: [PATCH 11/12] fixed module name --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2814b58..a564afe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(Warthog VERSION 0.5.0 LANGUAGES CXX C) -set_property(GLOBAL PROPERTY WARTHOG_${module} ON) +set_property(GLOBAL PROPERTY WARTHOG_warthog-core ON) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) From 1042dcfb6b89b814d7b097bee3ee064c3dfecec4 Mon Sep 17 00:00:00 2001 From: Ryan Hechenberger Date: Tue, 26 Aug 2025 21:55:44 +1000 Subject: [PATCH 12/12] moved details down --- README.md | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 96c91d9..0179bcc 100644 --- a/README.md +++ b/README.md @@ -25,32 +25,6 @@ Requires `warthog-core` as a dependency. It is recommended to use warthog not as a fork, but included in an external repo. This setup support FetchContent, git submodule and git subtree. -File `/cmake/warthog.cmake` from warthog core should be copied to user repo and `include` in CMake. -Calling `warthog_submodule(warthog-core)` will then add `warthog-core` to your CMake in the following order: -1. `add_subdirectory(/extern/warthog-core)` if `/extern/warthog-core/CMakeLists.txt` exists (submodule/subtree) -2. `FetchContent_Declare` then `FetchContent_MakeAvailable(warthog-core)` otherwise -3. Error if cannot find `warthog-core` content - -The `warthog_module` call only adds a module once, the following calls will be ignored. -The submodule/subtree version only works if called in the top level project by default; -if this method is preferred, then it should be added to the top level `/extern/`, can be overridden -with code `warthog_module(warthog-core ON)`. - -Declare of warthog-core can be done using the following code: -``` -warthog_module_declare(warthog-core [main|branch|tag|commit]) -``` -or: -``` -FetchContent_Declare(warthog-core - GIT_REPOSITORY https://github.com/ShortestPathLab/warthog-core.git - GIT_TAG [main|branch|tag|commit]) -``` -This will declare what warthog-core version to fetched. -The `warthog_module_declare` version makes it simple, although it only supports known warthog libraries. -The optional second parameter sets the version to pull, by default is `main` branch. -This system only support warthog 0.5 or greater. - ## CMake Setup a basic project using the following the commands: @@ -119,6 +93,34 @@ The update commands: git subtree -P extern/warthog-core pull https://github.com/ShortestPathLab/warthog-core.git main|branch|commit --squash git subtree -P extern/warthog-jps pull https://github.com/ShortestPathLab/warthog-jps.git main|branch|commit --squash +## Advance Module Details + +File `/cmake/warthog.cmake` from warthog core should be copied to user repo and `include` in CMake. +Calling `warthog_submodule(warthog-core)` will then add `warthog-core` to your CMake in the following order: +1. `add_subdirectory(/extern/warthog-core)` if `/extern/warthog-core/CMakeLists.txt` exists (submodule/subtree) +2. `FetchContent_Declare` then `FetchContent_MakeAvailable(warthog-core)` otherwise +3. Error if cannot find `warthog-core` content + +The `warthog_module` call only adds a module once, the following calls will be ignored. +The submodule/subtree version only works if called in the top level project by default; +if this method is preferred, then it should be added to the top level `/extern/`, can be overridden +with code `warthog_module(warthog-core ON)`. + +Declare of warthog-core can be done using the following code: +``` +warthog_module_declare(warthog-core [main|branch|tag|commit]) +``` +or: +``` +FetchContent_Declare(warthog-core + GIT_REPOSITORY https://github.com/ShortestPathLab/warthog-core.git + GIT_TAG [main|branch|tag|commit]) +``` +This will declare what warthog-core version to fetched. +The `warthog_module_declare` version makes it simple, although it only supports known warthog libraries. +The optional second parameter sets the version to pull, by default is `main` branch. +This system only support warthog 0.5 or greater. + # Resources - [Moving AI Lab](https://movingai.com/): pathfinding benchmark and tools