Skip to content

Commit 11ebd1e

Browse files
committed
rework deps population using CMake fetch_content module
1 parent f90959c commit 11ebd1e

15 files changed

+72
-71
lines changed

.gitmodules

Lines changed: 0 additions & 24 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
cmake_minimum_required(VERSION 3.23.0)
22
project(Jinja2Cpp VERSION 1.3.0)
33

4-
if (${CMAKE_VERSION} VERSION_GREATER "3.12")
5-
cmake_policy(SET CMP0074 OLD)
6-
endif ()
7-
84
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
95
set(JINJA2CPP_IS_MAIN_PROJECT TRUE)
106
else()

thirdparty/CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,39 @@ endfunction()
4646
include (./thirdparty/thirdparty-${JINJA2CPP_DEPS_MODE}.cmake)
4747

4848
if(JINJA2CPP_BUILD_TESTS)
49-
find_package(gtest QUIET)
49+
find_package(GTest QUIET)
5050

5151
if(gtest_FOUND)
5252
imported_target_alias(gtest ALIAS gtest::gtest)
5353
else()
54-
message(STATUS "gtest not found, using submodule")
55-
update_submodule(gtest)
56-
54+
message(STATUS "gtest not found, building own one")
5755
if(MSVC)
5856
if (THIRDPARTY_RUNTIME_TYPE STREQUAL "/MD" OR THIRDPARTY_RUNTIME_TYPE STREQUAL "/MDd")
5957
set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
6058
else ()
6159
set (gtest_force_shared_crt OFF CACHE BOOL "" FORCE)
6260
endif ()
6361
endif ()
64-
65-
add_subdirectory(thirdparty/gtest EXCLUDE_FROM_ALL)
62+
FetchContent_Declare(
63+
googletest
64+
GIT_REPOSITORY https://github.com/google/googletest.git
65+
GIT_TAG main
66+
)
67+
FetchContent_MakeAvailable(googletest)
6668
endif()
6769
endif()
6870

6971
if (NOT DEFINED JINJA2_PRIVATE_LIBS_INT)
70-
set(JINJA2CPP_PRIVATE_LIBS ${JINJA2CPP_PRIVATE_LIBS} Boost::variant
71-
Boost::filesystem Boost::algorithm Boost::lexical_cast Boost::json Boost::regex fmt RapidJson)
72+
set(JINJA2CPP_PRIVATE_LIBS ${JINJA2CPP_PRIVATE_LIBS}
73+
Boost::variant Boost::filesystem Boost::algorithm Boost::lexical_cast Boost::json
74+
Boost::regex fmt RapidJson)
7275
else ()
7376
set (JINJA2CPP_PRIVATE_LIBS ${JINJA2_PRIVATE_LIBS_INT})
7477
endif ()
7578

7679
if (NOT DEFINED JINJA2_PUBLIC_LIBS_INT)
77-
set (JINJA2CPP_PUBLIC_LIBS ${JINJA2CPP_PUBLIC_LIBS} expected-lite variant-lite optional-lite string-view-lite)
80+
set (JINJA2CPP_PUBLIC_LIBS ${JINJA2CPP_PUBLIC_LIBS}
81+
expected-lite variant-lite optional-lite string-view-lite)
7882
else ()
7983
set (JINJA2CPP_PUBLIC_LIBS ${JINJA2_PUBLIC_LIBS_INT})
8084
endif ()

thirdparty/fmtlib

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/gtest

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/internal_deps.cmake

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,72 @@
1-
update_submodule(nonstd/expected-lite)
2-
add_subdirectory(thirdparty/nonstd/expected-lite EXCLUDE_FROM_ALL)
1+
include(FetchContent)
32

4-
update_submodule(nonstd/variant-lite)
5-
add_subdirectory(thirdparty/nonstd/variant-lite EXCLUDE_FROM_ALL)
3+
FetchContent_Declare(
4+
expected-lite
5+
GIT_REPOSITORY https://github.com/martinmoene/expected-lite.git
6+
GIT_TAG master
7+
)
8+
FetchContent_MakeAvailable(expected-lite)
69

7-
update_submodule(nonstd/optional-lite)
8-
add_subdirectory(thirdparty/nonstd/optional-lite EXCLUDE_FROM_ALL)
10+
FetchContent_Declare(
11+
variant-lite
12+
GIT_REPOSITORY https://github.com/martinmoene/variant-lite.git
13+
GIT_TAG master
14+
)
15+
FetchContent_MakeAvailable(variant-lite)
916

10-
update_submodule(nonstd/string-view-lite)
11-
add_subdirectory(thirdparty/nonstd/string-view-lite EXCLUDE_FROM_ALL)
17+
FetchContent_Declare(
18+
optional-lite
19+
GIT_REPOSITORY https://github.com/martinmoene/optional-lite.git
20+
GIT_TAG master
21+
)
22+
FetchContent_MakeAvailable(optional-lite)
23+
24+
FetchContent_Declare(
25+
string-view-lite
26+
GIT_REPOSITORY https://github.com/martinmoene/string-view-lite.git
27+
GIT_TAG master
28+
)
29+
FetchContent_MakeAvailable(string-view-lite)
1230

