FreeCAD
200 строк · 11.1 Кб
1macro(InitializeFreeCADBuildOptions)
2# ==============================================================================
3# ================= All the options for the build process =================
4# ==============================================================================
5
6option(BUILD_FORCE_DIRECTORY "The build directory must be different to the source directory." OFF)
7option(BUILD_GUI "Build FreeCAD Gui. Otherwise you have only the command line and the Python import module." ON)
8option(FREECAD_USE_EXTERNAL_ZIPIOS "Use system installed zipios++ instead of the bundled." OFF)
9option(FREECAD_USE_EXTERNAL_SMESH "Use system installed smesh instead of the bundled." OFF)
10option(FREECAD_USE_EXTERNAL_KDL "Use system installed orocos-kdl instead of the bundled." OFF)
11option(FREECAD_USE_EXTERNAL_FMT "Use system installed fmt library if available instead of fetching the source." ON)
12option(FREECAD_USE_EXTERNAL_ONDSELSOLVER "Use system installed OndselSolver instead of git submodule." OFF)
13option(FREECAD_USE_FREETYPE "Builds the features using FreeType libs" ON)
14option(FREECAD_BUILD_DEBIAN "Prepare for a build of a Debian package" OFF)
15option(BUILD_WITH_CONDA "Set ON if you build FreeCAD with conda" OFF)
16option(BUILD_DYNAMIC_LINK_PYTHON "If OFF extension-modules do not link against python-libraries" ON)
17option(INSTALL_TO_SITEPACKAGES "If ON the freecad root namespace (python) is installed into python's site-packages" ON)
18option(OCCT_CMAKE_FALLBACK "disable usage of occt-config files" OFF)
19if (WIN32 OR APPLE)
20option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." OFF)
21else()
22option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." ON)
23endif()
24
25# == Win32 is default behaviour use the LibPack copied in Source tree ==========
26if(MSVC)
27option(FREECAD_RELEASE_PDB "Create PDB files for Release version." ON)
28option(FREECAD_RELEASE_SEH "Enable Structured Exception Handling for Release version." ON)
29option(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." ON)
30option(FREECAD_USE_PCH "Activate precompiled headers where it's used." ON)
31
32if (DEFINED ENV{FREECAD_LIBPACK_DIR})
33set(FREECAD_LIBPACK_DIR $ENV{FREECAD_LIBPACK_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
34message(STATUS "Found libpack env variable: ${FREECAD_LIBPACK_DIR}")
35else()
36set(FREECAD_LIBPACK_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
37endif()
38
39set(LIBPACK_FOUND OFF )
40if (EXISTS ${FREECAD_LIBPACK_DIR}/plugins/imageformats/qsvg.dll)
41set(LIBPACK_FOUND ON )
42set(COPY_LIBPACK_BIN_TO_BUILD OFF )
43# Create install commands for dependencies for INSTALL target in FreeCAD solution
44option(FREECAD_INSTALL_DEPEND_DIRS "Create install dependency commands for the INSTALL target found
45in the FreeCAD solution." ON)
46# Copy libpack smaller dependency folders to build folder per user request - if non-existent at destination
47if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/imageformats/qsvg.dll)
48option(FREECAD_COPY_DEPEND_DIRS_TO_BUILD "Copy smaller libpack dependency directories to build directory." OFF)
49endif()
50# Copy libpack 'bin' directory contents to build 'bin' per user request - only IF NOT EXISTS already
51if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/DLLs)
52set(COPY_LIBPACK_BIN_TO_BUILD ON )
53option(FREECAD_COPY_LIBPACK_BIN_TO_BUILD "Copy larger libpack dependency 'bin' folder to the build directory." OFF)
54# Copy only the minimum number of files to get a working application
55option(FREECAD_COPY_PLUGINS_BIN_TO_BUILD "Copy plugins to the build directory." OFF)
56endif()
57else()
58message(WARNING Could not locate ${FREECAD_LIBPACK_DIR}/plugins/imageformats/qsvg.dll)
59message("Libpack NOT found.\nIf you intend to use a Windows libpack, set the FREECAD_LIBPACK_DIR to the libpack directory.")
60message(STATUS "Visit: https://github.com/FreeCAD/FreeCAD-Libpack/releases/ for Windows libpack downloads.")
61endif()
62elseif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
63option(FREECAD_WARN_ERROR "Make all warnings into errors. " OFF)
64else(MSVC)
65option(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." OFF)
66set(FREECAD_LIBPACK_DIR "" CACHE PATH "Directory of the FreeCAD LibPack")
67endif(MSVC)
68
69ChooseQtVersion()
70
71# https://blog.kitware.com/constraining-values-with-comboboxes-in-cmake-cmake-gui/
72set(FREECAD_USE_OCC_VARIANT "Community Edition" CACHE STRING "Official OpenCASCADE version or community edition")
73set_property(CACHE FREECAD_USE_OCC_VARIANT PROPERTY STRINGS
74"Official Version"
75"Community Edition"
76)
77
78configure_file(${CMAKE_SOURCE_DIR}/src/QtOpenGL.h.cmake ${CMAKE_BINARY_DIR}/src/QtOpenGL.h)
79
80option(BUILD_DESIGNER_PLUGIN "Build and install the designer plugin" OFF)
81
82if(APPLE)
83option(FREECAD_CREATE_MAC_APP "Create app bundle on install" OFF)
84
85if(FREECAD_CREATE_MAC_APP)
86install(
87DIRECTORY ${CMAKE_SOURCE_DIR}/src/MacAppBundle/FreeCAD.app/
88DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app
89)
90
91# It should be safe to assume we've got sed on OSX...
92install(CODE "
93execute_process(COMMAND
94sed -i \"\" -e s/VERSION_STRING_FROM_CMAKE/${PACKAGE_VERSION}/
95-e s/NAME_STRING_FROM_CMAKE/${PROJECT_NAME}/
96${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/Info.plist)
97")
98
99set(CMAKE_INSTALL_PREFIX
100${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents)
101set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib )
102endif(FREECAD_CREATE_MAC_APP)
103set(CMAKE_MACOSX_RPATH TRUE )
104endif(APPLE)
105
106option(BUILD_FEM "Build the FreeCAD FEM module" ON)
107option(BUILD_SANDBOX "Build the FreeCAD Sandbox module which is only for testing purposes" OFF)
108option(BUILD_TEMPLATE "Build the FreeCAD template module which is only for testing purposes" OFF)
109option(BUILD_ADDONMGR "Build the FreeCAD addon manager module" ON)
110option(BUILD_BIM "Build the FreeCAD BIM module" ON)
111option(BUILD_DRAFT "Build the FreeCAD draft module" ON)
112option(BUILD_DRAWING "Build the FreeCAD drawing module" OFF)
113option(BUILD_HELP "Build the FreeCAD help module" ON)
114option(BUILD_IDF "Build the FreeCAD idf module" ON)
115option(BUILD_IMPORT "Build the FreeCAD import module" ON)
116option(BUILD_INSPECTION "Build the FreeCAD inspection module" ON)
117option(BUILD_JTREADER "Build the FreeCAD jt reader module" OFF)
118option(BUILD_MATERIAL "Build the FreeCAD material module" ON)
119option(BUILD_MESH "Build the FreeCAD mesh module" ON)
120option(BUILD_MESH_PART "Build the FreeCAD mesh part module" ON)
121option(BUILD_FLAT_MESH "Build the FreeCAD flat mesh module" ON)
122option(BUILD_OPENSCAD "Build the FreeCAD openscad module" ON)
123option(BUILD_PART "Build the FreeCAD part module" ON)
124option(BUILD_PART_DESIGN "Build the FreeCAD part design module" ON)
125option(BUILD_CAM "Build the FreeCAD CAM module" ON)
126option(BUILD_ASSEMBLY "Build the FreeCAD Assembly module" ON)
127option(BUILD_PLOT "Build the FreeCAD plot module" ON)
128option(BUILD_POINTS "Build the FreeCAD points module" ON)
129option(BUILD_REVERSEENGINEERING "Build the FreeCAD reverse engineering module" ON)
130option(BUILD_ROBOT "Build the FreeCAD robot module" ON)
131option(BUILD_SHOW "Build the FreeCAD Show module (helper module for visibility automation)" ON)
132option(BUILD_SKETCHER "Build the FreeCAD sketcher module" ON)
133option(BUILD_SPREADSHEET "Build the FreeCAD spreadsheet module" ON)
134option(BUILD_START "Build the FreeCAD start module" ON)
135option(BUILD_TEST "Build the FreeCAD test module" ON)
136option(BUILD_MEASURE "Build the FreeCAD Measure module" ON)
137option(BUILD_TECHDRAW "Build the FreeCAD Technical Drawing module" ON)
138option(BUILD_TUX "Build the FreeCAD Tux module" ON)
139option(BUILD_WEB "Build the FreeCAD Web module" ON)
140option(BUILD_SURFACE "Build the FreeCAD surface module" ON)
141option(BUILD_VR "Build the FreeCAD Oculus Rift support (need Oculus SDK 4.x or higher)" OFF)
142option(BUILD_CLOUD "Build the FreeCAD cloud module" OFF)
143option(ENABLE_DEVELOPER_TESTS "Build the FreeCAD unit tests suit" ON)
144
145if(MSVC)
146set(FREECAD_3DCONNEXION_SUPPORT "NavLib" CACHE STRING "Select version of the 3Dconnexion device integration")
147set_property(CACHE FREECAD_3DCONNEXION_SUPPORT PROPERTY STRINGS "NavLib" "Raw input")
148else(MSVC)
149set(FREECAD_3DCONNEXION_SUPPORT "Raw input")
150endif(MSVC)
151
152if(MSVC)
153option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
154option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF) # 3/5/2021 current LibPack uses non-C++17 FLANN
155option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
156elseif(APPLE)
157find_library(3DCONNEXIONCLIENT_FRAMEWORK 3DconnexionClient)
158if(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
159option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
160else(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
161option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." OFF)
162endif(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
163else(MSVC)
164set(FREECAD_USE_3DCONNEXION OFF )
165endif(MSVC)
166if(NOT MSVC)
167option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" OFF)
168option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF)
169endif(NOT MSVC)
170
171if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "NavLib" AND FREECAD_USE_3DCONNEXION)
172set(FREECAD_USE_3DCONNEXION_NAVLIB ON)
173set(FREECAD_USE_3DCONNEXION OFF)
174endif()
175
176# if this is set override some options
177if (FREECAD_BUILD_DEBIAN)
178set(FREECAD_USE_EXTERNAL_ZIPIOS ON )
179# A Debian package for SMESH doesn't exist
180#set(FREECAD_USE_EXTERNAL_SMESH ON )
181endif (FREECAD_BUILD_DEBIAN)
182
183if(BUILD_FEM)
184set(BUILD_SMESH ON )
185endif()
186
187# for Windows the minimum required cmake version is 3.4.3 to build the CAM module
188if(WIN32 AND CMAKE_VERSION VERSION_LESS 3.4.3)
189message(WARNING "Disable CAM, requires cmake >= 3.4.3 in order to build this module")
190set(BUILD_CAM OFF )
191endif()
192
193# force build directory to be different to source directory
194if (BUILD_FORCE_DIRECTORY)
195if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
196message(FATAL_ERROR "The build directory (${CMAKE_BINARY_DIR}) must be different to the source directory (${CMAKE_SOURCE_DIR}).\n"
197"Please choose another build directory! Or disable the option BUILD_FORCE_DIRECTORY.")
198endif()
199endif()
200endmacro(InitializeFreeCADBuildOptions)
201