-
Notifications
You must be signed in to change notification settings - Fork 49
/
CMakeLists.txt
131 lines (112 loc) · 3.98 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
message("--- functests")
set(SRCS
APITest.cpp
BasicFuncTests.cpp
LogSessionDataFuncTests.cpp
Main.cpp
MultipleLogManagersTests.cpp
)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD)
add_definitions(-DHAVE_MAT_PRIVACYGUARD)
list(APPEND SRCS
PrivacyGuardFuncTests.cpp
)
endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/)
list(APPEND SRCS
${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/tests/functests/DefaultDataViewerFuncTests.cpp
)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/ AND BUILD_LIVEEVENTINSPECTOR)
add_definitions(-DHAVE_MAT_LIVEEVENTINSPECTOR)
list(APPEND SRCS
LiveEventInspectorFuncTests.cpp
)
endif()
if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests)
list(APPEND SRCS
${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSClientFuncTests.cpp
${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSClientRealworldFuncTests.cpp
${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSConfigCacheFuncTests.cpp
)
if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json)
file(COPY_FILE ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json ${CMAKE_BINARY_DIR}/test.json)
endif()
endif()
source_group(" " REGULAR_EXPRESSION "")
source_group("common" REGULAR_EXPRESSION "/tests/common/")
if(BUILD_IOS)
add_library(FuncTests ${SRCS} ${TESTS_COMMON_SRCS})
else()
add_executable(FuncTests ${SRCS} ${TESTS_COMMON_SRCS})
endif()
if(PAL_IMPLEMENTATION STREQUAL "WIN32")
# Link against prebuilt libraries on Windows
message("--- WIN32: Linking against prebuilt libraries")
message("--- WIN32: ... ${CMAKE_BINARY_DIR}/gtest")
message("--- WIN32: ... ${CMAKE_BINARY_DIR}/gmock")
message("--- WIN32: ... ${CMAKE_BINARY_DIR}/zlib")
message("--- WIN32: ... ${CMAKE_BINARY_DIR}/sqlite")
# link_directories(${CMAKE_BINARY_DIR}/gtest/ ${CMAKE_BINARY_DIR}/gmock/ ${CMAKE_BINARY_DIR}/zlib/ ${CMAKE_BINARY_DIR}/sqlite/)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../zlib )
target_link_libraries(FuncTests
mat
wininet.lib
${CMAKE_BINARY_DIR}/gtest/gtest.lib
${CMAKE_BINARY_DIR}/gmock/gmock.lib
${CMAKE_BINARY_DIR}/zlib/zlib.lib
${CMAKE_BINARY_DIR}/sqlite/sqlite.lib
)
else()
# Prefer linking to more recent local sqlite3
if(EXISTS "/usr/local/lib/libsqlite3.a")
set (SQLITE3_LIB "/usr/local/lib/libsqlite3.a")
elseif(EXISTS "/usr/local/opt/sqlite/lib/libsqlite3.a")
set (SQLITE3_LIB "/usr/local/opt/sqlite/lib/libsqlite3.a")
else()
set (SQLITE3_LIB "sqlite3")
endif()
# Find zlib
find_package( ZLIB REQUIRED )
include_directories( ${ZLIB_INCLUDE_DIRS} )
set (PLATFORM_LIBS "")
# Add flags for obtaining system UUID via IOKit
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set (PLATFORM_LIBS "-framework CoreFoundation -framework Foundation")
if(BUILD_IOS)
set (PLATFORM_LIBS "${PLATFORM_LIBS} -framework UIKit -framework Network -framework SystemConfiguration")
else()
set (PLATFORM_LIBS "${PLATFORM_LIBS} -framework IOKit -framework Network -framework SystemConfiguration")
endif()
endif()
# Raspberry Pi 4 with gcc-8 on ARMv7l requires -latomic
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set (PLATFORM_LIBS "atomic")
endif()
# Find libraries
message("--- Linking libraries! ")
message("Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}")
message("Binary Dir: ${CMAKE_BINARY_DIR}")
find_file(LIBGTEST
NAMES libgtest.a
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/googletest/build/lib/
)
find_file(LIBGMOCK
NAMES libgmock.a
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/googletest/build/lib/
)
target_link_libraries(FuncTests
${LIBGTEST}
${LIBGMOCK}
mat
${ZLIB_LIBRARIES}
${SQLITE3_LIB}
${PLATFORM_LIBS}
dl)
if(NOT BUILD_IOS)
target_link_libraries(FuncTests curl)
endif()
endif()
add_test(FuncTests FuncTests "--gtest_output=xml:${CMAKE_BINARY_DIR}/test-reports/FuncTests.xml")