-
Notifications
You must be signed in to change notification settings - Fork 186
/
CMakeLists.txt
52 lines (45 loc) · 1.8 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
# Copyright (c) 2019-present, Facebook, Inc.
#
# This source code is licensed under the license found in the
# LICENSE.txt file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.12)
project(libunifex LANGUAGES CXX
VERSION 0.1.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(project-is-top-level)
include(unifex_options)
include(unifex_env)
include(unifex_flags)
option(UNIFEX_USE_SYSTEM_GTEST "Use system GTest dependency" OFF)
# The library target is defined in the source subdirectory
add_subdirectory(source)
# Don't build tests or examples if this project is not a top-level project
# and only consumed via add_subdirectory in a git submodule fashion
if (PROJECT_IS_TOP_LEVEL)
# We enable testing in both cases, either if doing tests or building examples
# Note, that examples are also registered as tests by subsequent calls to add_test()
# You can run all tests or examples at once by using `ctest` or `ninja test`
include(CTest)
if(BUILD_TESTING OR UNIFEX_BUILD_EXAMPLES)
# Examples do not use gtest
if(UNIFEX_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(UNIFEX_BUILD_EXAMPLES)
# Tests do use gtest
if(BUILD_TESTING)
if(UNIFEX_USE_SYSTEM_GTEST)
find_package(GTest CONFIG REQUIRED)
# find_package(GMock REQUIRED)
else()
include(gtest)
target_compile_features(gtest PUBLIC cxx_std_17)
target_compile_features(gtest_main PUBLIC cxx_std_17)
if (UNIFEX_CXX_COMPILER_CLANGCL)
target_compile_options(gtest PRIVATE -Wno-error)
target_compile_options(gtest_main PRIVATE -Wno-error)
endif()
endif()
add_subdirectory(test)
endif(BUILD_TESTING)
endif(BUILD_TESTING OR UNIFEX_BUILD_EXAMPLES)
endif(PROJECT_IS_TOP_LEVEL)