-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
63 lines (46 loc) · 2.07 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
cmake_minimum_required(VERSION 3.9)
project(dsa)
include(ExternalProject)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE "Debug")
option(DSA_BUILD_TESTS "build tests alongside the project" OFF)
include_directories(dsa/include)
# Add gtest dependency
set(GTEST_VERSION "1.8.0")
if(APPLE)
set(CMAKE_CXX_FLAGS "-g -fno-omit-frame-pointer -fsanitize=address")
set(GTEST_CMAKE_CXX_FLAGS "-fPIC -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes")
elseif(NOT MSVC)
set(CMAKE_CXX_FLAGS "-g -fno-omit-frame-pointer -fsanitize=address -fuse-ld=gold")
set(GTEST_CMAKE_CXX_FLAGS "-fPIC")
endif()
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
endif()
set(GTEST_CMAKE_CXX_FLAGS "${EP_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}} ${GTEST_CMAKE_CXX_FLAGS}")
set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/external/googletest-install")
set(GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include")
set(GTEST_STATIC_LIB
"${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GTEST_MAIN_STATIC_LIB
"${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GMOCK_MAIN_STATIC_LIB
"${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GTEST_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${GTEST_PREFIX}
-DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS})
set(GTEST_URL_MD5 "16877098823401d1bf2ed7891d7dce36")
#add_library(dsa SHARED ${DSA_SRC_FILES})
add_subdirectory(examples)
if (DSA_BUILD_TESTS)
ExternalProject_Add(googletest_ep
PREFIX external/googletest
URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz"
URL_MD5 ${GTEST_URL_MD5}
BUILD_BYPRODUCTS ${GTEST_STATIC_LIB} ${GTEST_MAIN_STATIC_LIB} ${GMOCK_MAIN_STATIC_LIB}
CMAKE_ARGS ${GTEST_CMAKE_ARGS}
${EP_LOG_OPTIONS})
# end of add gtest dependency
enable_testing()
add_subdirectory(test)
endif()