-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
41 lines (32 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
cmake_minimum_required(VERSION 3.5)
project(array_view)
option(AV_BUILD_TESTS "Build unit tests. Requires GTest." ON)
option(AV_BUILD_GTEST "Build GTest along with this project (ON) or use an existing installation (OFF)." ON)
# An interface target for array_view
add_library(array_view INTERFACE)
add_library(array_view::array_view ALIAS array_view)
target_include_directories(array_view INTERFACE .)
target_compile_features(array_view INTERFACE cxx_std_14)
# Export target, importable from build directory
export(TARGETS array_view
NAMESPACE array_view::
FILE array_viewConfig.cmake
)
if(AV_BUILD_TESTS)
add_executable(av_test "array_view/array_view_test.cpp")
target_link_libraries(av_test array_view::array_view )
if(AV_BUILD_GTEST)
set(GTEST_ROOT $ENV{GTEST_ROOT} CACHE PATH "Path to GTest directory")
if("${GTEST_ROOT}" STREQUAL "")
message(FATAL_ERROR "To build GTest, set GTEST_ROOT to point to your GTest folder, "
"or disable building with this project.")
endif()
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/gtest")
add_subdirectory("${GTEST_ROOT}" "${CMAKE_BINARY_DIR}/gtest")
include_directories("${GTEST_ROOT}/include")
target_link_libraries(av_test gtest gtest_main pthread)
else()
find_package(GTest REQUIRED)
target_link_libraries(av_test GTest::GTest GTest::Main)
endif()
endif()