|
1 | | -cmake_minimum_required(VERSION 3.0) |
2 | 1 |
|
3 | | -project (thirdparty) |
4 | | -list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) |
| 2 | +find_package(expected-lite QUIET) |
| 3 | +if(expected-lite_FOUND) |
| 4 | + add_library(expected-lite ALIAS expected-lite::expected-lite) |
| 5 | +else() |
| 6 | + message(STATUS "expected-lite not found, using submodule") |
| 7 | + add_subdirectory(nonstd/expected-light EXCLUDE_FROM_ALL) |
| 8 | +endif() |
5 | 9 |
|
6 | | -include (build_thirdparty) |
| 10 | +find_package(variant-lite QUIET) |
| 11 | +if(variant-lite_FOUND) |
| 12 | + add_library(variant-lite ALIAS variant-lite::variant-lite) |
| 13 | +else() |
| 14 | + message(STATUS "variant-lite not found, using submodule") |
| 15 | + add_subdirectory(nonstd/variant-light EXCLUDE_FROM_ALL) |
| 16 | + # There's a bug in the lib, the target does not include the header include dirs. |
| 17 | + # See https://github.com/martinmoene/variant-lite/issues/25 |
| 18 | + target_include_directories(variant-lite INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/nonstd/variant-light/include") |
| 19 | +endif() |
7 | 20 |
|
8 | | -if (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") |
9 | | - if (MSVC_RUNTIME_TYPE STREQUAL "/MD" OR NOT MSVC_RUNTIME_TYPE) |
10 | | - set (GTEST_EXTRA_OPTIONS "-Dgtest_force_shared_crt=TRUE") |
11 | | - else () |
12 | | - set (GTEST_EXTRA_OPTIONS "-Dgtest_force_shared_crt=TRUE") |
13 | | - endif () |
14 | | -endif () |
| 21 | +find_package(value-ptr-lite QUIET) |
| 22 | +if(value-ptr-lite_FOUND) |
| 23 | + add_library(value-ptr-lite ALIAS value-ptr-lite::value-ptr-lite) |
| 24 | +else() |
| 25 | + message(STATUS "value-ptr-lite not found, using submodule") |
| 26 | + add_subdirectory(nonstd/value-ptr-lite EXCLUDE_FROM_ALL) |
| 27 | + add_library(value-ptr-lite ALIAS value_ptr-lite) |
| 28 | +endif() |
15 | 29 |
|
16 | | -BuildThirdparty(gtest ${CMAKE_CURRENT_SOURCE_DIR}/gtest include/gmock/gmock.h "${GTEST_EXTRA_OPTIONS}") |
17 | | -add_subdirectory (nonstd) |
| 30 | +find_package(boost_filesystem QUIET) |
| 31 | +find_package(boost_algorithm QUIET) |
| 32 | +find_package(boost_variant QUIET) |
| 33 | +find_package(boost_optional QUIET) |
| 34 | + |
| 35 | +if(boost_filesystem_FOUND AND |
| 36 | + boost_algorithm_FOUND AND |
| 37 | + boost_variant_FOUND AND |
| 38 | + boost_optional_FOUND) |
| 39 | + add_library(boost_filesystem ALIAS boost_filesystem::boost_filesystem) |
| 40 | + add_library(boost_algorithm ALIAS boost_algorithm::boost_algorithm) |
| 41 | + add_library(boost_variant ALIAS boost_variant::boost_variant) |
| 42 | + add_library(boost_optional ALIAS boost_optional::boost_optional) |
| 43 | +else() |
| 44 | + message(STATUS "One or more boost modules not found, using submodule") |
| 45 | + set(BOOST_CMAKE_LIBRARIES filesystem algorithm variant optional CACHE INTERNAL "") |
| 46 | + add_subdirectory(boost EXCLUDE_FROM_ALL) |
| 47 | + |
| 48 | + if(NOT MSVC) |
| 49 | + # Enable -Werror and -Wall on jinja2cpp target, ignoring warning errors from thirdparty libs |
| 50 | + include(CheckCXXCompilerFlag) |
| 51 | + check_cxx_compiler_flag(-Wno-error=parentheses COMPILER_HAS_WNO_ERROR_PARENTHESES_FLAG) |
| 52 | + check_cxx_compiler_flag(-Wno-error=deprecated-declarations COMPILER_HAS_WNO_ERROR_DEPRECATED_DECLARATIONS_FLAG) |
| 53 | + check_cxx_compiler_flag(-Wno-error=maybe-uninitialized COMPILER_HAS_WNO_ERROR_MAYBE_UNINITIALIZED_FLAG) |
| 54 | + |
| 55 | + if(COMPILER_HAS_WNO_ERROR_PARENTHESES_FLAG) |
| 56 | + target_compile_options(boost_assert INTERFACE -Wno-error=parentheses) |
| 57 | + endif() |
| 58 | + if(COMPILER_HAS_WNO_ERROR_DEPRECATED_DECLARATIONS_FLAG) |
| 59 | + target_compile_options(boost_filesystem PRIVATE -Wno-error=deprecated-declarations) |
| 60 | + endif() |
| 61 | + if(COMPILER_HAS_WNO_ERROR_MAYBE_UNINITIALIZED_FLAG) |
| 62 | + target_compile_options(boost_variant INTERFACE -Wno-error=maybe-uninitialized) |
| 63 | + endif() |
| 64 | + endif() |
| 65 | +endif() |
| 66 | + |
| 67 | +if(JINJA2CPP_BUILD_TESTS) |
| 68 | + find_package(gtest QUIET) |
| 69 | + |
| 70 | + if(gtest_FOUND) |
| 71 | + add_library(gtest ALIAS gtest::gtest) |
| 72 | + else() |
| 73 | + message(STATUS "expected-lite not found, using submodule") |
| 74 | + |
| 75 | + if(MSVC) |
| 76 | + if (MSVC_RUNTIME_TYPE STREQUAL "/MD" OR NOT MSVC_RUNTIME_TYPE) |
| 77 | + set (GTEST_EXTRA_OPTIONS "-Dgtest_force_shared_crt=TRUE" CACHE INTERNAL "") |
| 78 | + else () |
| 79 | + set (GTEST_EXTRA_OPTIONS "-Dgtest_force_shared_crt=TRUE" CACHE INTERNAL "") |
| 80 | + endif () |
| 81 | + endif () |
| 82 | + |
| 83 | + add_subdirectory(gtest EXCLUDE_FROM_ALL) |
| 84 | + endif() |
| 85 | +endif() |
0 commit comments