Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
178 lines (148 loc) · 5.93 KB
/
Copy pathCMakeLists.txt
File metadata and controls
178 lines (148 loc) · 5.93 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# As of February 2025 we require CMake 3.22.0
cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR)
# As of cMake 3.27, find_package() will look for both case-sensitive and all-uppercase versions
# of the package. This seems to affect FLANN as included by Pixi
if(POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()
# FindPythonInterp and FindPythonLibs modules are deprecated, but are still in use by
# all versions of Shiboken2. This policy must be kept at OLD until Shiboken2 is no longer
# supported
if(POLICY CMP0148)
cmake_policy(SET CMP0148 OLD)
endif()
# The exec_program command was deprecated in cMake 3.0, and policy CMP0153 was added in cMake
# 3.28 to control whether this gives a warning (the OLD behavior) or a fatal error (NEW)
if(POLICY CMP0153)
cmake_policy(SET CMP0153 NEW)
endif()
# Suppress 'FindBoost module is removed' warning. Will use BoostConfig.cmake instead
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
# As of cMake 3.31 add_custom_command() rejects invalid arguments
if(POLICY CMP0175)
cmake_policy(SET CMP0175 NEW)
endif()
# Added in cMake 3.31, enforce normalization of all DESTINATION paths given to install()
if(POLICY CMP0177)
cmake_policy(SET CMP0177 NEW)
endif()
# Make CMake output a bit more focused
set(CMAKE_REQUIRED_QUIET TRUE)
option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" ON)
# FreeCAD does not use C++20 modules. Keep CMake 3.28+ from enabling module
# dependency scanning on C++20 targets, especially with toolchains that do not
# provide a scanner such as clang-scan-deps.
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
if(FREECAD_USE_CCACHE)
find_program(CCACHE_PROGRAM ccache) #This check should occur before project()
if(CCACHE_PROGRAM)
message(STATUS "Using ccache found at: " ${CCACHE_PROGRAM})
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endif()
# Version and Package Name are set in the version.json file and propagate to all other
# files with version information in them either via CMake or via the sync_version.py
# script (in src/Tools/)
file(READ "${CMAKE_SOURCE_DIR}/version.json" VERSION_JSON)
string(JSON _PROJECT_NAME GET ${VERSION_JSON} "name")
string(JSON PACKAGE_VERSION_MAJOR GET ${VERSION_JSON} "version_major")
string(JSON PACKAGE_VERSION_MINOR GET ${VERSION_JSON} "version_minor")
string(JSON PACKAGE_VERSION_PATCH GET ${VERSION_JSON} "version_patch")
string(JSON PACKAGE_VERSION_SUFFIX GET ${VERSION_JSON} "version_suffix")
string(JSON PACKAGE_BUILD_VERSION GET ${VERSION_JSON} "build_version")
project(${_PROJECT_NAME})
string(TIMESTAMP PACKAGE_COPYRIGHT_YEAR "%Y")
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
# include local modules
include(CheckCXXCompilerFlag)
include(AddFileDependencies)
include(cMake/FreeCadMacros.cmake)
# include helper functions/macros
add_subdirectory(cMake/FreeCAD_Helpers)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake")
CompilerChecksAndSetups()
ConfigureCMakeVariables()
InitializeFreeCADBuildOptions()
CheckInterModuleDependencies()
FreeCADLibpackChecks()
SetupDoxygen()
SetupJSON()
SetupKDTree()
SetupSanitizers()
SetupYamlCpp()
SetupZipIos()
SetupClipper2()
find_package(fmt REQUIRED)
find_package(ICU REQUIRED COMPONENTS uc i18n)
find_package(cpptrace QUIET)
if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIBPACK_CHECKFILE_VERSION)
SetupPython()
SetupPCL()
SetupPybind11()
SetupXercesC()
find_package(ZLIB REQUIRED)
find_package(PyCXX REQUIRED)
SetupOpenCasCade()
if(BUILD_GUI)
# Do this before the check for SMESH because it depends on vtk
# that may have its own OpenGL check but possibly fails and leaves
# OPENGL_gl_LIBRARY empty that results into linker errors
SetupOpenGL()
endif(BUILD_GUI)
SetupSalomeSMESH()
if (BUILD_FEM_NETGEN)
set(NETGEN_DEFINITIONS -DNO_PARALLEL_THREADS -DOCCGEOMETRY)
if (NOT FREECAD_USE_EXTERNAL_SMESH)
find_package(NETGEN REQUIRED)
endif()
endif()
SetupSwig()
SetupEigen()
# This file is included directly due to some cMake macros that are defined within.
# If these macro definitions are embedded within another macro, it causes problems.
include(cMake/FreeCAD_Helpers/SetupQt.cmake)
SetupFreetype()
if(BUILD_GUI)
SetupCoinPivy()
SetupSpaceball()
SetupShibokenAndPyside()
SetupMatplotlib()
endif(BUILD_GUI)
# SetupCoinPivy can overwrite find_package(Boost) output so keep this after.
SetupBoost()
if(BUILD_BIM)
SetupLark()
find_python_runtime_dep(ifcopenshell ifcopenshell ifcopenshell_VERSION "IFC files support disabled.")
endif()
if(BUILD_ASSEMBLY)
find_python_runtime_dep(av av av_VERSION "Assembly simulation video export will not work properly.")
find_python_runtime_dep(pillow PIL pillow_VERSION "Assembly simulation video export will not work properly.")
endif()
# HDF5 might have been imported by any of the above dependencies (SMESH, VTK, ...)
# and added _FORTIFY_SOURCE defines to the build. Clean them at the end of import chains
# to make sure nothing will reinstate them.
hdf5_clean_fortify_source()
endif()
SetLibraryVersions()
SetGlobalCompilerAndLinkerSettings()
add_subdirectory(src)
add_subdirectory(data)
BuildAndInstallDesignerPlugin()
CreatePackagingTargets()
if(MSVC AND FREECAD_LIBPACK_USE AND LIBPACK_FOUND)
CopyLibpackDirectories()
endif()
if (ENABLE_DEVELOPER_TESTS)
include(CTest)
enable_testing()
find_package(GTest REQUIRED)
add_subdirectory(tests)
endif()
PrintFinalReport()
message("\n=================================================\n"
"Now run 'cmake --build ${CMAKE_BINARY_DIR}' to build ${PROJECT_NAME}\n"
"=================================================\n")