forked from FreeCAD/FreeCAD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
146 lines (126 loc) · 3.8 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
if ( EXISTS "${CMAKE_SOURCE_DIR}/tests/lib/googletest" )
include_directories( ${CMAKE_SOURCE_DIR}/tests/lib/googletest/include/ )
include_directories( ${CMAKE_SOURCE_DIR}/tests/lib/googlemock/include/ )
else()
find_package(GTest)
if( GTest_FOUND )
message( STATUS "Found Google Test: version ${GTest_VERSION}" )
else()
message( SEND_ERROR "The Google Test submodule is not available. Please run git submodule update --init" )
endif()
endif()
if(MSVC)
add_compile_options(/wd4251)
option(
gtest_force_shared_crt
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
ON)
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON)
set(Google_Tests_LIBS
oldnames.lib
debug msvcrtd.lib
debug msvcprtd.lib
optimized msvcrt.lib
optimized msvcprt.lib
)
# Universal C runtime introduced in VS 2015 (cl version 19)
if(NOT(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19"))
list(APPEND Google_Tests_LIBS
debug vcruntimed.lib
debug ucrtd.lib
debug concrtd.lib
optimized vcruntime.lib
optimized ucrt.lib
optimized concrt.lib
)
endif()
endif()
if(WIN32)
add_definitions(-DCOIN_DLL -D_USE_MATH_DEFINES)
endif(WIN32)
if(NOT BUILD_DYNAMIC_LINK_PYTHON)
list(APPEND Google_Tests_LIBS
${PYTHON_LIBRARIES}
)
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
set(CMAKE_AUTOMOC ON)
function(setup_qt_test)
foreach(_testname ${ARGN})
add_executable(${_testname}_Tests_run ${_testname}.cpp)
add_test(NAME ${_testname}_Tests_run COMMAND ${_testname}_Tests_run)
if(NOT BUILD_DYNAMIC_LINK_PYTHON)
list(APPEND ${_testname}_LIBS
${PYTHON_LIBRARIES}
)
endif()
target_include_directories(${_testname}_Tests_run PUBLIC
${Python3_INCLUDE_DIRS}
${XercesC_INCLUDE_DIRS}
${QtGui_INCLUDE_DIRS}
${QtWidgets_INCLUDE_DIRS}
${QtTest_INCLUDE_DIRS}
${COIN3D_INCLUDE_DIRS})
target_link_libraries(${_testname}_Tests_run
FreeCADApp
FreeCADGui
${QtCore_LIBRARIES}
${QtWidgets_LIBRARIES}
${QtTest_LIBRARIES}
${${_testname}_LIBS})
endforeach()
endfunction()
# Add test executables here
set(TestExecutables
Tests_run
)
if(BUILD_ASSEMBLY)
list (APPEND TestExecutables Assembly_tests_run)
endif(BUILD_ASSEMBLY)
if(BUILD_MATERIAL)
list (APPEND TestExecutables Material_tests_run)
endif(BUILD_MATERIAL)
if(BUILD_MESH)
list (APPEND TestExecutables Mesh_tests_run)
endif(BUILD_MESH)
if(BUILD_MESH_PART)
list (APPEND TestExecutables MeshPart_tests_run)
endif(BUILD_MESH_PART)
if(BUILD_PART)
list (APPEND TestExecutables Part_tests_run)
endif(BUILD_PART)
if(BUILD_PART_DESIGN)
list (APPEND TestExecutables PartDesign_tests_run)
endif(BUILD_PART_DESIGN)
if(BUILD_POINTS)
list (APPEND TestExecutables Points_tests_run)
endif(BUILD_POINTS)
if(BUILD_SKETCHER)
list (APPEND TestExecutables Sketcher_tests_run)
endif(BUILD_SKETCHER)
# -------------------------
foreach (exe ${TestExecutables})
add_executable(${exe})
endforeach()
if ( EXISTS "${CMAKE_SOURCE_DIR}/tests/lib/googletest" )
add_subdirectory(lib)
endif()
add_subdirectory(src)
target_include_directories(Tests_run PUBLIC
${Python3_INCLUDE_DIRS}
${XercesC_INCLUDE_DIRS}
)
target_link_libraries(Tests_run
gtest_main
gmock_main
${Google_Tests_LIBS}
FreeCADApp
)
include(GoogleTest)
# discovers tests by asking the compiled test executable to enumerate its tests
set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST)
foreach (exe ${TestExecutables})
gtest_discover_tests(${exe})
endforeach()