Skip to content

Commit 63b8951

Browse files
Manu343726manusharded
authored andcommitted
Use boost-cmake from github for the boost dependency
1 parent 6cd8e31 commit 63b8951

File tree

3 files changed

+23
-109
lines changed

3 files changed

+23
-109
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
[submodule "thirdparty/nonstd/value-ptr-lite"]
1111
path = thirdparty/nonstd/value-ptr-lite
1212
url = https://github.com/flexferrum/value-ptr-lite.git
13+
[submodule "thirdparty/boost"]
14+
path = thirdparty/boost
15+
url = https://github.com/Manu343726/boost-cmake.git
16+
branch = master

CMakeLists.txt

Lines changed: 18 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,20 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(Jinja2Cpp VERSION 0.5.0)
33

4-
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
4+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
55

6-
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE_ENABLED)
7-
message (STATUS "This is DEBUG build with enabled Code Coverage")
8-
set (CMAKE_BUILD_TYPE Debug)
9-
include(code_coverage)
10-
setup_target_for_coverage(${PROJECT_NAME}_coverage jinja2cpp_tests coverage)
11-
endif()
12-
13-
set(GTEST_ROOT $ENV{GTEST_DIR} CACHE PATH "Path to GTest/GMock library root")
14-
if (NOT UNIX)
15-
set(BOOST_ROOT $ENV{BOOST_DIR} CACHE PATH "Path to boost library root")
16-
set(LIBRARY_TYPE STATIC CACHE PATH "Library link type")
17-
else ()
18-
set(BOOST_ROOT "/usr" CACHE PATH "Path to boost library root")
19-
set(LIBRARY_TYPE SHARED CACHE PATH "Library link type")
20-
endif ()
21-
22-
if (NOT DEFINED WITH_TESTS)
23-
set (WITH_TESTS TRUE)
24-
endif ()
25-
26-
set (EXTRA_TEST_LIBS "")
27-
set (CMAKE_CXX_STANDARD 14)
28-
set (CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_STANDARD 14)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
298
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
309
if (NOT UNIX)
31-
set (EXTRA_TEST_LIBS "stdc++")
3210
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wa,-mbig-obj")
33-
else ()
34-
include(CMakeFindDependencyMacro)
35-
find_dependency(Threads)
36-
set (EXTRA_TEST_LIBS Threads::Threads)
3711
endif ()
3812
else ()
3913
# MSVC
40-
if (NOT DEFINED Boost_USE_STATIC_LIBS)
41-
set (Boost_USE_STATIC_LIBS ON)
42-
endif ()
4314
if (NOT DEFINED MSVC_RUNTIME_TYPE)
4415
set (MSVC_RUNTIME_TYPE "/MD")
4516
endif ()
4617
if (CMAKE_BUILD_TYPE MATCHES "Debug")
47-
message("#######>>>>>>>>>>!!!!!!!!!!!!!! AAAAAAAAAAAAAAAAAAAAAAAAAAAA")
4818
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MSVC_RUNTIME_TYPE}d")
4919
set (Boost_USE_DEBUG_RUNTIME ON)
5020
else ()
@@ -55,104 +25,43 @@ else ()
5525
endif ()
5626
endif()
5727

58-
if("${GTEST_ROOT}" STREQUAL "" AND WITH_TESTS)
59-
set (THIRDPARTY_TARGETS ${THIRDPARTY_TARGETS} gtest)
60-
endif()
28+
set(BOOST_CMAKE_LIBRARIES filesystem algorithm variant optional CACHE INTERNAL "")
29+
add_subdirectory(thirdparty/boost EXCLUDE_FROM_ALL)
30+
add_subdirectory(thirdparty/nonstd EXCLUDE_FROM_ALL)
6131

