/
CMakeLists.txt
90 lines (78 loc) · 2.77 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
if (ENABLE_TESTS)
macro (add_qgis_test TESTSRC)
set(options OPTIONAL)
set(oneValueArgs MODULE LABELS)
set(multiValueArgs LINKEDLIBRARIES DEPENDENCIES)
cmake_parse_arguments(ARG_QGIS_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set (TESTNAME ${TESTSRC})
string(REPLACE "test" "" TESTNAME ${TESTNAME})
string(REPLACE "qgs" "" TESTNAME ${TESTNAME})
string(REPLACE ".cpp" "" TESTNAME ${TESTNAME})
set (TESTNAME "test_${ARG_QGIS_TEST_MODULE}_${TESTNAME}")
add_executable(${TESTNAME} ${TESTSRC} ${util_SRCS})
# add_custom_target(${TESTNAME}moc ALL DEPENDS ${${TESTNAME}_MOC_SRCS})
target_compile_features(${TESTNAME} PRIVATE cxx_std_17)
set_target_properties(${TESTNAME} PROPERTIES AUTORCC TRUE)
target_link_libraries(${TESTNAME} ${ARG_QGIS_TEST_LINKEDLIBRARIES})
target_link_libraries(${TESTNAME} ${Qt5Test_LIBRARIES})
add_test(${TESTNAME} ${CMAKE_BINARY_DIR}/output/bin/${TESTNAME} -maxwarnings 10000)
if (DEFINED ARG_QGIS_TEST_DEPENDENCIES)
add_dependencies(${TESTNAME} ${ARG_QGIS_TEST_DEPENDENCIES})
endif()
if (DEFINED ARG_QGIS_TEST_LABELS)
set_tests_properties(${TESTNAME} PROPERTIES LABELS ${ARG_QGIS_TEST_LABELS})
endif()
endmacro()
#############################################################
# Compiler defines
# This define is used for tests that need to locate the test
# data under tests/testdata in the qgis source tree.
# the TEST_DATA_DIR variable is set in the top level CMakeLists.txt
add_definitions(-DTEST_DATA_DIR="${TEST_DATA_DIR}")
add_definitions(-DINSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
# libraries
# enable postgresql tests
set (ENABLE_PGTEST FALSE CACHE BOOL "Enable PostgreSQL provider tests")
if ( ENABLE_PGTEST )
add_definitions(-DENABLE_PGTEST)
endif()
# because of htonl
if (WIN32)
set(PLATFORM_LIBRARIES wsock32)
endif()
# Since the tests are not actually installed, but rather
# run directly from the build/src/tests dir we need to
# ensure the qgis libs can be found.
if (APPLE)
# For Mac OS X, the executable must be at the root of the bundle's executable folder
# set (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
endif()
add_subdirectory(core)
if (WITH_GUI)
add_subdirectory(gui)
endif()
if (WITH_3D)
add_subdirectory(3d)
endif()
if (WITH_ANALYSIS)
add_subdirectory(analysis)
add_subdirectory(geometry_checker)
endif()
if (WITH_AUTH)
add_subdirectory(auth)
endif()
add_subdirectory(providers)
if (WITH_DESKTOP)
add_subdirectory(app)
endif()
add_subdirectory(native)
if (WITH_BINDINGS)
add_subdirectory(python)
endif()
if (WITH_QUICK)
add_subdirectory(quickgui)
endif()
if (WITH_SERVER)
add_subdirectory(server)
endif()
endif()