forked from standardese/cppast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
57 lines (47 loc) · 1.43 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
# Copyright (C) 2017-2023 Jonathan Müller and cppast contributors
# SPDX-License-Identifier: MIT
# found in the top-level directory of this distribution.
cmake_minimum_required(VERSION 3.11)
project(cppast VERSION 0.1.0)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(is_top_level_project TRUE)
else()
set(is_top_level_project FALSE)
endif()
# options
option(CPPAST_BUILD_TEST "whether or not to build the tests" OFF)
option(CPPAST_BUILD_EXAMPLE "whether or not to build the examples" OFF)
option(CPPAST_BUILD_TOOL "whether or not to build the tool" OFF)
if(${CPPAST_BUILD_TEST} OR ${is_top_level_project})
set(build_test ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for the self integration test
else()
set(build_test OFF)
endif()
if(${CPPAST_BUILD_EXAMPLE} OR ${is_top_level_project})
set(build_example ON)
else()
set(build_example OFF)
endif()
if(${CPPAST_BUILD_TOOL} OR ${is_top_level_project})
set(build_tool ON)
else()
set(build_tool OFF)
endif()
include(external/external.cmake)
if(build_test AND CPPAST_TEST_GCOV AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
endif()
add_subdirectory(src)
if(${build_test})
enable_testing()
add_subdirectory(test)
endif()
if(${build_example})
add_subdirectory(example)
endif()
if(${build_tool})
add_subdirectory(tool)
endif()