forked from jinja2cpp/Jinja2Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (74 loc) · 2.89 KB
/
Copy pathCMakeLists.txt
File metadata and controls
84 lines (74 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
if(MSVC)
set (THIRDPARTY_RUNTIME_TYPE ${JINJA2CPP_MSVC_RUNTIME_TYPE})
if ("${THIRDPARTY_RUNTIME_TYPE}" STREQUAL "")
string (FIND "${CURRENT_CXX_FLAGS}" "MT" THIRDPARTY_MT_POS REVERSE)
string (FIND "${CURRENT_CXX_FLAGS}" "MD" THIRDPARTY_MD_POS REVERSE)
if (NOT THIRDPARTY_MT_POS EQUAL -1)
set (THIRDPARTY_RUNTIME_TYPE "/MT")
elseif (NOT THIRDPARTY_MD_POS EQUAL -1)
set (THIRDPARTY_RUNTIME_TYPE "/MD")
else ()
message (STATUS "Dynamic C runtime assumed. Use 'JINJA2CPP_MSVC_RUNTIME_TYPE' variable for override")
set (THIRDPARTY_RUNTIME_TYPE "/MD")
endif()
endif ()
message(STATUS "Selected Jinja2C++ thirdparty libraries runtime type: '${THIRDPARTY_RUNTIME_TYPE}'")
endif ()
function(update_submodule submodule)
find_package(Git REQUIRED)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive thirdparty/${submodule}
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
)
endfunction()
function(imported_target_alias ALIAS)
# For some unknown reason CMake does not support creating alias
# libraries from IMPORTED libraries. This function is an ugly workaround
# to get the same
cmake_parse_arguments("__ALIAS"
""
"ALIAS"
""
${ARGN}
)
if(NOT __ALIAS_ALIAS)
message(FATAL_ERROR "imported_target_alias invoked with wrong arguments, missing ALIAS")
endif()
add_library(${ALIAS} INTERFACE)
target_link_libraries(${ALIAS} INTERFACE ${__ALIAS_ALIAS})
endfunction()
include (./thirdparty/thirdparty-${JINJA2CPP_DEPS_MODE}.cmake)
if(JINJA2CPP_BUILD_TESTS)
find_package(GTest QUIET)
if(gtest_FOUND)
imported_target_alias(gtest ALIAS gtest::gtest)
else()
message(STATUS "gtest not found, building own one")
if(MSVC)
if (THIRDPARTY_RUNTIME_TYPE STREQUAL "/MD" OR THIRDPARTY_RUNTIME_TYPE STREQUAL "/MDd")
set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
else ()
set (gtest_force_shared_crt OFF CACHE BOOL "" FORCE)
endif ()
endif ()
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
FetchContent_MakeAvailable(googletest)
endif()
endif()
if (NOT DEFINED JINJA2_PRIVATE_LIBS_INT)
set(JINJA2CPP_PRIVATE_LIBS ${JINJA2CPP_PRIVATE_LIBS}
Boost::variant Boost::filesystem Boost::algorithm Boost::lexical_cast Boost::json
Boost::regex Boost::numeric_conversion fmt RapidJson)
else ()
set (JINJA2CPP_PRIVATE_LIBS ${JINJA2_PRIVATE_LIBS_INT})
endif ()
if (NOT DEFINED JINJA2_PUBLIC_LIBS_INT)
set (JINJA2CPP_PUBLIC_LIBS ${JINJA2CPP_PUBLIC_LIBS}
expected-lite variant-lite optional-lite string-view-lite)
else ()
set (JINJA2CPP_PUBLIC_LIBS ${JINJA2_PUBLIC_LIBS_INT})
endif ()