An official mirror (for now...) of the FreeCAD project. Currently maintained in sync manually by Yorik. Please check https://www.freecadweb.org for issues and pull requests https://www.freecadweb.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 68KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
  2. if(COMMAND cmake_policy)
  3. cmake_policy(SET CMP0003 NEW)
  4. if(POLICY CMP0020)
  5. cmake_policy(SET CMP0020 NEW)
  6. endif(POLICY CMP0020)
  7. # added in cmake 3.0
  8. if(POLICY CMP0050)
  9. cmake_policy(SET CMP0050 NEW)
  10. endif(POLICY CMP0050)
  11. if (POLICY CMP0045)
  12. cmake_policy(SET CMP0045 NEW)
  13. endif(POLICY CMP0045)
  14. if (POLICY CMP0072)
  15. cmake_policy(SET CMP0072 OLD)
  16. endif(POLICY CMP0072)
  17. endif(COMMAND cmake_policy)
  18. find_program(CCACHE_PROGRAM ccache) #This check should occur before project()
  19. if(CCACHE_PROGRAM)
  20. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
  21. endif()
  22. project(FreeCAD)
  23. set(PACKAGE_VERSION_NAME "Vulcan")
  24. set(PACKAGE_VERSION_MAJOR "0")
  25. set(PACKAGE_VERSION_MINOR "19")
  26. set(PACKAGE_VERSION_PATCH "16100")
  27. set(FREECAD_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
  28. set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
  29. set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
  30. # include local modules
  31. include(AddFileDependencies)
  32. include(cMake/FreeCadMacros.cmake)
  33. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake")
  34. if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
  35. set(CMAKE_COMPILER_IS_CLANGXX TRUE)
  36. endif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
  37. # ================================================================================
  38. # Needed for boost1.69
  39. # Avoid that Python (pyerrors.h) defines snprintf and vsnprintf
  40. if (MSVC AND NOT MSVC_VERSION VERSION_LESS 1900)
  41. add_definitions(-DHAVE_SNPRINTF)
  42. elseif (MINGW)
  43. add_definitions(-DHAVE_SNPRINTF)
  44. endif()
  45. # Allow developers to use Boost < 1.48
  46. if (NOT BOOST_MIN_VERSION)
  47. set(BOOST_MIN_VERSION 1.48)
  48. endif()
  49. # For older cmake versions the variable 'CMAKE_CXX_COMPILER_VERSION' is missing
  50. if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION)
  51. execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
  52. OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
  53. endif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION)
  54. # Enabled C++11 for Freecad 0.17 and later
  55. if (FREECAD_VERSION VERSION_GREATER 0.16)
  56. set(BUILD_ENABLE_CXX_STD "C++11" CACHE STRING "Enable C++ standard")
  57. set_property(CACHE BUILD_ENABLE_CXX_STD PROPERTY STRINGS
  58. "C++11"
  59. "C++14"
  60. "C++17"
  61. "C++20"
  62. )
  63. if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
  64. message(FATAL_ERROR "FreeCAD 0.17 and later requires C++11. G++ must be 4.7 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}")
  65. elseif(CMAKE_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
  66. message(FATAL_ERROR "FreeCAD 0.17 and later requires C++11. Clang must be 3.3 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}")
  67. endif()
  68. endif(FREECAD_VERSION VERSION_GREATER 0.16)
  69. # Log the compiler and version
  70. message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}, version: ${CMAKE_CXX_COMPILER_VERSION}")
  71. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
  72. include(cMake/ConfigureChecks.cmake)
  73. configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  74. add_definitions(-DHAVE_CONFIG_H)
  75. # Escape the two plus chars as otherwise cmake complains about invalid regex
  76. if(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+20")
  77. set(CMAKE_CXX_STANDARD 20)
  78. elseif(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+17")
  79. set(CMAKE_CXX_STANDARD 17)
  80. elseif(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+14")
  81. set(CMAKE_CXX_STANDARD 14)
  82. elseif (${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+11")
  83. set(CMAKE_CXX_STANDARD 11)
  84. endif()
  85. set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-write-strings ${CMAKE_CXX_FLAGS}")
  86. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  87. # get linker errors as soon as possible and not at runtime e.g. for modules
  88. if(BUILD_DYNAMIC_LINK_PYTHON)
  89. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  90. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
  91. elseif(UNIX)
  92. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
  93. endif()
  94. else(BUILD_DYNAMIC_LINK_PYTHON)
  95. if(CMAKE_COMPILER_IS_CLANGXX)
  96. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,dynamic_lookup")
  97. endif()
  98. endif(BUILD_DYNAMIC_LINK_PYTHON)
  99. endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
  100. if(CMAKE_COMPILER_IS_CLANGXX)
  101. # Disable warning about potentially uninstantiated static members
  102. # because it leads to a lot of false-positives.
  103. #
  104. # https://en.wikipedia.org/wiki/Xcode#Latest_versions
  105. if (APPLE)
  106. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
  107. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template")
  108. endif()
  109. elseif (UNIX)
  110. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9)
  111. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template")
  112. endif()
  113. endif()
  114. # older boost.preprocessor turn off variadics for clang
  115. add_definitions(-DBOOST_PP_VARIADICS=1)
  116. message(STATUS "Force BOOST_PP_VARIADICS=1 for clang")
  117. endif()
  118. # ================================================================================
  119. # Output directories for install target
  120. if(WIN32)
  121. set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation root directory")
  122. set(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for executables")
  123. set(CMAKE_INSTALL_DATADIR data CACHE PATH "Output directory for data and resource files")
  124. set(CMAKE_INSTALL_INCLUDEDIR include CACHE PATH "Output directory for header files")
  125. set(CMAKE_INSTALL_DOCDIR doc CACHE PATH "Output directory for documentation and license files")
  126. # Don't set it without manual adoption of LibDir variable in src/App/FreeCADInit.py
  127. set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
  128. else()
  129. set(CMAKE_INSTALL_PREFIX "/usr/lib${LIB_SUFFIX}/freecad" CACHE PATH "Installation root directory")
  130. include(GNUInstallDirs)
  131. endif()
  132. set(PYCXX_INCLUDE_DIR
  133. "${CMAKE_SOURCE_DIR}/src" CACHE PATH
  134. "Path to the directory containing PyCXX's CXX/Config.hxx include file")
  135. set(PYCXX_SOURCE_DIR
  136. "${CMAKE_SOURCE_DIR}/src/CXX" CACHE PATH
  137. "Path to the directory containing PyCXX's cxxextensions.c source file")
  138. # used as compiler defines
  139. set(RESOURCEDIR "${CMAKE_INSTALL_DATADIR}")
  140. set(DOCDIR "${CMAKE_INSTALL_DOCDIR}")
  141. message(STATUS "prefix: ${CMAKE_INSTALL_PREFIX}")
  142. message(STATUS "bindir: ${CMAKE_INSTALL_BINDIR}")
  143. message(STATUS "datadir: ${CMAKE_INSTALL_DATADIR}")
  144. message(STATUS "docdir: ${CMAKE_INSTALL_DOCDIR}")
  145. message(STATUS "includedir: ${CMAKE_INSTALL_INCLUDEDIR}")
  146. message(STATUS "libdir: ${CMAKE_INSTALL_LIBDIR}")
  147. message(STATUS "cmake: ${CMAKE_VERSION}")
  148. # ==============================================================================
  149. # ================= All the options for the build process =================
  150. # ==============================================================================
  151. option(BUILD_FORCE_DIRECTORY "The build directory must be different to the source directory." OFF)
  152. option(BUILD_GUI "Build FreeCAD Gui. Otherwise you have only the command line and the Python import module." ON)
  153. option(FREECAD_USE_EXTERNAL_ZIPIOS "Use system installed zipios++ instead of the bundled." OFF)
  154. option(FREECAD_USE_EXTERNAL_SMESH "Use system installed smesh instead of the bundled." OFF)
  155. option(FREECAD_USE_EXTERNAL_KDL "Use system installed orocos-kdl instead of the bundled." OFF)
  156. option(FREECAD_USE_FREETYPE "Builds the features using FreeType libs" ON)
  157. option(FREECAD_BUILD_DEBIAN "Prepare for a build of a Debian package" OFF)
  158. option(BUILD_WITH_CONDA "Set ON if you build freecad with conda" OFF)
  159. option(BUILD_DYNAMIC_LINK_PYTHON "If OFF extension-modules do not link against python-libraries" ON)
  160. option(OCCT_CMAKE_FALLBACK "disable usage of occt-config files" OFF)
  161. if (WIN32 OR APPLE)
  162. option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." OFF)
  163. else()
  164. option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." ON)
  165. endif()
  166. # == Win32 is default behaviour use the LibPack copied in Source tree ==========
  167. if(MSVC)
  168. option(FREECAD_RELEASE_PDB "Create PDB files for Release version." ON)
  169. option(FREECAD_RELEASE_SEH "Enable Structured Exception Handling for Release version." ON)
  170. option(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." ON)
  171. option(FREECAD_LIBPACK_USEPYSIDE "Use PySide in LibPack rather to PyQt and Swig." ON)
  172. option(FREECAD_USE_PCH "Activate precompiled headers where it's used." ON)
  173. if (DEFINED ENV{FREECAD_LIBPACK_DIR})
  174. set(FREECAD_LIBPACK_DIR $ENV{FREECAD_LIBPACK_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
  175. message(STATUS "Found libpack env variable: ${FREECAD_LIBPACK_DIR}")
  176. if (EXISTS ${FREECAD_LIBPACK_DIR}/lib/Qt5Core.lib)
  177. option(BUILD_QT5 "Build with Qt5." ON)
  178. else()
  179. option(BUILD_QT5 "Build with Qt5." OFF)
  180. endif()
  181. else()
  182. set(FREECAD_LIBPACK_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
  183. if (EXISTS ${FREECAD_LIBPACK_DIR}/lib/Qt5Core.lib)
  184. option(BUILD_QT5 "Build with Qt5." ON)
  185. else()
  186. option(BUILD_QT5 "Build with Qt5." OFF)
  187. endif()
  188. endif()
  189. set(LIBPACK_FOUND OFF)
  190. if (EXISTS ${FREECAD_LIBPACK_DIR}/plugins/imageformats/qsvg.dll)
  191. set(LIBPACK_FOUND ON)
  192. set(COPY_LIBPACK_BIN_TO_BUILD OFF)
  193. # Create install commands for dependencies for INSTALL target in FreeCAD solution
  194. option(FREECAD_INSTALL_DEPEND_DIRS "Create install dependency commands for the INSTALL target found
  195. in the FreeCAD solution." ON)
  196. # Copy libpack smaller dependency folders to build folder per user request - if non-existent at destination
  197. if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/imageformats/qsvg.dll)
  198. option(FREECAD_COPY_DEPEND_DIRS_TO_BUILD "Copy smaller libpack dependency directories to build directory." OFF)
  199. endif()
  200. # Copy libpack 'bin' directory contents to build 'bin' per user request - only IF NOT EXISTS already
  201. if (NOT EXISTS ${CMAKE_BINARY_DIR}/bin/DLLs)
  202. set(COPY_LIBPACK_BIN_TO_BUILD ON)
  203. option(FREECAD_COPY_LIBPACK_BIN_TO_BUILD "Copy larger libpack dependency 'bin' folder to the build directory." OFF)
  204. endif()
  205. else()
  206. message("Libpack NOT found.\nIf you intend to use a Windows libpack, set the FREECAD_LIBPACK_DIR to the libpack directory.")
  207. message(STATUS "Visit: https://github.com/apeltauer/FreeCAD/releases/ for Windows libpack downloads.")
  208. endif()
  209. else(MSVC)
  210. option(BUILD_QT5 "Build with Qt5." OFF)
  211. option(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." OFF)
  212. set(FREECAD_LIBPACK_DIR "" CACHE PATH "Directory of the FreeCAD LibPack")
  213. endif(MSVC)
  214. # https://blog.kitware.com/constraining-values-with-comboboxes-in-cmake-cmake-gui/
  215. set(FREECAD_USE_OCC_VARIANT "Community Edition" CACHE STRING "Official OpenCASCADE version or community edition")
  216. set_property(CACHE FREECAD_USE_OCC_VARIANT PROPERTY STRINGS
  217. "Official Version"
  218. "Community Edition"
  219. )
  220. if (BUILD_QT5)
  221. option(FREECAD_USE_QTOPENGL_WIDGET "Replace QGLWidget with QOpenGLWidget." ON)
  222. if (FREECAD_USE_QTOPENGL_WIDGET)
  223. set(HAVE_QT5_OPENGL 1)
  224. endif()
  225. set(FREECAD_USE_QTWEBMODULE "Automatic" CACHE STRING "Qt Webkit or Qt WebEngine")
  226. set_property(CACHE FREECAD_USE_QTWEBMODULE PROPERTY STRINGS
  227. "Automatic"
  228. "Qt Webkit"
  229. "Qt WebEngine"
  230. )
  231. endif()
  232. configure_file(${CMAKE_SOURCE_DIR}/src/QtOpenGL.h.cmake ${CMAKE_BINARY_DIR}/src/QtOpenGL.h)
  233. if(APPLE)
  234. option(FREECAD_CREATE_MAC_APP "Create app bundle on install" OFF)
  235. if(FREECAD_CREATE_MAC_APP)
  236. install(
  237. DIRECTORY ${CMAKE_SOURCE_DIR}/src/MacAppBundle/FreeCAD.app/
  238. DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app
  239. )
  240. # It should be safe to assume we've got sed on OSX...
  241. install(CODE "
  242. execute_process(COMMAND
  243. sed -i \"\" -e s/VERSION_STRING_FROM_CMAKE/${PACKAGE_VERSION}/
  244. -e s/NAME_STRING_FROM_CMAKE/${PROJECT_NAME}/
  245. ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/Info.plist)
  246. ")
  247. set(CMAKE_INSTALL_PREFIX
  248. ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents)
  249. set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
  250. endif(FREECAD_CREATE_MAC_APP)
  251. set(CMAKE_MACOSX_RPATH TRUE)
  252. endif(APPLE)
  253. option(BUILD_FEM "Build the FreeCAD FEM module" ON)
  254. option(BUILD_SANDBOX "Build the FreeCAD Sandbox module which is only for testing purposes" OFF)
  255. option(BUILD_TEMPLATE "Build the FreeCAD template module which is only for testing purposes" OFF)
  256. option(BUILD_ADDONMGR "Build the FreeCAD addon manager module" ON)
  257. option(BUILD_ARCH "Build the FreeCAD Architecture module" ON)
  258. option(BUILD_ASSEMBLY "Build the FreeCAD Assembly module" OFF)
  259. option(BUILD_COMPLETE "Build the FreeCAD complete module" ON)
  260. option(BUILD_DRAFT "Build the FreeCAD draft module" ON)
  261. option(BUILD_DRAWING "Build the FreeCAD drawing module" ON)
  262. option(BUILD_IDF "Build the FreeCAD idf module" ON)
  263. option(BUILD_IMAGE "Build the FreeCAD image module" ON)
  264. option(BUILD_IMPORT "Build the FreeCAD import module" ON)
  265. option(BUILD_INSPECTION "Build the FreeCAD inspection module" ON)
  266. option(BUILD_JTREADER "Build the FreeCAD jt reader module" OFF)
  267. option(BUILD_MATERIAL "Build the FreeCAD material module" ON)
  268. option(BUILD_MESH "Build the FreeCAD mesh module" ON)
  269. option(BUILD_MESH_PART "Build the FreeCAD mesh part module" ON)
  270. option(BUILD_FLAT_MESH "Build the FreeCAD flat mesh module" OFF)
  271. option(BUILD_OPENSCAD "Build the FreeCAD openscad module" ON)
  272. option(BUILD_PART "Build the FreeCAD part module" ON)
  273. option(BUILD_PART_DESIGN "Build the FreeCAD part design module" ON)
  274. option(BUILD_PATH "Build the FreeCAD path module" ON)
  275. option(BUILD_PLOT "Build the FreeCAD plot module" OFF)
  276. option(BUILD_POINTS "Build the FreeCAD points module" ON)
  277. option(BUILD_RAYTRACING "Build the FreeCAD ray tracing module" ON)
  278. option(BUILD_REVERSEENGINEERING "Build the FreeCAD reverse engineering module" ON)
  279. option(BUILD_ROBOT "Build the FreeCAD robot module" ON)
  280. option(BUILD_SHIP "Build the FreeCAD ship module" OFF)
  281. option(BUILD_SHOW "Build the FreeCAD Show module (helper module for visibility automation)" ON)
  282. option(BUILD_SKETCHER "Build the FreeCAD sketcher module" ON)
  283. option(BUILD_SPREADSHEET "Build the FreeCAD spreadsheet module" ON)
  284. option(BUILD_START "Build the FreeCAD start module" ON)
  285. option(BUILD_TEST "Build the FreeCAD test module" ON)
  286. option(BUILD_TECHDRAW "Build the FreeCAD Technical Drawing module" ON)
  287. option(BUILD_TUX "Build the FreeCAD Tux module" ON)
  288. option(BUILD_WEB "Build the FreeCAD web module" ON)
  289. option(BUILD_SURFACE "Build the FreeCAD surface module" ON)
  290. option(BUILD_VR "Build the FreeCAD Oculus Rift support (need Oculus SDK 4.x or higher)" OFF)
  291. if(MSVC)
  292. option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
  293. option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
  294. elseif(APPLE)
  295. find_library(3DCONNEXIONCLIENT_FRAMEWORK 3DconnexionClient)
  296. if(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
  297. option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
  298. else(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
  299. option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." OFF)
  300. endif(IS_DIRECTORY ${3DCONNEXIONCLIENT_FRAMEWORK})
  301. else(MSVC)
  302. set(FREECAD_USE_3DCONNEXION OFF)
  303. endif(MSVC)
  304. if(NOT MSVC)
  305. option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" OFF)
  306. option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF)
  307. endif(NOT MSVC)
  308. # if this is set override some options
  309. if (FREECAD_BUILD_DEBIAN)
  310. set(FREECAD_USE_EXTERNAL_ZIPIOS ON)
  311. # A Debian package for SMESH doesn't exist
  312. #set(FREECAD_USE_EXTERNAL_SMESH ON)
  313. endif (FREECAD_BUILD_DEBIAN)
  314. if(BUILD_FEM)
  315. set(BUILD_SMESH ON)
  316. endif()
  317. # for Windows the minimum required cmake version is 3.4.3 to build the Path module
  318. if(WIN32 AND CMAKE_VERSION VERSION_LESS 3.4.3)
  319. message(WARNING "Disable Path, requires cmake >= 3.4.3 in order to build this module")
  320. set(BUILD_PATH OFF)
  321. endif()
  322. # force build directory to be different to source directory
  323. if (BUILD_FORCE_DIRECTORY)
  324. if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  325. message(FATAL_ERROR "The build directory (${CMAKE_BINARY_DIR}) must be different to the source directory (${CMAKE_SOURCE_DIR}).\n"
  326. "Please choose another build directory! Or disable the option BUILD_FORCE_DIRECTORY.")
  327. endif()
  328. endif()
  329. # ==============================================================================
  330. #inter-module dependencies
  331. # Takes a dependent module followed by a variable-length list of prerequisite
  332. # modules. Warns if any of the prerequisite modules are disabled.
  333. function(REQUIRES_MODS dependent)
  334. if(${dependent})
  335. foreach(prerequisite ${ARGN})
  336. if(NOT ${prerequisite})
  337. message(WARNING
  338. "${dependent} requires ${ARGN} each be ON, but "
  339. "${prerequisite} is \"${${prerequisite}}\"")
  340. endif(NOT ${prerequisite})
  341. endforeach()
  342. endif(${dependent})
  343. endfunction(REQUIRES_MODS)
  344. REQUIRES_MODS(BUILD_ARCH BUILD_PART BUILD_MESH BUILD_DRAFT)
  345. REQUIRES_MODS(BUILD_DRAFT BUILD_SKETCHER)
  346. REQUIRES_MODS(BUILD_DRAWING BUILD_PART BUILD_SPREADSHEET)
  347. REQUIRES_MODS(BUILD_FEM BUILD_PART)
  348. REQUIRES_MODS(BUILD_IDF BUILD_PART)
  349. REQUIRES_MODS(BUILD_IMPORT BUILD_PART)
  350. REQUIRES_MODS(BUILD_INSPECTION BUILD_MESH BUILD_POINTS BUILD_PART)
  351. REQUIRES_MODS(BUILD_JTREADER BUILD_MESH)
  352. REQUIRES_MODS(BUILD_MESH_PART BUILD_PART BUILD_MESH BUILD_SMESH)
  353. REQUIRES_MODS(BUILD_FLAT_MESH BUILD_MESH_PART)
  354. REQUIRES_MODS(BUILD_OPENSCAD BUILD_MESH_PART BUILD_DRAFT)
  355. REQUIRES_MODS(BUILD_PART_DESIGN BUILD_SKETCHER)
  356. REQUIRES_MODS(BUILD_PATH BUILD_PART BUILD_ROBOT)
  357. REQUIRES_MODS(BUILD_RAYTRACING BUILD_PART)
  358. REQUIRES_MODS(BUILD_REVERSEENGINEERING BUILD_PART BUILD_MESH)
  359. REQUIRES_MODS(BUILD_ROBOT BUILD_PART)
  360. REQUIRES_MODS(BUILD_SANDBOX BUILD_PART BUILD_MESH)
  361. REQUIRES_MODS(BUILD_SHIP BUILD_PART BUILD_PLOT BUILD_IMAGE)
  362. REQUIRES_MODS(BUILD_SKETCHER BUILD_PART)
  363. REQUIRES_MODS(BUILD_SPREADSHEET BUILD_DRAFT)
  364. REQUIRES_MODS(BUILD_START BUILD_WEB)
  365. REQUIRES_MODS(BUILD_TECHDRAW BUILD_PART BUILD_SPREADSHEET BUILD_DRAWING)
  366. # ==============================================================================
  367. if(FREECAD_LIBPACK_USE)
  368. # checking for a unique file in LibPack location to make sure the right version of the LibPack is there
  369. find_file(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER MANIFEST.db ${FREECAD_LIBPACK_DIR})
  370. # don't show them in the GUI
  371. set(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER "${FREECAD_LIBPACK_CHECKFILE_CLBUNDLER}" CACHE INTERNAL "Find libpack")
  372. if (FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
  373. set(FREECAD_LIBPACK_VERSION "CLbundler" CACHE STRING "Displays if the libpack has been found" FORCE)
  374. include(cMake/UseLibPackCLbundler.cmake)
  375. else(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
  376. set(FREECAD_LIBPACK_VERSION "NOTFOUND" CACHE STRING "Displays if the libpack has been found" FORCE)
  377. message(SEND_ERROR "Could not find libpack in specified location:" ${FREECAD_LIBPACK_DIR})
  378. endif(FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
  379. # -------------------------------- PyCXX --------------------------------
  380. find_package(PyCXX REQUIRED)
  381. # -------------------------------- Swig ----------------------------------
  382. find_package(SWIG)
  383. if(NOT SWIG_FOUND)
  384. message("==================================================\n"
  385. "SWIG not found, don't build SWIG binding for pivy.\n"
  386. "==================================================\n")
  387. endif(NOT SWIG_FOUND)
  388. # -------------------------------- Salome SMESH --------------------------
  389. if(NOT FREECAD_USE_EXTERNAL_SMESH)
  390. set(SMESH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc)
  391. endif()
  392. endif(FREECAD_LIBPACK_USE)
  393. if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
  394. # ================================================================================
  395. # == Search the packages =========================================================
  396. # -------------------------------- Python --------------------------------
  397. # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=677598
  398. # Acceptable versions of Python
  399. set(Python_ADDITIONAL_VERSIONS "2.7")
  400. # For building on OS X
  401. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT BUILD_WITH_CONDA)
  402. # If the user doesn't tell us which package manager they're using
  403. if(NOT DEFINED MACPORTS_PREFIX AND NOT DEFINED HOMEBREW_PREFIX)
  404. # Try to find MacPorts path
  405. find_program(MACPORTS_EXECUTABLE port)
  406. if(EXISTS ${MACPORTS_EXECUTABLE})
  407. string(REPLACE "/bin/port" ""
  408. MACPORTS_PREFIX ${MACPORTS_EXECUTABLE})
  409. message(STATUS "Detected MacPorts install at ${MACPORTS_PREFIX}")
  410. endif(EXISTS ${MACPORTS_EXECUTABLE})
  411. # Try to find Homebrew path
  412. find_program(HOMEBREW_EXECUTABLE brew)
  413. if(EXISTS ${HOMEBREW_EXECUTABLE})
  414. string(REPLACE "/bin/brew" ""
  415. HOMEBREW_PREFIX ${HOMEBREW_EXECUTABLE})
  416. message(STATUS "Detected Homebrew install at ${HOMEBREW_PREFIX}")
  417. endif()
  418. endif(NOT DEFINED MACPORTS_PREFIX AND NOT DEFINED HOMEBREW_PREFIX)
  419. # In case someone tries to shoot themselves in the foot
  420. if(DEFINED MACPORTS_PREFIX AND DEFINED HOMEBREW_PREFIX)
  421. message(SEND_ERROR
  422. "Multiple package management systems detected - ")
  423. message(SEND_ERROR
  424. "define either MACPORTS_PREFIX or HOMEBREW_PREFIX")
  425. # No package manager
  426. elseif(NOT DEFINED MACPORTS_PREFIX AND NOT DEFINED HOMEBREW_PREFIX)
  427. message(SEND_ERROR
  428. "No package manager detected - install MacPorts or Homebrew")
  429. # The hopefully-normal case - one package manager identified
  430. else(DEFINED MACPORTS_PREFIX AND DEFINED HOMEBREW_PREFIX)
  431. # Construct a list like python;python2.9;python2.8;...
  432. set(Python_ADDITIONAL_VERSIONS_REV ${Python_ADDITIONAL_VERSIONS})
  433. list(REVERSE Python_ADDITIONAL_VERSIONS_REV)
  434. set(_PYTHON_NAMES "python")
  435. foreach(_PYTHON_VERSION IN LISTS Python_ADDITIONAL_VERSIONS_REV)
  436. list(APPEND _PYTHON_NAMES "python${_PYTHON_VERSION}")
  437. endforeach(_PYTHON_VERSION)
  438. # Find python in the package management systems, using names in that
  439. # list in decreasing priority. Note that a manually specified
  440. # PYTHON_EXECUTABLE still has prescedence over this.
  441. find_program(PYTHON_EXECUTABLE
  442. NAMES ${_PYTHON_NAMES}
  443. PATHS ${MACPORTS_PREFIX} ${HOMEBREW_PREFIX}
  444. PATH_SUFFIXES /bin
  445. NO_DEFAULT_PATH)
  446. endif(DEFINED MACPORTS_PREFIX AND DEFINED HOMEBREW_PREFIX)
  447. # Warn user if we still only have the system Python
  448. string(FIND ${PYTHON_EXECUTABLE} "/usr/bin/python" _FIND_SYS_PYTHON)
  449. if(_FIND_SYS_PYTHON EQUAL 0)
  450. message(SEND_ERROR
  451. "Only found the stock Python, that's probably bad.")
  452. endif(_FIND_SYS_PYTHON EQUAL 0)
  453. # Ask Python to tell us it's include directory, if nobody else has
  454. if(NOT DEFINED PYTHON_INCLUDE_DIR)
  455. execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
  456. "from distutils.sysconfig import get_python_inc;print(get_python_inc())"
  457. OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
  458. RESULT_VARIABLE PYTHON_INCLUDE_DIR_RESULT
  459. ERROR_QUIET)
  460. if(NOT PYTHON_INCLUDE_DIR_RESULT MATCHES 0)
  461. message(SEND_ERROR "Failed to determine PYTHON_INCLUDE_DIR")
  462. endif(NOT PYTHON_INCLUDE_DIR_RESULT MATCHES 0)
  463. endif(NOT DEFINED PYTHON_INCLUDE_DIR)
  464. # Similar for the Python library - there must be an easier way...
  465. if(NOT DEFINED PYTHON_LIBRARY)
  466. # Get the library path
  467. execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
  468. "from distutils import sysconfig;print(sysconfig.get_config_var('LIBDIR'))"
  469. OUTPUT_VARIABLE PYTHON_LIBRARY_DIR
  470. RESULT_VARIABLE PYTHON_LIBRARY_DIR_RESULT
  471. ERROR_QUIET)
  472. string(STRIP ${PYTHON_LIBRARY_DIR} PYTHON_LIBRARY_DIR)
  473. if(NOT PYTHON_LIBRARY_DIR_RESULT MATCHES 0)
  474. message(SEND_ERROR "Failed to determine PYTHON_LIBRARY")
  475. endif(NOT PYTHON_LIBRARY_DIR_RESULT MATCHES 0)
  476. # Get library filename - might not be safe to assume .dylib extension?
  477. execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
  478. "import sys;print('libpython%d.%d.dylib'%sys.version_info[0:2])"
  479. OUTPUT_VARIABLE PYTHON_LIBRARY_FILE
  480. RESULT_VARIABLE PYTHON_LIBRARY_FILE_RESULT
  481. ERROR_QUIET)
  482. string(STRIP ${PYTHON_LIBRARY_FILE} PYTHON_LIBRARY_FILE)
  483. if(NOT PYTHON_LIBRARY_FILE_RESULT MATCHES 0)
  484. message(SEND_ERROR "Failed to determine PYTHON_LIBRARY")
  485. endif(NOT PYTHON_LIBRARY_FILE_RESULT MATCHES 0)
  486. set(PYTHON_LIBRARY "${PYTHON_LIBRARY_DIR}/${PYTHON_LIBRARY_FILE}")
  487. else(NOT DEFINED PYTHON_LIBRARY)
  488. # Used on MacPorts systems for finding Shiboken and PySide
  489. # TODO: When we start requiring minimum CMake version above
  490. # 2.8.11, change PATH below to DIRECTORY
  491. get_filename_component(PYTHON_LIBRARY_DIR ${PYTHON_LIBRARY} PATH)
  492. endif(NOT DEFINED PYTHON_LIBRARY)
  493. endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT BUILD_WITH_CONDA)
  494. find_package(PythonInterp REQUIRED)
  495. set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
  496. if (NOT DEFINED PYTHON_VERSION_STRING)
  497. find_package(PythonLibs REQUIRED)
  498. else (NOT DEFINED PYTHON_VERSION_STRING)
  499. find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
  500. endif(NOT DEFINED PYTHON_VERSION_STRING)
  501. if(NOT PYTHONLIBS_FOUND)
  502. message(FATAL_ERROR "=================================\n"
  503. "Python not found, install Python!\n"
  504. "=================================\n")
  505. else(NOT PYTHONLIBS_FOUND)
  506. # prevent python3 lower than 3.3 (not enough utf8<->unicode tools)
  507. if(PYTHON_VERSION_MAJOR EQUAL 3)
  508. if(PYTHON_VERSION_MINOR LESS 4)
  509. message(FATAL_ERROR "To build FreeCAD with Python3, you need at least version 3.4\n")
  510. endif(PYTHON_VERSION_MINOR LESS 4)
  511. endif(PYTHON_VERSION_MAJOR EQUAL 3)
  512. endif(NOT PYTHONLIBS_FOUND)
  513. # -------------------------------- pcl ----------------------------------
  514. # Can be used by ReverseEngineering module"
  515. #
  516. # PCL needs to be found before boost because the PCLConfig also calls find_package(Boost ...),
  517. # but with different components
  518. if(FREECAD_USE_PCL)
  519. find_package(PCL REQUIRED COMPONENTS common kdtree features surface io filters segmentation sample_consensus)
  520. endif(FREECAD_USE_PCL)
  521. # -------------------------------- PyBind11 -----------------------------
  522. # necessary for flat-mesh feature
  523. option(FREECAD_USE_PYBIND11 "Use pybind11" OFF)
  524. if (FREECAD_USE_PYBIND11)
  525. find_package(pybind11 REQUIRED)
  526. endif()
  527. # -------------------------------- Boost --------------------------------
  528. set(_boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS})
  529. set (BOOST_COMPONENTS filesystem program_options regex system thread)
  530. find_package(Boost ${BOOST_MIN_VERSION}
  531. COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
  532. if(UNIX AND NOT APPLE)
  533. # Boost.Thread 1.67+ headers reference pthread_condattr_*
  534. list(APPEND Boost_LIBRARIES pthread)
  535. endif()
  536. if(NOT Boost_FOUND)
  537. set (NO_BOOST_COMPONENTS)
  538. foreach (comp ${BOOST_COMPONENTS})
  539. string(TOUPPER ${comp} uppercomp)
  540. if (NOT Boost_${uppercomp}_FOUND)
  541. list(APPEND NO_BOOST_COMPONENTS ${comp})
  542. endif()
  543. endforeach()
  544. message(FATAL_ERROR "=============================================\n"
  545. "Required components:\n"
  546. " ${BOOST_COMPONENTS}\n"
  547. "Not found, install the components:\n"
  548. " ${NO_BOOST_COMPONENTS}\n"
  549. "=============================================\n")
  550. endif(NOT Boost_FOUND)
  551. # -------------------------------- XercesC --------------------------------
  552. find_package(XercesC REQUIRED)
  553. if(NOT XercesC_FOUND)
  554. message(FATAL_ERROR "==================\n"
  555. "XercesC not found.\n"
  556. "==================\n")
  557. endif(NOT XercesC_FOUND)
  558. # -------------------------------- ZLIB --------------------------------
  559. find_package(ZLIB REQUIRED)
  560. # -------------------------------- PyCXX --------------------------------
  561. find_package(PyCXX REQUIRED)
  562. # -------------------------------- OpenCasCade --------------------------------
  563. find_package(OpenCasCade)
  564. if(NOT OCC_FOUND)
  565. message(FATAL_ERROR "================================================================\n"
  566. "Neither OpenCASCADE Community Edition nor OpenCASCADE was found!\n"
  567. "================================================================\n")
  568. endif(NOT OCC_FOUND)
  569. # -------------------------------- Salome SMESH --------------------------
  570. # Salome SMESH sources are under src/3rdParty now
  571. if(BUILD_SMESH)
  572. # set the internal smesh version:
  573. # see src/3rdParty/salomonemesh/CMakeLists.txt and commit https://github.com/FreeCAD/FreeCAD/commit/666a3e5 and https://forum.freecadweb.org/viewtopic.php?f=10&t=30838
  574. set(SMESH_VERSION_MAJOR 7)
  575. set(SMESH_VERSION_MINOR 7)
  576. set(SMESH_VERSION_PATCH 1)
  577. set(SMESH_VERSION_TWEAK 0)
  578. #if we use smesh we definitely also need vtk, no matter of external or internal smesh
  579. set (VTK_COMPONENTS
  580. vtkCommonCore
  581. vtkCommonDataModel
  582. vtkFiltersVerdict
  583. vtkIOXML
  584. vtkFiltersCore
  585. vtkFiltersGeneral
  586. vtkIOLegacy
  587. vtkFiltersExtraction
  588. vtkFiltersSources
  589. vtkFiltersGeometry
  590. )
  591. # check which modules are available
  592. if(UNIX OR WIN32)
  593. find_package(VTK COMPONENTS vtkCommonCore REQUIRED NO_MODULE)
  594. list(APPEND VTK_COMPONENTS vtkIOMPIParallel vtkParallelMPI vtkhdf5 vtkFiltersParallelDIY2 vtkRenderingCore vtkInteractionStyle vtkRenderingFreeType vtkRenderingOpenGL2)
  595. foreach(_module ${VTK_COMPONENTS})
  596. list (FIND VTK_MODULES_ENABLED ${_module} _index)
  597. if (${_index} GREATER -1)
  598. list(APPEND AVAILABLE_VTK_COMPONENTS ${_module})
  599. endif()
  600. endforeach()
  601. endif()
  602. # don't check VERSION 6 as this would exclude VERSION 7
  603. if(AVAILABLE_VTK_COMPONENTS)
  604. message(STATUS "VTK components: ${AVAILABLE_VTK_COMPONENTS}")
  605. find_package(VTK COMPONENTS ${AVAILABLE_VTK_COMPONENTS} REQUIRED NO_MODULE)
  606. else()
  607. message(STATUS "VTK components: not found or used")
  608. find_package(VTK REQUIRED NO_MODULE)
  609. endif()
  610. set(BUILD_FEM_VTK ON)
  611. if(${VTK_MAJOR_VERSION} LESS 6)
  612. message( FATAL_ERROR "Found VTK version is <6, this is not compatible" )
  613. endif()
  614. if(${VTK_MAJOR_VERSION} EQUAL 6)
  615. if(${VTK_MINOR_VERSION} LESS 2)
  616. set(VTK_OPTIONS -DVTK_NO_QUAD_POLY)
  617. endif()
  618. if(${VTK_MINOR_VERSION} EQUAL 0)
  619. message(WARNING "VTK equal to 6.0 cannot be used with c++11, FEM postprocessing is disabled")
  620. set(BUILD_FEM_VTK OFF)
  621. endif()
  622. endif()
  623. # on openSUSE 13.1 VTK_LIBRARIES ends with "optimized" keyword
  624. list(REMOVE_ITEM VTK_LIBRARIES "optimized" "debug")
  625. if(NOT FREECAD_USE_EXTERNAL_SMESH)
  626. find_package(MEDFile REQUIRED)
  627. # See https://www.hdfgroup.org/HDF5/release/cmakebuild.html
  628. if (WIN32)
  629. find_package(HDF5 COMPONENTS NO_MODULE REQUIRED static)
  630. else()
  631. find_package(PkgConfig)
  632. file(READ ${meddotH} TMPTXT)
  633. string(FIND "${TMPTXT}" "#define MED_HAVE_MPI" matchres)
  634. if(${matchres} EQUAL -1)
  635. message(STATUS "We guess that libmed was built using hdf5-serial version")
  636. set(HDF5_VARIANT "hdf5-serial")
  637. else()
  638. message(STATUS "We guess that libmed was built using hdf5-openmpi version")
  639. set(HDF5_VARIANT "hdf5-openmpi")
  640. set(HDF5_PREFER_PARALLEL TRUE) # if pkg-config fails, find_package(HDF5) needs this
  641. endif()
  642. pkg_search_module(HDF5 ${HDF5_VARIANT})
  643. if(NOT HDF5_FOUND)
  644. find_package(HDF5 REQUIRED)
  645. else()
  646. add_compile_options(${HDF5_CFLAGS})
  647. link_directories(${HDF5_LIBRARY_DIRS})
  648. link_libraries(${HDF5_LIBRARIES})
  649. find_file(Hdf5dotH hdf5.h PATHS ${HDF5_INCLUDE_DIRS} NO_DEFAULT_PATH)
  650. if(NOT Hdf5dotH)
  651. message( FATAL_ERROR "${HDF5_VARIANT} development header not found.")
  652. endif()
  653. endif()
  654. check_include_file_cxx(hdf5.h HDF5_FOUND)
  655. if(NOT HDF5_FOUND)
  656. message( FATAL_ERROR "hdf5.h was not found.")
  657. endif()
  658. # Med Fichier can require MPI
  659. pkg_search_module(OPENMPI ompi-cxx)
  660. add_compile_options(${OPENMPI_CFLAGS})
  661. link_directories(${OPENMPI_LIBRARY_DIRS})
  662. link_libraries(${OPENMPI_LIBRARIES})
  663. find_file(MpidotH mpi.h PATHS ${OPENMPI_INCLUDE_DIRS} NO_DEFAULT_PATH)
  664. if(NOT MpidotH)
  665. message( WARNING "mpi.h was not found. Check for error above.")
  666. endif()
  667. endif()
  668. set(SMESH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc)
  669. else(NOT FREECAD_USE_EXTERNAL_SMESH)
  670. find_package(SMESH CONFIG)
  671. set (SMESH_INCLUDE_DIR ${SMESH_INCLUDE_PATH})
  672. set(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES})
  673. if(NOT SMESH_FOUND)
  674. message(ERROR "================\n"
  675. "SMESH not found.\n"
  676. "================\n")
  677. endif()
  678. include_directories(${SMESH_INCLUDE_DIR})
  679. endif()
  680. set(SMESH_FOUND TRUE)
  681. configure_file(SMESH_Version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/SMESH_Version.h)
  682. endif(BUILD_SMESH)
  683. # -------------------------------- Netgen --------------------------------
  684. if (BUILD_FEM_NETGEN)
  685. find_package(NETGEN)
  686. endif(BUILD_FEM_NETGEN)
  687. # -------------------------------- OpenCV --------------------------------
  688. # not needed at the moment
  689. #find_package(OpenCV REQUIRED)
  690. # -------------------------------- Swig ----------------------------------
  691. find_package(SWIG)
  692. if (NOT SWIG_FOUND)
  693. message("=====================================================\n"
  694. "SWIG not found, will not build SWIG binding for pivy.\n"
  695. "=====================================================\n")
  696. endif(NOT SWIG_FOUND)
  697. # -------------------------------- Eigen --------------------------------
  698. # necessary for Sketcher module
  699. # necessary for Robot module
  700. find_package(Eigen3)
  701. if(NOT EIGEN3_FOUND)
  702. message("=================\n"
  703. "Eigen3 not found.\n"
  704. "=================\n")
  705. endif(NOT EIGEN3_FOUND)
  706. if (${EIGEN3_VERSION} VERSION_LESS "3.3.1")
  707. message(WARNING "Disable module flatmesh because it requires "
  708. "minimum Eigen3 version 3.3.1 but version ${EIGEN3_VERSION} was found")
  709. set (BUILD_FLAT_MESH OFF)
  710. endif()
  711. # -------------------------------- Qt --------------------------------
  712. if (NOT BUILD_QT5)
  713. # If using MacPorts, help the Qt4 finder.
  714. if(MACPORTS_PREFIX)
  715. if(NOT QT_QMAKE_EXECUTABLE)
  716. set(QT_QMAKE_EXECUTABLE ${MACPORTS_PREFIX}/libexec/qt4/bin/qmake)
  717. endif()
  718. endif()
  719. set(QT_MIN_VERSION 4.5.0)
  720. set(QT_USE_QTNETWORK TRUE)
  721. set(QT_USE_QTXML TRUE)
  722. if(BUILD_GUI)
  723. set(QT_USE_QTOPENGL TRUE)
  724. set(QT_USE_QTSVG TRUE)
  725. set(QT_USE_QTUITOOLS TRUE)
  726. set(QT_USE_QTWEBKIT TRUE)
  727. endif(BUILD_GUI)
  728. find_package(Qt4)# REQUIRED
  729. include(${QT_USE_FILE})
  730. if(NOT QT4_FOUND)
  731. message(FATAL_ERROR "========================\n"
  732. "Qt4 libraries not found.\n"
  733. "========================\n")
  734. endif(NOT QT4_FOUND)
  735. if(NOT QT_QTWEBKIT_FOUND)
  736. message("========================================================\n"
  737. "Qt Webkit not found, will not build browser integration.\n"
  738. "========================================================\n")
  739. endif(NOT QT_QTWEBKIT_FOUND)
  740. # This is a special version of the built in macro qt4_wrap_cpp
  741. # It is required since moc'ed files are now included instead of being added to projects directly
  742. # It adds a reverse dependency to solve this
  743. # This has the unfortunate side effect that some files are always rebuilt
  744. # There is probably a cleaner solution than this
  745. macro(fc_wrap_cpp outfiles)
  746. # get include dirs
  747. QT4_GET_MOC_FLAGS(moc_flags)
  748. QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN})
  749. # fixes bug 0000585: bug with boost 1.48
  750. set(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
  751. foreach(it ${moc_files})
  752. get_filename_component(it ${it} ABSOLUTE)
  753. QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
  754. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  755. COMMAND ${QT_MOC_EXECUTABLE}
  756. ARGS ${moc_options} ${it} -o ${outfile}
  757. MAIN_DEPENDENCY ${it}
  758. )
  759. set(${outfiles} ${${outfiles}} ${outfile})
  760. add_file_dependencies(${it} ${outfile})
  761. endforeach(it)
  762. endmacro(fc_wrap_cpp)
  763. elseif (BUILD_QT5)
  764. find_package(Qt5Core REQUIRED)
  765. find_package(Qt5Network REQUIRED)
  766. find_package(Qt5Xml REQUIRED)
  767. find_package(Qt5XmlPatterns REQUIRED)
  768. if(BUILD_GUI)
  769. find_package(Qt5Widgets REQUIRED)
  770. find_package(Qt5PrintSupport REQUIRED)
  771. find_package(Qt5OpenGL REQUIRED)
  772. find_package(Qt5Svg REQUIRED)
  773. find_package(Qt5UiTools REQUIRED)
  774. find_package(Qt5Concurrent REQUIRED)
  775. if (BUILD_WEB)
  776. if (${FREECAD_USE_QTWEBMODULE} MATCHES "Qt Webkit")
  777. find_package(Qt5WebKitWidgets REQUIRED)
  778. elseif(${FREECAD_USE_QTWEBMODULE} MATCHES "Qt WebEngine")
  779. find_package(Qt5WebEngineWidgets REQUIRED)
  780. if (Qt5WebEngineWidgets_VERSION VERSION_LESS 5.7.0)
  781. message(FATAL_ERROR "** Minimum supported Qt5WebEngine version is 5.7.0!\n")
  782. endif()
  783. else() # Automatic
  784. find_package(Qt5WebKitWidgets QUIET)
  785. if(NOT Qt5WebKitWidgets_FOUND)
  786. find_package(Qt5WebEngineWidgets REQUIRED)
  787. if (Qt5WebEngineWidgets_VERSION VERSION_LESS 5.7.0)
  788. message(FATAL_ERROR "** Minimum supported Qt5WebEngine version is 5.7.0!\n")
  789. endif()
  790. endif()
  791. endif()
  792. endif()
  793. if(MSVC AND ${Qt5Core_VERSION} VERSION_GREATER "5.2.0")
  794. find_package(Qt5WinExtras QUIET)
  795. endif()
  796. endif(BUILD_GUI)
  797. # This is a special version of the built in macro qt5_wrap_cpp
  798. # It is required since moc'ed files are now included instead of being added to projects directly
  799. # It adds a reverse dependency to solve this
  800. # This has the unfortunate side effect that some files are always rebuilt
  801. # There is probably a cleaner solution than this
  802. macro(fc_wrap_cpp outfiles )
  803. # get include dirs
  804. qt5_get_moc_flags(moc_flags)
  805. set(moc_files ${ARGN})
  806. # fixes bug 0000585: bug with boost 1.48
  807. set(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
  808. foreach(it ${moc_files})
  809. get_filename_component(it ${it} ABSOLUTE)
  810. qt5_make_output_file(${it} moc_ cpp outfile)
  811. qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
  812. set(${outfiles} ${${outfiles}} ${outfile})
  813. add_file_dependencies(${it} ${outfile})
  814. endforeach(it)
  815. endmacro(fc_wrap_cpp)
  816. endif (NOT BUILD_QT5)
  817. #--------------------FreeType-----------------------
  818. if(FREECAD_USE_FREETYPE)
  819. find_package(Freetype)
  820. if(NOT FREETYPE_FOUND)
  821. message("===============================================================\n"
  822. "FreeType2 not found. Part module will lack of makeWireString().\n"
  823. "===============================================================\n")
  824. endif(NOT FREETYPE_FOUND)
  825. endif(FREECAD_USE_FREETYPE)
  826. #---------------------------------------------------
  827. if(BUILD_GUI)
  828. # -------------------------------- OpenGL --------------------------------
  829. find_package(OpenGL)
  830. include(FindPackageMessage)
  831. if(OPENGL_GLU_FOUND)
  832. find_package_message(OPENGL_GLU
  833. "Found OpenGLU: ${OPENGL_glu_LIBRARY}"
  834. "[${OPENGL_glu_LIBRARY}][${OPENGL_INCLUDE_DIR}]")
  835. else(OPENGL_GLU_FOUND)
  836. message(FATAL_ERROR "======================\n"
  837. "GLU library not found.\n"
  838. "======================\n")
  839. endif(OPENGL_GLU_FOUND)
  840. # -------------------------------- Coin3D --------------------------------
  841. find_package(Coin3D REQUIRED)
  842. if(NOT COIN3D_FOUND)
  843. message(FATAL_ERROR "=================\n"
  844. "Coin3D not found.\n"
  845. "=================\n")
  846. endif(NOT COIN3D_FOUND)
  847. # ------------------------------ Spaceball -------------------------------
  848. if (WIN32)
  849. #future
  850. else(WIN32)
  851. find_package(Spnav)
  852. endif(WIN32)
  853. # -------------------------------- Shiboken/PySide ------------------------
  854. if(BUILD_QT5)
  855. # set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
  856. # Below are two variables that can be left empty for standard python 3 version,
  857. # but must be set by the user for different python versions such as 2.7, 3.5 ...
  858. if (PYTHON_VERSION_MAJOR LESS 3)
  859. set(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
  860. set(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
  861. else()
  862. #set(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
  863. #set(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
  864. endif()
  865. if(DEFINED MACPORTS_PREFIX)
  866. find_package(Shiboken REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
  867. find_package(PySide REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
  868. endif(DEFINED MACPORTS_PREFIX)
  869. # Shiboken2Config.cmake may explicitly set CMAKE_BUILD_TYPE to Release which causes
  870. # CMake to fail to create Makefiles for a debug build.
  871. # So as a workaround we save and restore the value after checking for Shiboken2.
  872. set (SAVE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
  873. find_package(Shiboken2 QUIET)# REQUIRED
  874. set (CMAKE_BUILD_TYPE ${SAVE_BUILD_TYPE})
  875. if (Shiboken2_FOUND)
  876. # Shiboken2 config file was found but it may use the wrong Python version
  877. # Try to get the matching config suffix and repeat finding the package
  878. if (PYTHON_VERSION_MAJOR LESS 3)
  879. set(SHIBOKEN_PATTERN -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
  880. else()
  881. set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
  882. endif()
  883. file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake")
  884. if (SHIBOKEN_CONFIG)
  885. get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME)
  886. string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX)
  887. string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX})
  888. message(STATUS "PYTHON_CONFIG_SUFFIX: ${PYTHON_CONFIG_SUFFIX}")
  889. find_package(Shiboken2 QUIET)
  890. endif()
  891. endif()
  892. if(NOT SHIBOKEN_INCLUDE_DIR)
  893. message("====================\n"
  894. "shiboken2 not found.\n"
  895. "====================\n")
  896. endif(NOT SHIBOKEN_INCLUDE_DIR)
  897. find_package(PySide2 QUIET)# REQUIRED
  898. if(NOT PYSIDE_INCLUDE_DIR)
  899. message("==================\n"
  900. "PySide2 not found.\n"
  901. "==================\n")
  902. endif(NOT PYSIDE_INCLUDE_DIR)
  903. find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc)
  904. if(NOT PYSIDE2_TOOLS_FOUND)
  905. message("=======================\n"
  906. "PySide2Tools not found.\n"
  907. "=======================\n")
  908. endif(NOT PYSIDE2_TOOLS_FOUND)
  909. file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide)
  910. file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n"
  911. "from PySide2 import __version__\n"
  912. "from PySide2 import __version_info__\n")
  913. file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n"
  914. "#QCoreApplication.CodecForTr=0\n"
  915. "#QCoreApplication.UnicodeUTF8=1\n")
  916. file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n"
  917. "from PySide2.QtWidgets import *\n"
  918. "QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n")
  919. file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n")
  920. file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtUiTools.py "from PySide2.QtUiTools import *\n")
  921. if(APPLE AND NOT BUILD_WITH_CONDA)
  922. install(
  923. DIRECTORY
  924. ${CMAKE_BINARY_DIR}/Ext/PySide
  925. DESTINATION
  926. MacOS
  927. )
  928. else()
  929. install(
  930. DIRECTORY
  931. ${CMAKE_BINARY_DIR}/Ext/PySide
  932. DESTINATION
  933. Ext
  934. )
  935. endif()
  936. else(BUILD_QT5)
  937. # set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
  938. # Below are two variables that can be left empty for standard python 3 version,
  939. # but must be set by the user for different python versions such as 2.7, 3.5 ...
  940. if (PYTHON_VERSION_MAJOR LESS 3)
  941. set(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
  942. set(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
  943. else()
  944. set(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
  945. set(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
  946. endif()
  947. if(DEFINED MACPORTS_PREFIX)
  948. find_package(Shiboken REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
  949. find_package(PySide REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
  950. endif(DEFINED MACPORTS_PREFIX)
  951. find_package(Shiboken)# REQUIRED
  952. if(NOT SHIBOKEN_INCLUDE_DIR)
  953. message(FATAL_ERROR "===================\n"
  954. "shiboken not found.\n"
  955. "===================\n")
  956. endif(NOT SHIBOKEN_INCLUDE_DIR)
  957. find_package(PySide)# REQUIRED
  958. if(NOT PYSIDE_INCLUDE_DIR)
  959. message(FATAL_ERROR "=================\n"
  960. "PySide not found.\n"
  961. "=================\n")
  962. endif(NOT PYSIDE_INCLUDE_DIR)
  963. find_package(PySideTools REQUIRED) # PySide utilities (pyside-uic & pyside-rcc)
  964. endif(BUILD_QT5)
  965. # ------------------------------ Matplotlib ------------------------------
  966. find_package(Matplotlib)
  967. if (MATPLOTLIB_FOUND)
  968. message(STATUS "-- matplotlib-${MATPLOTLIB_VERSION} has been found.")
  969. else(MATPLOTLIB_FOUND)
  970. message("=====================================================\n"
  971. "matplotlib not found, Plot module won't be available.\n"
  972. "=====================================================\n")
  973. endif(MATPLOTLIB_FOUND)
  974. # ------------------------------------------------------------------------
  975. endif(BUILD_GUI)
  976. endif(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
  977. if(BUILD_VR)
  978. find_package(Rift)
  979. endif(BUILD_VR)
  980. # version information of libraries
  981. #
  982. if(OCC_INCLUDE_DIR AND EXISTS ${OCC_INCLUDE_DIR}/Standard_Version.hxx)
  983. set(HAVE_OCC_VERSION 1)
  984. endif(OCC_INCLUDE_DIR AND EXISTS ${OCC_INCLUDE_DIR}/Standard_Version.hxx)
  985. configure_file(LibraryVersions.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/LibraryVersions.h)
  986. # ================================================================================
  987. # == Global Compiler and Linker Settings =========================================
  988. include_directories(${CMAKE_BINARY_DIR}/src
  989. ${CMAKE_SOURCE_DIR}/src)
  990. # check for 64-bit platform
  991. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  992. message(STATUS "Platform is 64-bit, set -D_OCC64")
  993. add_definitions(-D_OCC64 )
  994. else(CMAKE_SIZEOF_VOID_P EQUAL 8)
  995. message(STATUS "Platform is 32-bit")
  996. endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
  997. if(MSVC)
  998. # set default compiler settings
  999. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zm150 /bigobj")
  1000. set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFC_DEBUG /Zm150 /bigobj")
  1001. # set default libs
  1002. set (CMAKE_C_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib SHFolder.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib winmm.lib comsupp.lib Ws2_32.lib dbghelp.lib ")
  1003. set (CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}")
  1004. # set linker flag /nodefaultlib
  1005. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB")
  1006. set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /NODEFAULTLIB")
  1007. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB")
  1008. if(FREECAD_RELEASE_PDB)
  1009. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
  1010. set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG")
  1011. endif(FREECAD_RELEASE_PDB)
  1012. if(FREECAD_RELEASE_SEH)
  1013. # remove /EHsc or /EHs flags because they are incompatible with /EHa
  1014. if (${CMAKE_BUILD_TYPE} MATCHES "Release")
  1015. string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  1016. string(REPLACE "/EHs" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  1017. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHa")
  1018. endif()
  1019. endif(FREECAD_RELEASE_SEH)
  1020. option(FREECAD_USE_MP_COMPILE_FLAG "Add /MP flag to the compiler definitions. Speeds up the compile on multi processor machines" OFF)
  1021. if(FREECAD_USE_MP_COMPILE_FLAG)
  1022. # set "Build with Multiple Processes"
  1023. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
  1024. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
  1025. endif()
  1026. # Mark 32 bit executables large address aware so they can use > 2GB address space
  1027. # NOTE: This setting only has an effect on machines with at least 3GB of RAM, although it sets the linker option it doesn't set the linker switch 'Enable Large Addresses'
  1028. if(CMAKE_SIZEOF_VOID_P EQUAL 4)
  1029. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE")
  1030. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
  1031. endif(CMAKE_SIZEOF_VOID_P EQUAL 4)
  1032. else(MSVC)
  1033. set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFC_DEBUG")
  1034. #message(STATUS "DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
  1035. endif(MSVC)
  1036. if(MINGW)
  1037. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12477
  1038. # Actually '-Wno-inline-dllimport' should work to suppress warnings of the form:
  1039. # inline function 'foo' is declared as dllimport: attribute ignored
  1040. # But it doesn't work with MinGW gcc 4.5.0 while using '-Wno-attributes' seems to
  1041. # do the trick.
  1042. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads -Wno-attributes")
  1043. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthreads -Wno-attributes")
  1044. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
  1045. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
  1046. # http://stackoverflow.com/questions/8375310/warning-auto-importing-has-been-activated-without-enable-auto-import-specifie
  1047. # set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
  1048. link_libraries(-lgdi32)
  1049. endif(MINGW)
  1050. add_subdirectory(src)
  1051. add_subdirectory(data)
  1052. # ================================================================================
  1053. # == Packaging ===================================================================
  1054. #
  1055. #add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
  1056. add_custom_target(dist-git
  1057. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
  1058. --srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR}
  1059. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1060. )
  1061. add_custom_target(distdfsg-git
  1062. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
  1063. --srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg
  1064. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1065. )
  1066. if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
  1067. add_custom_target(distcheck-git
  1068. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
  1069. --srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --check
  1070. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1071. )
  1072. add_custom_target(distcheckdfsg-git
  1073. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
  1074. --srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg --check
  1075. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1076. )
  1077. endif(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
  1078. # -------------------------------- The final report ----------------------------------
  1079. message(STATUS "\n==============\n"
  1080. "Summary report\n"
  1081. "==============\n")
  1082. if (DEFINED CMAKE_BUILD_TYPE)
  1083. message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
  1084. endif()
  1085. # Qt5 needs/sets PYTHON_CONFIG_SUFFIX regarding Shiboken
  1086. message(STATUS "Python: [${PYTHON_EXECUTABLE}] [${PYTHON_CONFIG_SUFFIX}]")
  1087. if(DEFINED PCL_FOUND)
  1088. message(STATUS "PCL: ${PCL_VERSION}")
  1089. else(DEFINED PCL_FOUND)
  1090. message(STATUS "PCL: not enabled")
  1091. endif(DEFINED PCL_FOUND)
  1092. if(DEFINED pybind11_FOUND)
  1093. message(STATUS "pybind11: ${pybind11_VERSION}")
  1094. else(DEFINED pybind11_FOUND)
  1095. message(STATUS "pybind11: not enabled")
  1096. endif(DEFINED pybind11_FOUND)
  1097. message(STATUS "Boost: ${Boost_VERSION}")
  1098. message(STATUS "XercesC: [${XercesC_LIBRARIES}] [${XercesC_INCLUDE_DIRS}]")
  1099. message(STATUS "ZLIB: ${ZLIB_VERSION_STRING}")
  1100. message(STATUS "PyCXX: [${PYCXX_INCLUDE_DIR}]")
  1101. message(STATUS "OCC: ${OCC_VERSION_STRING} [${OCC_LIBRARIES}]")
  1102. if(BUILD_SMESH)
  1103. if(FREECAD_USE_EXTERNAL_SMESH)
  1104. message(STATUS "SMESH: ${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK}")
  1105. else(FREECAD_USE_EXTERNAL_SMESH)
  1106. message(STATUS "SMESH: build internal")
  1107. message(STATUS " MEDFile: [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]")
  1108. message(STATUS " HDF5: ${HDF5_VERSION}")
  1109. message(STATUS " VTK: ${VTK_VERSION}")
  1110. endif(FREECAD_USE_EXTERNAL_SMESH)
  1111. else(BUILD_SMESH)
  1112. message(STATUS "SMESH: do not build")
  1113. endif(BUILD_SMESH)
  1114. if(DEFINED NETGEN_FOUND)
  1115. message(STATUS "NETGEN: ${NETGEN_VERSION} [${NETGEN_DEFINITIONS}] [${NETGEN_CXX_FLAGS}] [${NGLIB_INCLUDE_DIR}] [${NGLIB_LIBRARIES}] [${NETGEN_INCLUDE_DIRS}]")
  1116. else(DEFINED NETGEN_FOUND)
  1117. message(STATUS "NETGEN: not enabled")
  1118. endif(DEFINED NETGEN_FOUND)
  1119. #message(STATUS "OpenCV: ${OpenCV_VERSION}")
  1120. if(DEFINED SWIG_FOUND)
  1121. message(STATUS "SWIG: ${SWIG_VERSION}")
  1122. else(DEFINED SWIG_FOUND)
  1123. message(STATUS "SWIG: not found")
  1124. endif(DEFINED SWIG_FOUND)
  1125. if(DEFINED EIGEN3_FOUND)
  1126. message(STATUS "Eigen3 ${EIGEN3_VERSION}")
  1127. else(DEFINED EIGEN3_FOUND)
  1128. message(STATUS "Eigen3: not found")
  1129. endif(DEFINED EIGEN3_FOUND)
  1130. if(NOT BUILD_QT5)
  1131. message(STATUS "Qt4: ${Qt4_VERSION}")
  1132. if(QT_QTWEBKIT_FOUND)
  1133. message(STATUS "QtWebKit: found")
  1134. else(QT_QTWEBKIT_FOUND)
  1135. message(STATUS "QtWebKit: not found")
  1136. endif(QT_QTWEBKIT_FOUND)
  1137. message(STATUS "Shiboken: ${Shiboken_VERSION} [${SHIBOKEN_INCLUDE_DIR}]")
  1138. message(STATUS "PySide: ${PySide_VERSION} [${PYSIDE_INCLUDE_DIR}]")
  1139. message(STATUS "PySideTools: [${PYSIDEUIC4BINARY}] [${PYSIDERCC4BINARY}]")
  1140. else(NOT BUILD_QT5)
  1141. message(STATUS "Qt5Core: ${Qt5Core_VERSION}")
  1142. message(STATUS "Qt5Network: ${Qt5Network_VERSION}")
  1143. message(STATUS "Qt5Xml: ${Qt5Xml_VERSION}")
  1144. message(STATUS "Qt5XmlPatterns: ${Qt5XmlPatterns_VERSION}")
  1145. if (BUILD_GUI)
  1146. message(STATUS "Qt5Widgets: ${Qt5Widgets_VERSION}")
  1147. message(STATUS "Qt5PrintSupport: ${Qt5PrintSupport_VERSION}")
  1148. message(STATUS "Qt5OpenGL: ${Qt5OpenGL_VERSION}")
  1149. message(STATUS "Qt5Svg: ${Qt5Svg_VERSION}")
  1150. message(STATUS "Qt5UiTools: ${Qt5UiTools_VERSION}")
  1151. message(STATUS "Qt5Concurrent: ${Qt5Concurrent_VERSION}")
  1152. if(BUILD_WEB)
  1153. if (Qt5WebKitWidgets_FOUND)
  1154. message(STATUS "Qt5WebKitWidgets: ${Qt5WebKitWidgets_VERSION}")
  1155. endif()
  1156. if (Qt5WebEngineWidgets_FOUND)
  1157. message(STATUS "Qt5WebEngineWidgets: ${Qt5WebEngineWidgets_VERSION}")
  1158. endif()
  1159. else(BUILD_WEB)
  1160. message(STATUS "Qt5WebKitWidgets: not needed (BUILD_WEB)")
  1161. message(STATUS "Qt5WebEngineWidgets: not needed (BUILD_WEB)")
  1162. endif(BUILD_WEB)
  1163. if(${Qt5WinExtras_FOUND})
  1164. message(STATUS "Qt5WinExtras: ${Qt5WinExtras_VERSION}")
  1165. endif()
  1166. else(BUILD_GUI)
  1167. message(STATUS "Qt5Widgets: not needed")
  1168. message(STATUS "Qt5PrintSupport: not needed")
  1169. message(STATUS "Qt5OpenGL: not needed")
  1170. message(STATUS "Qt5Svg: not needed")
  1171. message(STATUS "Qt5UiTools: not needed")
  1172. message(STATUS "Qt5Concurrent: not needed")
  1173. message(STATUS "Qt5WebKitWidgets: not needed")
  1174. endif(BUILD_GUI)
  1175. if(DEFINED MACPORTS_PREFIX)
  1176. if(DEFINED Shiboken_FOUND)
  1177. message(STATUS "Shiboken: ${Shiboken_VERSION} [${SHIBOKEN_INCLUDE_DIR}]")
  1178. else(DEFINED Shiboken_FOUND)
  1179. message(STATUS "Shiboken: not found (only searched if MACPORTS_PREFIX is defined)")
  1180. endif(DEFINED Shiboken_FOUND)
  1181. if(DEFINED PySide_FOUND)
  1182. message(STATUS "PySide: ${PySide_VERSION} [${PYSIDE_INCLUDE_DIR}]")
  1183. if(NOT PYSIDE_INCLUDE_DIR)
  1184. message(STATUS " IncludeDir: Unable to find, python version mismatch?")
  1185. endif(NOT PYSIDE_INCLUDE_DIR)
  1186. else(DEFINED PySide_FOUND)
  1187. message(STATUS "PySide: not found (only searched if MACPORTS_PREFIX is defined)")
  1188. endif(DEFINED PySide_FOUND)
  1189. endif(DEFINED MACPORTS_PREFIX)
  1190. if(DEFINED Shiboken2_FOUND)
  1191. message(STATUS "Shiboken2: ${Shiboken2_VERSION} [${Shiboken2_DIR}] [${SHIBOKEN_INCLUDE_DIR}]")
  1192. else(DEFINED Shiboken2_FOUND)
  1193. message(STATUS "Shiboken2: not found")
  1194. endif(DEFINED Shiboken2_FOUND)
  1195. if(DEFINED PySide2_FOUND)
  1196. message(STATUS "PySide2: ${PySide2_VERSION} [${PYSIDE_INCLUDE_DIR}]")
  1197. if(NOT PYSIDE_INCLUDE_DIR)
  1198. message(STATUS " IncludeDir: Unable to find, python version mismatch?")
  1199. endif(NOT PYSIDE_INCLUDE_DIR)
  1200. else(DEFINED PySide2_FOUND)
  1201. message(STATUS "PySide2: not found")
  1202. endif(DEFINED PySide2_FOUND)
  1203. if(DEFINED PYSIDE2_TOOLS_FOUND)
  1204. message(STATUS "PySide2Tools: [${PYSIDE2UICBINARY}] [${PYSIDE2RCCBINARY}]")
  1205. else(DEFINED PYSIDE2_TOOLS_FOUND)
  1206. message(STATUS "PySide2Tools: not found")
  1207. endif(DEFINED PYSIDE2_TOOLS_FOUND)
  1208. endif(NOT BUILD_QT5)
  1209. if(FREECAD_USE_FREETYPE)
  1210. if(DEFINED FREETYPE_FOUND)
  1211. message(STATUS "Freetype: ${FREETYPE_VERSION_STRING}")
  1212. else(DEFINED FREETYPE_FOUND)
  1213. message(STATUS "Freetype: not found")
  1214. endif(DEFINED FREETYPE_FOUND)
  1215. else(FREECAD_USE_FREETYPE)
  1216. message(STATUS "Freetype: disabled")
  1217. endif(FREECAD_USE_FREETYPE)
  1218. message(STATUS "OpenGLU: ${OPENGL_glu_LIBRARY} [${OPENGL_glu_LIBRARY}][${OPENGL_INCLUDE_DIR}]")
  1219. message(STATUS "Coin3D: [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]")
  1220. if (WIN32)
  1221. #message(STATUS "SPNAV: not available yet for your OS") # FREECAD_USE_3DCONNEXION instead...
  1222. else(WIN32)
  1223. if(DEFINED SPNAV_FOUND)
  1224. message(STATUS "SPNAV: [${SPNAV_LIBRARY}] [${SPNAV_INCLUDE_DIR}]")
  1225. else(DEFINED SPNAV_FOUND)
  1226. message(STATUS "SPNAV: not found")
  1227. endif(DEFINED SPNAV_FOUND)
  1228. endif(WIN32)
  1229. if(MATPLOTLIB_FOUND)
  1230. message(STATUS "Matplotlib: ${MATPLOTLIB_VERSION}")
  1231. else(MATPLOTLIB_FOUND)
  1232. message(STATUS "Matplotlib: not found")
  1233. endif(MATPLOTLIB_FOUND)
  1234. if(BUILD_VR)
  1235. if(DEFINED RIFT_FOUND)
  1236. message(STATUS "Rift: ${Rift_VERSION}")
  1237. else(DEFINED RIFT_FOUND)
  1238. message(STATUS "Rift: not found")
  1239. endif(DEFINED RIFT_FOUND)
  1240. else(BUILD_VR)
  1241. message(STATUS "Rift: not enabled (BUILD_VR)")
  1242. endif(BUILD_VR)
  1243. if(DOXYGEN_FOUND)
  1244. message(STATUS "Doxygen: ${DOXYGEN_VERSION}")
  1245. message(STATUS " Language: ${DOXYGEN_LANGUAGE}")
  1246. if(COIN3D_DOC_FOUND)
  1247. message(STATUS " Coin3D_DOC: found [${COIN3D_DOC_PATH}]")
  1248. else(COIN3D_DOC_FOUND)
  1249. message(STATUS " Coin3D_DOC: not found")
  1250. endif(COIN3D_DOC_FOUND)
  1251. else(DOXYGEN_FOUND)
  1252. message(STATUS "Doxygen: not found")
  1253. endif(DOXYGEN_FOUND)
  1254. if(MSVC)
  1255. # Copy libpack dependency directories to build folder for user as part of overall build process
  1256. if(FREECAD_LIBPACK_USE AND LIBPACK_FOUND)
  1257. if(FREECAD_COPY_DEPEND_DIRS_TO_BUILD)
  1258. message(STATUS "=======================================\n"
  1259. "Copying libpack dependency directories to build directory for Windows MSVC build.\n")
  1260. file(COPY ${FREECAD_LIBPACK_DIR}/plugins/platforms DESTINATION ${CMAKE_BINARY_DIR}/bin)
  1261. file(COPY ${FREECAD_LIBPACK_DIR}/plugins/imageformats DESTINATION ${CMAKE_BINARY_DIR}/bin)
  1262. file(COPY ${FREECAD_LIBPACK_DIR}/plugins/iconengines DESTINATION ${CMAKE_BINARY_DIR}/bin)
  1263. file(COPY ${FREECAD_LIBPACK_DIR}/plugins/sqldrivers DESTINATION ${CMAKE_BINARY_DIR}/bin)
  1264. file(COPY ${FREECAD_LIBPACK_DIR}/resources DESTINATION ${CMAKE_BINARY_DIR})
  1265. file(COPY ${FREECAD_LIBPACK_DIR}/bin/Lib/site-packages/PySide2/translations/qtwebengine_locales
  1266. DESTINATION ${CMAKE_BINARY_DIR}/bin)
  1267. message(STATUS "... end copying.\n=======================================\n")
  1268. endif(FREECAD_COPY_DEPEND_DIRS_TO_BUILD)
  1269. if(COPY_LIBPACK_BIN_TO_BUILD)
  1270. if(FREECAD_COPY_LIBPACK_BIN_TO_BUILD)
  1271. message("=======================================\n"
  1272. "Copying libpack 'bin' directory to build directory.\n")
  1273. file(COPY ${FREECAD_LIBPACK_DIR}/bin DESTINATION ${CMAKE_BINARY_DIR})
  1274. message("... done copying libpack 'bin' directory.\n=======================================\n")
  1275. endif()
  1276. endif()
  1277. if(FREECAD_INSTALL_DEPEND_DIRS)
  1278. # Test install command for installing/copying directories
  1279. message(STATUS "=======================================")
  1280. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/platforms DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  1281. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/imageformats DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  1282. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/iconengines DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  1283. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/plugins/sqldrivers DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  1284. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/bin/Lib/site-packages/PySide2/translations/qtwebengine_locales DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
  1285. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/resources DESTINATION ${CMAKE_INSTALL_PREFIX})
  1286. install(DIRECTORY ${FREECAD_LIBPACK_DIR}/bin DESTINATION ${CMAKE_INSTALL_PREFIX})
  1287. message(STATUS "Created install commands for INSTALL target.\n")
  1288. endif(FREECAD_INSTALL_DEPEND_DIRS)
  1289. endif(FREECAD_LIBPACK_USE AND LIBPACK_FOUND)
  1290. endif()
  1291. # Print message to start build process
  1292. message("=================================================\n"
  1293. "Now run 'cmake --build ${CMAKE_BINARY_DIR}' to build ${PROJECT_NAME}\n"
  1294. "=================================================\n")