-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
56 lines (43 loc) · 1.32 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
cmake_minimum_required(VERSION 3.8)
project(sample_statistics LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
##
## MAIN_PROJECT CHECK
## determine if sample_statistics is built as a subproject (using add_subdirectory) or if it is the main project
##
set(MAIN_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(MAIN_PROJECT ON)
endif()
##
## TARGET
## create target and add include path
##
add_library(sample_statistics INTERFACE)
if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
target_compile_features(sample_statistics INTERFACE cxx_range_for)
else()
target_compile_features(sample_statistics INTERFACE cxx_std_11)
endif()
target_include_directories(
sample_statistics
INTERFACE
include
)
add_subdirectory(examples)
# Testing with GoogleTest (optional, but recommended)
option (INCLUDE_TESTS
"Unit testing with GoogleTest" ON)
if(INCLUDE_TESTS)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip # v1.12.1 (last version to support C++11)
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(test)
endif()