FreeCAD WebAssembly development snapshot
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
This commit is contained in:
254
CMakeLists.txt
Normal file
254
CMakeLists.txt
Normal file
@@ -0,0 +1,254 @@
|
||||
# As of February 2025 we require CMake 3.22.0
|
||||
cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR)
|
||||
|
||||
|
||||
# As of cMake 3.27, find_package() will look for both case-sensitive and all-uppercase versions
|
||||
# of the package. This seems to affect FLANN as included by Pixi
|
||||
if(POLICY CMP0144)
|
||||
cmake_policy(SET CMP0144 NEW)
|
||||
endif()
|
||||
|
||||
# FindPythonInterp and FindPythonLibs modules are deprecated, but are still in use by
|
||||
# all versions of Shiboken2. This policy must be kept at OLD until Shiboken2 is no longer
|
||||
# supported
|
||||
if(POLICY CMP0148)
|
||||
cmake_policy(SET CMP0148 OLD)
|
||||
endif()
|
||||
|
||||
# The exec_program command was deprecated in cMake 3.0, and policy CMP0153 was added in cMake
|
||||
# 3.28 to control whether this gives a warning (the OLD behavior) or a fatal error (NEW)
|
||||
if(POLICY CMP0153)
|
||||
cmake_policy(SET CMP0153 NEW)
|
||||
endif()
|
||||
|
||||
# Suppress 'FindBoost module is removed' warning. Will use BoostConfig.cmake instead
|
||||
if(POLICY CMP0167)
|
||||
cmake_policy(SET CMP0167 NEW)
|
||||
endif()
|
||||
|
||||
# As of cMake 3.31 add_custom_command() rejects invalid arguments
|
||||
if(POLICY CMP0175)
|
||||
cmake_policy(SET CMP0175 NEW)
|
||||
endif()
|
||||
|
||||
# Added in cMake 3.31, enforce normalization of all DESTINATION paths given to install()
|
||||
if(POLICY CMP0177)
|
||||
cmake_policy(SET CMP0177 NEW)
|
||||
endif()
|
||||
|
||||
|
||||
option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" ON)
|
||||
|
||||
if(FREECAD_USE_CCACHE)
|
||||
find_program(CCACHE_PROGRAM ccache) #This check should occur before project()
|
||||
if(CCACHE_PROGRAM)
|
||||
message(STATUS "Using ccache found at: " ${CCACHE_PROGRAM})
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(FreeCAD)
|
||||
|
||||
# WebAssembly is an explicit, opt-in configuration. Desktop builds retain all
|
||||
# existing defaults; the Web preset supplies the Emscripten toolchain and this
|
||||
# block narrows the module graph to the first native-kernel probe.
|
||||
option(FREECAD_WEB "Build the FreeCAD WebAssembly core configuration" OFF)
|
||||
option(FREECAD_WEB_ENABLE_ASSEMBLY "Enable the Assembly Web probe and its dependency closure" OFF)
|
||||
if(FREECAD_WEB)
|
||||
if(NOT EMSCRIPTEN OR NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||
message(FATAL_ERROR
|
||||
"FREECAD_WEB requires the Emscripten CMake toolchain. "
|
||||
"Use the freecad-web-core preset or pass -DCMAKE_TOOLCHAIN_FILE explicitly.")
|
||||
endif()
|
||||
|
||||
set(BUILD_GUI OFF CACHE BOOL "Web core does not build the desktop GUI" FORCE)
|
||||
set(BUILD_FORCE_DIRECTORY ON CACHE BOOL "Web builds must be out of source" FORCE)
|
||||
set(BUILD_DYNAMIC_LINK_PYTHON OFF CACHE BOOL "Web core does not dynamically link Python" FORCE)
|
||||
set(BUILD_TRACY_FRAME_PROFILER OFF CACHE BOOL "Web core does not build Tracy" FORCE)
|
||||
set(ENABLE_DEVELOPER_TESTS OFF CACHE BOOL "Web core does not build desktop tests" FORCE)
|
||||
set(FREECAD_USE_PCH OFF CACHE BOOL "Web core does not use desktop PCH defaults" FORCE)
|
||||
set(FREECAD_USE_FREETYPE OFF CACHE BOOL "Web core leaves optional FreeType disabled" FORCE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include${CMAKE_SOURCE_DIR}/src/FCWebRangesCompat.h")
|
||||
|
||||
set(_freecad_web_disabled_options
|
||||
BUILD_ADDONMGR
|
||||
BUILD_ASSEMBLY
|
||||
BUILD_BIM
|
||||
BUILD_CAM
|
||||
BUILD_CLOUD
|
||||
BUILD_DRAWING
|
||||
BUILD_DRAFT
|
||||
BUILD_FEM
|
||||
BUILD_FLAT_MESH
|
||||
BUILD_HELP
|
||||
BUILD_INSPECTION
|
||||
BUILD_JTREADER
|
||||
BUILD_MESH
|
||||
BUILD_MESH_PART
|
||||
BUILD_OPENSCAD
|
||||
BUILD_PLOT
|
||||
BUILD_POINTS
|
||||
BUILD_REVERSEENGINEERING
|
||||
BUILD_ROBOT
|
||||
BUILD_SANDBOX
|
||||
BUILD_SHOW
|
||||
BUILD_SPREADSHEET
|
||||
BUILD_START
|
||||
BUILD_SURFACE
|
||||
BUILD_TECHDRAW
|
||||
BUILD_TEST
|
||||
BUILD_TUX
|
||||
BUILD_VR
|
||||
BUILD_WEB)
|
||||
if(FREECAD_WEB_ENABLE_ASSEMBLY)
|
||||
# Assembly's App target requires Spreadsheet; the configured dependency
|
||||
# graph also requires Draft and TechDraw. Keep this opt-in so the
|
||||
# default viewer/kernel build remains unchanged.
|
||||
list(REMOVE_ITEM _freecad_web_disabled_options
|
||||
BUILD_ASSEMBLY BUILD_SPREADSHEET BUILD_DRAFT BUILD_TECHDRAW)
|
||||
endif()
|
||||
foreach(_freecad_web_disabled_option IN LISTS _freecad_web_disabled_options)
|
||||
set(${_freecad_web_disabled_option} OFF CACHE BOOL "Disabled by FREECAD_WEB core configuration" FORCE)
|
||||
endforeach()
|
||||
unset(_freecad_web_disabled_options)
|
||||
|
||||
foreach(_freecad_web_enabled_option BUILD_IMPORT BUILD_MATERIAL BUILD_MEASURE BUILD_PART BUILD_PART_DESIGN BUILD_SKETCHER)
|
||||
set(${_freecad_web_enabled_option} ON CACHE BOOL "Enabled by FREECAD_WEB core configuration" FORCE)
|
||||
endforeach()
|
||||
if(FREECAD_WEB_ENABLE_ASSEMBLY)
|
||||
foreach(_freecad_web_assembly_option BUILD_ASSEMBLY BUILD_SPREADSHEET BUILD_DRAFT BUILD_TECHDRAW)
|
||||
set(${_freecad_web_assembly_option} ON CACHE BOOL "Enabled by FREECAD_WEB_ENABLE_ASSEMBLY" FORCE)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(cMake/FreeCADWebDependencies.cmake)
|
||||
endif()
|
||||
|
||||
# Sanitizer support
|
||||
option(FREECAD_USE_SANITIZER_ASAN "Enable AddressSanitizer ie. (ASan)" OFF)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
option(FREECAD_USE_SANITIZER_LSAN "Enable LeakSanitizer (LSan)" OFF)
|
||||
option(FREECAD_USE_SANITIZER_TSAN "Enable ThreadSanitizer (TSan)" OFF)
|
||||
option(FREECAD_USE_SANITIZER_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
|
||||
option(FREECAD_USE_SANITIZER_MSAN "Enable MemorySanitizer (MSan)" OFF)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
FREECAD_USE_SANITIZER_ASAN
|
||||
FREECAD_USE_SANITIZER_LSAN
|
||||
FREECAD_USE_SANITIZER_TSAN
|
||||
FREECAD_USE_SANITIZER_UBSAN
|
||||
FREECAD_USE_SANITIZER_MSAN
|
||||
)
|
||||
|
||||
set(PACKAGE_VERSION_MAJOR "1")
|
||||
set(PACKAGE_VERSION_MINOR "2")
|
||||
set(PACKAGE_VERSION_PATCH "0") # number of patch release (e.g. "4" for the 0.18.4 release)
|
||||
set(PACKAGE_VERSION_SUFFIX "dev") # either "dev" for development snapshot or "" (empty string)
|
||||
set(PACKAGE_BUILD_VERSION "0") # used when the same FreeCAD version will be re-released (for example using an updated LibPack)
|
||||
string(TIMESTAMP PACKAGE_COPYRIGHT_YEAR "%Y")
|
||||
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
|
||||
set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
|
||||
|
||||
# include local modules
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(AddFileDependencies)
|
||||
include(cMake/FreeCadMacros.cmake)
|
||||
# include helper functions/macros
|
||||
add_subdirectory(cMake/FreeCAD_Helpers)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake")
|
||||
|
||||
CompilerChecksAndSetups()
|
||||
ConfigureCMakeVariables()
|
||||
InitializeFreeCADBuildOptions()
|
||||
CheckInterModuleDependencies()
|
||||
FreeCADLibpackChecks()
|
||||
SetupDoxygen()
|
||||
SetupLibFmt()
|
||||
SetupSanitizers()
|
||||
SetupYamlCpp()
|
||||
SetupZipIos()
|
||||
find_package(ICU REQUIRED COMPONENTS uc i18n)
|
||||
if(FREECAD_WEB)
|
||||
# Emscripten's ICU port keeps the data archive separate from uc/i18n.
|
||||
# Keep it in the Web link interface without changing desktop discovery.
|
||||
list(APPEND ICU_LIBRARIES "${FREECAD_WEB_ICU_DATA_LIBRARY}")
|
||||
endif()
|
||||
if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIBPACK_CHECKFILE_VERSION)
|
||||
SetupPython()
|
||||
SetupPCL()
|
||||
SetupPybind11()
|
||||
SetupXercesC()
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(PyCXX REQUIRED)
|
||||
SetupOpenCasCade()
|
||||
if(BUILD_GUI)
|
||||
# Do this before the check for SMESH because it depends on vtk
|
||||
# that may have its own OpenGL check but possibly fails and leaves
|
||||
# OPENGL_gl_LIBRARY empty that results into linker errors
|
||||
SetupOpenGL()
|
||||
endif(BUILD_GUI)
|
||||
SetupSalomeSMESH()
|
||||
if (BUILD_FEM_NETGEN)
|
||||
set(NETGEN_DEFINITIONS -DNO_PARALLEL_THREADS -DOCCGEOMETRY)
|
||||
if (NOT FREECAD_USE_EXTERNAL_SMESH)
|
||||
find_package(NETGEN REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
# not needed at the moment
|
||||
#find_package(OpenCV REQUIRED)
|
||||
SetupSwig()
|
||||
SetupEigen()
|
||||
# This file is included directly due to some cMake macros that are defined within.
|
||||
# If these macro definitions are embedded within another macro, it causes problems.
|
||||
include(cMake/FreeCAD_Helpers/SetupQt.cmake)
|
||||
SetupFreetype()
|
||||
|
||||
if(BUILD_GUI)
|
||||
SetupCoin3D()
|
||||
SetupPivy()
|
||||
SetupSpaceball()
|
||||
SetupShibokenAndPyside()
|
||||
SetupMatplotlib()
|
||||
endif(BUILD_GUI)
|
||||
|
||||
# SetupCoin3D can overwrite find_package(Boost) output so keep this after.
|
||||
SetupBoost()
|
||||
|
||||
if(BUILD_BIM)
|
||||
SetupLark()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_VR)
|
||||
find_package(Rift)
|
||||
endif(BUILD_VR)
|
||||
|
||||
SetLibraryVersions()
|
||||
SetGlobalCompilerAndLinkerSettings()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(data)
|
||||
|
||||
BuildAndInstallDesignerPlugin()
|
||||
|
||||
CreatePackagingTargets()
|
||||
|
||||
if(MSVC AND FREECAD_LIBPACK_USE AND LIBPACK_FOUND)
|
||||
CopyLibpackDirectories()
|
||||
endif()
|
||||
|
||||
if (ENABLE_DEVELOPER_TESTS)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
PrintFinalReport()
|
||||
|
||||
message("\n=================================================\n"
|
||||
"Now run 'cmake --build ${CMAKE_BINARY_DIR}' to build ${PROJECT_NAME}\n"
|
||||
"=================================================\n")
|
||||
Reference in New Issue
Block a user