forked from boostorg/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
106 lines (83 loc) · 3.77 KB
/
CMakeLists.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright (C) 2024 T. Zachary Laine
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Generated by `boostdep --cmake parser`
cmake_minimum_required(VERSION 3.14...3.20)
project(boost_parser VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_parser INTERFACE)
add_library(Boost::parser ALIAS boost_parser)
target_include_directories(boost_parser INTERFACE include)
target_link_libraries(boost_parser
INTERFACE
Boost::assert
Boost::hana
Boost::type_index
)
else()
cmake_minimum_required(VERSION 3.14...3.20)
project(parse)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
##################################################
# C++ standard version selection
##################################################
set(CXX_STD 17 CACHE STRING "Set to 14, 17, etc., to enable C++14, C++17, etc.")
message("-- Using -std=c++${CXX_STD}")
# to just check the different frontend flavours we could use the following code
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
get_filename_component(CNAME "${CMAKE_CXX_COMPILER}" NAME)
message(STATUS "Detected MSVC style compiler frontend '" ${CNAME} "'")
add_definitions(/W3)
add_compile_options(/Zc:__cplusplus) # not sure, if it necessary for clang-cl
elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
get_filename_component(CNAME "${CMAKE_CXX_COMPILER}" NAME)
message(STATUS "Detected GNU style compiler frontend '" ${CNAME} "'")
add_definitions(-Wall)
endif ()
# alternatively the boolean variable 'MSVC' is equivalent to 'if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")'
# summary for a more detailed analysis (https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-that-provide-information):
# CMAKE_CXX_COMPILER_ID: Clang, GNU, MSVC
# CMAKE_CXX_COMPILER_FRONTEND_VARIANT: GNU, MSVC
# CMAKE_CXX_SIMULATE_ID: MSVC (for Microsoft clang and clang-cl as they use the MSVC runtime)
# CMAKE_CXX_PLATFORM_ID: Windows, Darwin, MinGW, MSYS, Linux, UNIX, ...
# Variables that describe the system (https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-that-describe-the-system)
##################################################
# Build config
##################################################
set(BUILD_WITH_HANA false CACHE BOOL
"Build with optional Hana support (and BOOST_PARSER_USE_HANA_TUPLE defined).")
if (BUILD_WITH_HANA)
add_definitions(-DBOOST_PARSER_USE_HANA_TUPLE)
endif()
##################################################
# Dependencies
##################################################
include(dependencies)
##################################################
# Sanitizers
##################################################
set(USE_ASAN false CACHE BOOL "Set to true to enable -fsanitize=address when building tests.")
set(USE_UBSAN false CACHE BOOL "Set to true to enable -fsanitize=undefined when building tests.")
if (USE_ASAN AND USE_UBSAN)
message(FATAL_ERROR "USE_ASAN and USE_UBSAN must not be enabled at the same time")
elseif (USE_ASAN)
set(compile_flags -fsanitize=address)
set(link_flags -fsanitize=address)
elseif (USE_UBSAN)
set(compile_flags -fsanitize=undefined)
set(link_flags -fsanitize=undefined)
endif()
##################################################
# Parser
##################################################
add_library(parser INTERFACE)
target_include_directories(parser INTERFACE ${CMAKE_SOURCE_DIR}/include)
if (Boost_FOUND)
target_include_directories(parser INTERFACE ${Boost_INCLUDE_DIRS})
endif()
##################################################
# Subdirectories
##################################################
add_subdirectory(test)
add_subdirectory(example)
endif()