62-
if(NOT "${BOOST_ROOT}" STREQUAL "")
63-
list (APPEND CMAKE_PREFIX_PATH ${BOOST_ROOT})
64-
set (Boost_DIR ${BOOST_ROOT})
32+
if(CMAKE_SOURCEDIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
33+
set(JINJA2CPP_IS_MAIN_PROEJCT TRUE)
34+
else()
35+
set(JINJA2CPP_IS_MAIN_PROEJCT FALSE)
6536
endif()
6637

67-
make_directory (${CMAKE_CURRENT_BINARY_DIR}/thirdparty)
68-
execute_process (
69-
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
70-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty
71-
RESULT_VARIABLE THIRDPARTY_BUILD_RESULT
72-
)
73-
74-
if (THIRDPARTY_BUILD_RESULT EQUAL 0 AND THIRDPARTY_TARGETS)
75-
execute_process (
76-
COMMAND ${CMAKE_COMMAND} --build . --target ${THIRDPARTY_TARGETS}
77-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty
78-
RESULT_VARIABLE THIRDPARTY_BUILD_RESULT
79-
)
80-
endif ()
81-
82-
if (NOT THIRDPARTY_BUILD_RESULT EQUAL 0)
83-
message (FATAL_ERROR "Can't build thirdparty libraries")
84-
endif ()
85-
86-
if("${GTEST_ROOT}" STREQUAL "" AND WITH_TESTS)
87-
set (GTEST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/gtest/install)
88-
set (GTEST_SELF_BUILD ON)
89-
endif ()
90-
91-
if(NOT "${GTEST_ROOT}" STREQUAL "" AND WITH_TESTS)
92-
list (APPEND CMAKE_PREFIX_PATH ${GTEST_ROOT})
93-
set (Gtest_DIR ${GTEST_ROOT})
94-
message(STATUS "GTest library search path: ${Gtest_DIR}")
95-
if (NOT GTEST_SELF_BUILD)
96-
find_package(GTest)
97-
else ()
98-
set (Gtest_DIR ${GTEST_ROOT})
99-
find_package(GTest)
100-
endif ()
101-
if (NOT GTEST_INCLUDE_DIRS)
102-
if (MSVC AND NOT GTEST_INCLUDE_DIRS)
103-
set (GTEST_MSVC_SEARCH "MT")
104-
find_package(GTest)
105-
else ()
106-
set (GTEST_BOTH_LIBRARIES "optimized;${GTEST_ROOT}/lib/libgtest.a;debug;${GTEST_ROOT}/lib/libgtestd.a;optimized;${GTEST_ROOT}/lib/libgtest_main.a;debug;${GTEST_ROOT}/lib/libgtest_maind.a")
107-
set (GTEST_INCLUDE_DIRS ${GTEST_ROOT}/include)
108-
endif ()
109-
endif ()
110-
endif()
111-
112-
if (WITH_TESTS)
113-
find_package(Boost COMPONENTS system filesystem REQUIRED)
114-
else ()
115-
find_package(Boost)
116-
endif ()
117-
118-
add_subdirectory (thirdparty/nonstd)
38+
option(JINJA2CPP_BUILD_TESTS "Build Jinja2Cpp unit tests" ${JINJA2CPP_IS_MAIN_PROEJCT})
11939

12040
include(collect_sources)
12141

122-
include_directories(
123-
${CMAKE_CURRENT_SOURCE_DIR}/include
124-
)
125-
12642
set (LIB_TARGET_NAME jinja2cpp)
12743

12844
CollectSources(Sources Headers ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src)
12945
CollectSources(PublicSources PublicHeaders ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
13046

131-
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE_ENABLED)
132-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
133-
endif()
134-
13547
add_library(${LIB_TARGET_NAME} STATIC
13648
${Sources}
13749
${Headers}
13850
${PublicHeaders}
13951
)
14052

141-
target_link_libraries(${LIB_TARGET_NAME} PUBLIC ThirdParty::nonstd Boost::boost) # Boost::system Boost::filesystem)
53+
target_link_libraries(${LIB_TARGET_NAME} PUBLIC ThirdParty::nonstd boost_variant boost_filesystem boost_algorithm)
14254

14355
target_include_directories(${LIB_TARGET_NAME}
144-
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
56+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
14557

146-
if (WITH_TESTS)
58+
if (JINJA2CPP_BUILD_TESTS)
14759
enable_testing()
148-
149-
include_directories(
150-
${GTEST_INCLUDE_DIRS}
151-
)
60+
add_subdirectory(thirdparty/gtest)
15261

15362
CollectSources(TestSources TestHeaders ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test)
15463
add_executable(jinja2cpp_tests ${TestSources} ${TestHeaders})
155-
target_link_libraries(jinja2cpp_tests ${GTEST_BOTH_LIBRARIES} ${LIB_TARGET_NAME} ${EXTRA_TEST_LIBS} ${Boost_LIBRARIES})
64+
target_link_libraries(jinja2cpp_tests gtest gtest_main ${LIB_TARGET_NAME} ${EXTRA_TEST_LIBS})
15665

15766
add_custom_command(
15867
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_data/simple_template1.j2tpl
@@ -164,6 +73,8 @@ if (WITH_TESTS)
16473
add_custom_target(CopyTestData ALL
16574
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/test_data/simple_template1.j2tpl
16675
)
76+
77+
add_test(NAME jinja2cpp_tests COMMAND jinja2cpp_tests)
16778
endif ()
16879

16980
install(TARGETS ${LIB_TARGET_NAME}
@@ -176,5 +87,3 @@ install (DIRECTORY thirdparty/nonstd/expected-light/include/ DESTINATION include
17687
install (DIRECTORY thirdparty/nonstd/variant-light/include/ DESTINATION include)
17788
install (DIRECTORY thirdparty/nonstd/value-ptr-light/include/ DESTINATION include)
17889
install (FILES cmake/public/FindJinja2Cpp.cmake DESTINATION cmake)
179-
180-
add_test(NAME jinja2cpp_tests COMMAND jinja2cpp_tests)

thirdparty/boost

Submodule boost added at 83b7a7a

0 commit comments

Comments
 (0)