Debian Codegraph @

src/Base/CMakeLists.txt

raw
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 add_library(FreeCADBase SHARED)
4
5 if(WIN32)
6 add_definitions(-DFCBase)
7 add_definitions(-DPYCXX_DLL)
8 add_definitions(-DBOOST_DYN_LINK)
9 add_definitions(-DZIPIOS_UTF8)
10 endif(WIN32)
11
12 if(BUILD_TRACY_FRAME_PROFILER)
13 add_definitions(-DBUILD_TRACY_FRAME_PROFILER)
14 endif()
15
16 target_include_directories(
17 FreeCADBase
18 PRIVATE
19 ${CMAKE_BINARY_DIR}/src
20 ${CMAKE_SOURCE_DIR}/src
21 ${CMAKE_CURRENT_BINARY_DIR}
22 ${CMAKE_CURRENT_SOURCE_DIR}
23 )
24
25 target_include_directories(
26 FreeCADBase
27 SYSTEM
28 PUBLIC
29 ${Boost_INCLUDE_DIRS}
30 ${PYCXX_INCLUDE_DIRS}
31 ${Python3_INCLUDE_DIRS}
32 ${QtCore_INCLUDE_DIRS}
33 ${XercesC_INCLUDE_DIRS}
34 ${ZLIB_INCLUDE_DIR}
35 ${ZIPIOS_INCLUDES}
36 ${ICU_INCLUDE_DIRS}
37 )
38
39 if(MSVC)
40 set(FreeCADBase_LIBS
41 ${Boost_LIBRARIES}
42 ${XercesC_LIBRARIES}
43 ${ZLIB_LIBRARIES}
44 ${ICU_LIBRARIES}
45 debug MSVCRTD.LIB
46 debug MSVCPRTD.LIB
47 optimized MSVCRT.LIB
48 optimized MSVCPRT.LIB
49 Rpcrt4.lib
50 version.lib
51 )
52
53 #Universal C runtime introduced in VS 2015 (cl version 19)
54 if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19"))
55 list(APPEND FreeCADBase_LIBS
56 debug vcruntimed.lib
57 debug ucrtd.lib
58 debug concrtd.lib
59 optimized vcruntime.lib
60 optimized ucrt.lib
61 optimized concrt.lib
62 )
63 endif()
64 elseif(MINGW)
65 set(FreeCADBase_LIBS
66 ${XercesC_LIBRARIES}
67 ${Boost_LIBRARIES}
68 ${ZLIB_LIBRARIES}
69 ${ICU_LIBRARIES}
70 Rpcrt4.lib
71 )
72 else(MSVC)
73 set(FreeCADBase_LIBS
74 ${XercesC_LIBRARIES}
75 ${Boost_LIBRARIES}
76 ${ZLIB_LIBRARIES}
77 ${ICU_LIBRARIES}
78 )
79 endif(MSVC)
80
81 if(BUILD_TRACY_FRAME_PROFILER)
82 list(APPEND FreeCADBase_LIBS TracyClient)
83 endif()
84
85 list(APPEND FreeCADBase_LIBS ${QtCore_LIBRARIES})
86
87 list(APPEND FreeCADBase_LIBS fmt::fmt)
88
89 if (BUILD_DYNAMIC_LINK_PYTHON)
90 list(APPEND FreeCADBase_LIBS ${Python3_LIBRARIES})
91 endif (BUILD_DYNAMIC_LINK_PYTHON)
92
93 # needed for OpenSUSE
94 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
95 list(APPEND FreeCADBase_LIBS -lutil -ldl)
96 endif()
97
98 generate_from_py(Type)
99 generate_from_py(BaseClass)
100 generate_from_py(BoundBox)
101 generate_from_py(CoordinateSystem)
102 generate_from_py(Persistence)
103 generate_from_py(Vector)
104 generate_from_py(Matrix)
105 generate_from_py(Rotation)
106 generate_from_py(Placement)
107 generate_from_py(Axis)
108 generate_from_py(Unit)
109 generate_from_py(Quantity)
110 generate_from_py(Precision)
111 generate_from_any(Parameter.xsd Parameter.inl xmlSchemeString)
112
113 if(SWIG_FOUND)
114 # Create the file swigpyrun.hh and then compare with the file swigpyrun.h.
115 # If the files are different or if swigpyrun.h doesn't exist then copy swigpyrun.hh.
116 # This is to avoid to having to build the target each time cmake configure is executed.
117 execute_process(COMMAND ${SWIG_EXECUTABLE} -python -external-runtime ${CMAKE_CURRENT_BINARY_DIR}/swigpyrun.hh)
118
119 fc_copy_file_if_different(
120 "${CMAKE_CURRENT_BINARY_DIR}/swigpyrun.hh"
121 "${CMAKE_CURRENT_BINARY_DIR}/swigpyrun.h"
122 )
123 add_definitions(-DHAVE_SWIG=1)
124 endif(SWIG_FOUND)
125
126 SOURCE_GROUP("pycxx" FILES ${PYCXX_SOURCES})
127
128 # auto-generate resource file with all available translations
129 set (FreeCADBase_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Base_translation.qrc)
130 qt_find_and_add_translation(QM_SRCS "Resources/translations/*_*.ts"
131 ${CMAKE_CURRENT_BINARY_DIR}/Resources/translations)
132 qt_create_resource_file(${FreeCADBase_TR_QRC} ${QM_SRCS})
133 qt_add_resources(FreeCADBase_QRC_SRCS ${FreeCADBase_TR_QRC})
134
135 SET(FreeCADBase_Pyi_SRCS
136 Axis.pyi
137 BaseClass.pyi
138 BoundBox.pyi
139 CoordinateSystem.pyi
140 Matrix.pyi
141 Persistence.pyi
142 Placement.pyi
143 Rotation.pyi
144 Vector.pyi
145 Quantity.pyi
146 Type.pyi
147 Unit.pyi
148 Precision.pyi
149 )
150 SOURCE_GROUP("Pyi" FILES ${FreeCADBase_Pyi_SRCS})
151
152 SET(FreeCADBase_UNITAPI_SRCS
153 UnitsApi.cpp
154 UnitsApiPy.cpp
155 UnitsApi.h
156 UnitsConvData.h
157 UnitsSchema.h
158 UnitsSchema.cpp
159 UnitsSchemas.cpp
160 UnitsSchemas.h
161 UnitsSchemasData.h
162 UnitsSchemasSpecs.h
163 Quantity.h
164 Quantity.cpp
165 QuantityPyImp.cpp
166 Quantity.l
167 Quantity.y
168 Unit.h
169 Unit.cpp
170 UnitPyImp.cpp
171 )
172 SOURCE_GROUP("Units" FILES ${FreeCADBase_UNITAPI_SRCS})
173
174 SET(SWIG_SRCS
175 swigpyrun.cpp
176 )
177
178 SET(FreeCADBase_CPP_SRCS
179 Axis.cpp
180 AxisPyImp.cpp
181 Base64.cpp
182 BaseClass.cpp
183 BaseClassPyImp.cpp
184 BindingManager.cpp
185 BoundBoxPyImp.cpp
186 Builder3D.cpp
187 Console.cpp
188 ConsoleObserver.cpp
189 Color.cpp
190 CoordinateSystem.cpp
191 CoordinateSystemPyImp.cpp
192 Debugger.cpp
193 DualQuaternion.cpp
194 Exception.cpp
195 ExceptionFactory.cpp
196 Factory.cpp
197 FileInfo.cpp
198 FutureWatcherProgress.cpp
199 GeometryPyCXX.cpp
200 Handle.cpp
201 InputSource.cpp
202 Interpreter.cpp
203 Matrix.cpp
204 MatrixPyImp.cpp
205 Observer.cpp
206 Parameter.xsd
207 Parameter.cpp
208 ParameterPy.cpp
209 Persistence.cpp
210 PersistencePyImp.cpp
211 Placement.cpp
212 PlacementPyImp.cpp
213 PrecisionPyImp.cpp
214 ProgressIndicator.cpp
215 ProgressIndicatorPy.cpp
216 PyExport.cpp
217 PyObjectBase.cpp
218 PythonTypeExt.cpp
219 Reader.cpp
220 Rotation.cpp
221 RotationPyImp.cpp
222 Sequencer.cpp
223 ServiceProvider.cpp
224 SmartPtrPy.cpp
225 Stream.cpp
226 Swap.cpp
227 ${SWIG_SRCS}
228 Tools.cpp
229 Tools2D.cpp
230 Tools3D.cpp
231 Translate.cpp
232 Type.cpp
233 TypePyImp.cpp
234 UniqueNameManager.cpp
235 Uuid.cpp
236 Vector3D.cpp
237 VectorPyImp.cpp
238 ViewProj.cpp
239 Writer.cpp
240 XMLTools.cpp
241 ZipHeader.cpp
242 )
243
244 SET(SWIG_HEADERS
245 swigpyrun.inl
246 )
247
248 SET(FreeCADBase_HPP_SRCS
249 Axis.h
250 Base64.h
251 Base64Filter.h
252 BaseClass.h
253 BindingManager.h
254 Bitmask.h
255 BoundBox.h
256 Builder3D.h
257 Console.h
258 ConsoleObserver.h
259 Converter.h
260 Color.h
261 CoordinateSystem.h
262 Debugger.h
263 DualNumber.h
264 DualQuaternion.h
265 Exception.h
266 ExceptionFactory.h
267 Factory.h
268 FileInfo.h
269 FutureWatcherProgress.h
270 GeometryPyCXX.h
271 Handle.h
272 InputSource.h
273 Interpreter.h
274 Matrix.h
275 Observer.h
276 Parameter.h
277 Persistence.h
278 Placement.h
279 Precision.h
280 ProgressIndicatorPy.h
281 ProgressIndicator.h
282 PyExport.h
283 PyObjectBase.h
284 PyWrapParseTupleAndKeywords.h
285 PythonTypeExt.h
286 Reader.h
287 Rotation.h
288 ServiceProvider.h
289 Sequencer.h
290 SmartPtrPy.h
291 Stream.h
292 Swap.h
293 ${SWIG_HEADERS}
294 TimeInfo.h
295 Tools.h
296 Tools2D.h
297 Tools3D.h
298 Translate.h
299 Type.h
300 UnlimitedUnsigned.h
301 UniqueNameManager.h
302 Uuid.h
303 Vector3D.h
304 ViewProj.h
305 Writer.h
306 XMLTools.h
307 ZipHeader.h
308 )
309
310 SET(FreeCADBase_SRCS
311 ${PYCXX_SOURCES}
312 ${FreeCADBase_QRC_SRCS}
313 ${FreeCADBase_CPP_SRCS}
314 ${FreeCADBase_HPP_SRCS}
315 ${FreeCADBase_Pyi_SRCS}
316 ${FreeCADBase_UNITAPI_SRCS}
317 PyTools.c
318 PyTools.h
319 PreCompiled.h
320 )
321
322 IF (MSVC)
323 SET(FreeCADBase_SRCS
324 ${FreeCADBase_SRCS}
325 StackWalker.cpp
326 StackWalker.h
327 )
328 ENDIF(MSVC)
329
330 if(FREECAD_USE_EXTERNAL_ZIPIOS)
331 list(APPEND FreeCADBase_LIBS ${ZIPIOS_LIBRARY})
332 else()
333 list(APPEND FreeCADBase_SRCS ${zipios_SRCS})
334 SOURCE_GROUP("zipios" FILES ${zipios_SRCS})
335 endif()
336
337 if(FREECAD_USE_PCH)
338 target_precompile_headers(FreeCADBase PRIVATE
339 $<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
340 )
341 endif(FREECAD_USE_PCH)
342
343 target_sources(FreeCADBase PRIVATE ${FreeCADBase_SRCS})
344 target_link_libraries(FreeCADBase ${FreeCADBase_LIBS})
345
346 if (MSVC)
347 target_compile_definitions(FreeCADBase PRIVATE WIN32_LEAN_AND_MEAN)
348 endif()
349
350 if (FREECAD_WARN_ERROR)
351 target_compile_warn_error(FreeCADBase)
352 endif()
353
354 SET_BIN_DIR(FreeCADBase FreeCADBase)
355
356 if(WIN32)
357 INSTALL(TARGETS FreeCADBase
358 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
359 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
360 )
361 else(WIN32)
362 INSTALL(TARGETS FreeCADBase
363 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
364 )
365 endif(WIN32)