13-
update_submodule(fmtlib)
1431
set (FMT_INSTALL ON CACHE BOOL "" FORCE)
15-
add_subdirectory(thirdparty/fmtlib EXCLUDE_FROM_ALL)
32+
FetchContent_Declare(
33+
fmt
34+
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
35+
GIT_TAG 10.1.1
36+
)
37+
FetchContent_MakeAvailable(fmt)
1638

17-
update_submodule(json/rapid)
1839
set (RAPIDJSON_BUILD_DOC OFF CACHE BOOL "" FORCE)
1940
set (RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
2041
set (RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
2142
set (RAPIDJSON_BUILD_THIRDPARTY_GTEST OFF CACHE BOOL "" FORCE)
2243
set (RAPIDJSON_ENABLE_INSTRUMENTATION_OPT OFF CACHE BOOL "" FORCE)
23-
add_subdirectory(thirdparty/json/rapid EXCLUDE_FROM_ALL)
24-
find_package(RapidJSON)
44+
45+
FetchContent_Declare(
46+
rapidjson
47+
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
48+
GIT_TAG 973dc9c06dcd3d035ebd039cfb9ea457721ec213
49+
)
50+
# GIT_TAG f9d53419e912910fd8fa57d5705fa41425428c35 - latest but broken revision
51+
FetchContent_MakeAvailable(rapidjson)
52+
find_package(RapidJSON REQUIRED)
2553
add_library(RapidJson INTERFACE)
2654
target_include_directories(RapidJson
2755
INTERFACE
2856
$<BUILD_INTERFACE:${RapidJSON_INCLUDE_DIR}>
2957
$<INSTALL_INTERFACE:include>
30-
)
31-
58+
)
3259
if (JINJA2CPP_BUILD_TESTS)
33-
update_submodule(json/nlohmann)
3460
set (JSON_BuildTests OFF CACHE BOOL "" FORCE)
3561
set (JSON_Install OFF CACHE BOOL "" FORCE)
3662
set (JSON_MultipleHeaders ON CACHE BOOL "" FORCE)
37-
add_subdirectory(thirdparty/json/nlohmann EXCLUDE_FROM_ALL)
63+
64+
FetchContent_Declare(
65+
nlohmann_json
66+
GIT_REPOSITORY https://github.com/nlohmann/json.git
67+
GIT_TAG develop
68+
)
69+
FetchContent_MakeAvailable(nlohmann_json)
3870
endif()
3971

4072
install (FILES
@@ -49,4 +81,4 @@ install (TARGETS RapidJson
4981
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
5082
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
5183
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
52-
)
84+
)

thirdparty/json/nlohmann

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/json/rapid

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/nonstd/expected-lite

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/nonstd/optional-lite

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/nonstd/string-view-lite

Lines changed: 0 additions & 1 deletion
This file was deleted.

thirdparty/nonstd/variant-lite

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
message(STATUS "'external-boost' dependencies mode selected for Jinja2Cpp. All dependencies are used as submodules except of boost")
1+
message(STATUS "'external-boost' dependencies mode selected for Jinja2Cpp. All
2+
dependencies are built from source pulled from github except of boost")
23

34
include (./thirdparty/internal_deps.cmake)
45
include (./thirdparty/external_boost_deps.cmake)

thirdparty/thirdparty-external.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ target_include_directories(RapidJson
4747
$<BUILD_INTERFACE:${RapidJSON_INCLUDE_DIR}>
4848
$<INSTALL_INTERFACE:include>
4949
)
50-
50+
5151
if (TARGET fmt-header-only)
5252
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
5353
add_library(fmt ALIAS fmt-header-only)
@@ -74,5 +74,5 @@ install(TARGETS RapidJson
7474
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
7575
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
7676
)
77-
77+
7878
include (./thirdparty/external_boost_deps.cmake)

thirdparty/thirdparty-internal.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
message(STATUS "'internal' dependencies mode selected for Jinja2Cpp. All dependencies are used as submodules")
1+
message(STATUS "'internal' dependencies mode selected for Jinja2Cpp. All dependencies will be built from source pulled from github")
22

33
include (./thirdparty/internal_deps.cmake)
44

@@ -17,10 +17,10 @@ list(APPEND BOOST_INCLUDE_LIBRARIES
1717

1818
include(FetchContent)
1919
FetchContent_Declare(
20-
Boost
21-
GIT_REPOSITORY https://github.com/boostorg/boost.git
22-
GIT_TAG boost-1.83.0
23-
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../cmake/patches/0001-fix-skip-install-rules.patch" || true
20+
Boost
21+
GIT_REPOSITORY https://github.com/boostorg/boost.git
22+
GIT_TAG boost-1.83.0
23+
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../cmake/patches/0001-fix-skip-install-rules.patch" || true
2424
)
2525
FetchContent_MakeAvailable(Boost)
2626

0 commit comments

Comments
 (0)