FreeCAD
184 строки · 10.4 Кб
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("Libpack NOT found.\nIf you intend to use a Windows libpack, set the FREECAD_LIBPACK_DIR to the libpack directory.")
59message(STATUS "Visit: https://github.com/FreeCAD/FreeCAD-Libpack/releases/ for Windows libpack downloads.")
60endif()
61else(MSVC)
62option(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." OFF)
63set(FREECAD_LIBPACK_DIR "" CACHE PATH "Directory of the FreeCAD LibPack")
64endif(MSVC)
65
66ChooseQtVersion()
67
68# https://blog.kitware.com/constraining-values-with-comboboxes-in-cmake-cmake-gui/
69set(FREECAD_USE_OCC_VARIANT "Community Edition" CACHE STRING "Official OpenCASCADE version or community edition")
70set_property(CACHE FREECAD_USE_OCC_VARIANT PROPERTY STRINGS
71"Official Version"
72"Community Edition"
73)
74
75configure_file(${CMAKE_SOURCE_DIR}/src/QtOpenGL.h.cmake ${CMAKE_BINARY_DIR}/src/QtOpenGL.h)
76
77option(BUILD_DESIGNER_PLUGIN "Build and install the designer plugin" OFF)
78
79if(APPLE)
80option(FREECAD_CREATE_MAC_APP "Create app bundle on install" OFF)
81
82if(FREECAD_CREATE_MAC_APP)
83install(
84DIRECTORY ${CMAKE_SOURCE_DIR}/src/MacAppBundle/FreeCAD.app/
85DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app
86)
87
88# It should be safe to assume we've got sed on OSX...
89install(CODE "
90execute_process(COMMAND
91sed -i \"\" -e s/VERSION_STRING_FROM_CMAKE/${PACKAGE_VERSION}/
92-e s/NAME_STRING_FROM_CMAKE/${PROJECT_NAME}/
93${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/Info.plist)
94")
95
96set(CMAKE_INSTALL_PREFIX
97${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents)
98set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib )
99endif(FREECAD_CREATE_MAC_APP)
100set(CMAKE_MACOSX_RPATH TRUE )
101endif(APPLE)
102
103option(BUILD_FEM "Build the FreeCAD FEM module" ON)
104option(BUILD_SANDBOX "Build the FreeCAD Sandbox module which is only for testing purposes" OFF)
105option(BUILD_TEMPLATE "Build the FreeCAD template module which is only for testing purposes" OFF)
106option(BUILD_ADDONMGR "Build the FreeCAD addon manager module" ON)
107option(BUILD_ARCH "Build the FreeCAD Architecture module" ON)
108option(BUILD_DRAFT "Build the FreeCAD draft module" ON)
109option(BUILD_DRAWING "Build the FreeCAD drawing module" OFF)
110option(BUILD_HELP "Build the FreeCAD help module" ON)
111option(BUILD_IDF "Build the FreeCAD idf module" ON)
112option(BUILD_IMPORT "Build the FreeCAD import module" ON)
113option(BUILD_INSPECTION "Build the FreeCAD inspection module" ON)
114option(BUILD_JTREADER "Build the FreeCAD jt reader module" OFF)
115option(BUILD_MATERIAL "Build the FreeCAD material module" ON)
116option(BUILD_MESH "Build the FreeCAD mesh module" ON)
117option(BUILD_MESH_PART "Build the FreeCAD mesh part module" ON)
118option(BUILD_FLAT_MESH "Build the FreeCAD flat mesh module" ON)
119option(BUILD_OPENSCAD "Build the FreeCAD openscad module" ON)
120option(BUILD_PART "Build the FreeCAD part module" ON)
121option(BUILD_PART_DESIGN "Build the FreeCAD part design module" ON)
122option(BUILD_PATH "Build the FreeCAD path module" ON)
123option(BUILD_ASSEMBLY "Build the FreeCAD Assembly module" ON)
124option(BUILD_PLOT "Build the FreeCAD plot module" ON)
125option(BUILD_POINTS "Build the FreeCAD points module" ON)
126option(BUILD_REVERSEENGINEERING "Build the FreeCAD reverse engineering module" ON)
127option(BUILD_ROBOT "Build the FreeCAD robot module" ON)
128option(BUILD_SHOW "Build the FreeCAD Show module (helper module for visibility automation)" ON)
129option(BUILD_SKETCHER "Build the FreeCAD sketcher module" ON)
130option(BUILD_SPREADSHEET "Build the FreeCAD spreadsheet module" ON)
131option(BUILD_START "Build the FreeCAD start module" ON)
132option(BUILD_TEST "Build the FreeCAD test module" ON)
133option(BUILD_TECHDRAW "Build the FreeCAD Technical Drawing module" ON)
134option(BUILD_TUX "Build the FreeCAD Tux module" ON)
135option(BUILD_WEB "Build the FreeCAD web module" ON)
136option(BUILD_SURFACE "Build the FreeCAD surface module" ON)
137option(BUILD_VR "Build the FreeCAD Oculus Rift support (need Oculus SDK 4.x or higher)" OFF)
138option(BUILD_CLOUD "Build the FreeCAD cloud module" OFF)
139option(ENABLE_DEVELOPER_TESTS "Build the FreeCAD unit tests suit" ON)
140
141if(MSVC)
142option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
143option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF) # 3/5/2021 current LibPack uses non-C++17 FLANN
144option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
145elseif(APPLE)
146find_library(3DCONNEXIONCLIENT_FRAMEWORK 3DconnexionClient)
147if(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
148option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
149else(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
150option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." OFF)
151endif(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
152else(MSVC)
153set(FREECAD_USE_3DCONNEXION OFF )
154endif(MSVC)
155if(NOT MSVC)
156option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" OFF)
157option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF)
158endif(NOT MSVC)
159
160# if this is set override some options
161if (FREECAD_BUILD_DEBIAN)
162set(FREECAD_USE_EXTERNAL_ZIPIOS ON )
163# A Debian package for SMESH doesn't exist
164#set(FREECAD_USE_EXTERNAL_SMESH ON )
165endif (FREECAD_BUILD_DEBIAN)
166
167if(BUILD_FEM)
168set(BUILD_SMESH ON )
169endif()
170
171# for Windows the minimum required cmake version is 3.4.3 to build the Path module
172if(WIN32 AND CMAKE_VERSION VERSION_LESS 3.4.3)
173message(WARNING "Disable Path, requires cmake >= 3.4.3 in order to build this module")
174set(BUILD_PATH OFF )
175endif()
176
177# force build directory to be different to source directory
178if (BUILD_FORCE_DIRECTORY)
179if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
180message(FATAL_ERROR "The build directory (${CMAKE_BINARY_DIR}) must be different to the source directory (${CMAKE_SOURCE_DIR}).\n"
181"Please choose another build directory! Or disable the option BUILD_FORCE_DIRECTORY.")
182endif()
183endif()
184endmacro(InitializeFreeCADBuildOptions)
185