Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an initial pass, simply moving the existing logic as-is. Future PR's will attempt to refactor and improve the cmake stuff.
- Loading branch information
1 parent
cfc2562
commit 63c45d3
Showing
30 changed files
with
1,676 additions
and
1,452 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
message("Running the INCLUDE stuff!!!!!!!!!!!!!!!!!!") | ||
file(GLOB FREECAD_HELPER_CMAKE_FILES ./*.cmake) | ||
set(_SKIP_FILES "SetupQt.cmake") | ||
foreach(_CMAKE_FILE ${FREECAD_HELPER_CMAKE_FILES}) | ||
get_filename_component(_FILENAME ${_CMAKE_FILE} NAME) | ||
if (NOT _FILENAME IN_LIST _SKIP_FILES) | ||
include(${_CMAKE_FILE}) | ||
endif() | ||
endforeach(_CMAKE_FILE ${FREECAD_HELPER_CMAKE_FILES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
macro(CheckInterModuleDependencies) | ||
# ============================================================================== | ||
#inter-module dependencies | ||
|
||
# Takes a dependent module followed by a variable-length list of prerequisite | ||
# modules. Warns if any of the prerequisite modules are disabled. | ||
function(REQUIRES_MODS dependent) | ||
if(${dependent}) | ||
foreach(prerequisite ${ARGN}) | ||
if(NOT ${prerequisite}) | ||
message(WARNING | ||
"${dependent} requires ${ARGN} each be ON, but " | ||
"${prerequisite} is \"${${prerequisite}}\"") | ||
endif(NOT ${prerequisite}) | ||
endforeach() | ||
endif(${dependent}) | ||
endfunction(REQUIRES_MODS) | ||
|
||
REQUIRES_MODS(BUILD_ARCH BUILD_PART BUILD_MESH BUILD_DRAFT) | ||
REQUIRES_MODS(BUILD_DRAFT BUILD_SKETCHER) | ||
REQUIRES_MODS(BUILD_DRAWING BUILD_PART BUILD_SPREADSHEET) | ||
REQUIRES_MODS(BUILD_FEM BUILD_PART) | ||
REQUIRES_MODS(BUILD_IDF BUILD_PART) | ||
REQUIRES_MODS(BUILD_IMPORT BUILD_PART) | ||
REQUIRES_MODS(BUILD_INSPECTION BUILD_MESH BUILD_POINTS BUILD_PART) | ||
REQUIRES_MODS(BUILD_JTREADER BUILD_MESH) | ||
REQUIRES_MODS(BUILD_MESH_PART BUILD_PART BUILD_MESH BUILD_SMESH) | ||
REQUIRES_MODS(BUILD_FLAT_MESH BUILD_MESH_PART) | ||
REQUIRES_MODS(BUILD_OPENSCAD BUILD_MESH_PART BUILD_DRAFT) | ||
REQUIRES_MODS(BUILD_PART_DESIGN BUILD_SKETCHER) | ||
REQUIRES_MODS(BUILD_PATH BUILD_PART BUILD_ROBOT) | ||
REQUIRES_MODS(BUILD_RAYTRACING BUILD_PART) | ||
REQUIRES_MODS(BUILD_REVERSEENGINEERING BUILD_PART BUILD_MESH) | ||
REQUIRES_MODS(BUILD_ROBOT BUILD_PART) | ||
REQUIRES_MODS(BUILD_SANDBOX BUILD_PART BUILD_MESH) | ||
REQUIRES_MODS(BUILD_SHIP BUILD_PART BUILD_PLOT BUILD_IMAGE) | ||
REQUIRES_MODS(BUILD_SKETCHER BUILD_PART) | ||
REQUIRES_MODS(BUILD_SPREADSHEET BUILD_DRAFT) | ||
REQUIRES_MODS(BUILD_START BUILD_WEB) | ||
REQUIRES_MODS(BUILD_TECHDRAW BUILD_PART BUILD_SPREADSHEET BUILD_DRAWING) | ||
endmacro(CheckInterModuleDependencies) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
macro(CompilerChecksAndSetups) | ||
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") | ||
set(CMAKE_COMPILER_IS_CLANGXX TRUE) | ||
endif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") | ||
|
||
# ================================================================================ | ||
|
||
# Needed for boost1.69 | ||
# Avoid that Python (pyerrors.h) defines snprintf and vsnprintf | ||
if (MSVC AND NOT MSVC_VERSION VERSION_LESS 1900) | ||
add_definitions(-DHAVE_SNPRINTF) | ||
elseif (MINGW) | ||
add_definitions(-DHAVE_SNPRINTF) | ||
endif() | ||
|
||
# Allow developers to use Boost < 1.48 | ||
if (NOT BOOST_MIN_VERSION) | ||
set(BOOST_MIN_VERSION 1.48) | ||
endif() | ||
|
||
# For older cmake versions the variable 'CMAKE_CXX_COMPILER_VERSION' is missing | ||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION) | ||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion | ||
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION) | ||
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION) | ||
|
||
# Enabled C++11 for Freecad 0.17 and later | ||
if (FREECAD_VERSION VERSION_GREATER 0.16) | ||
set(BUILD_ENABLE_CXX_STD "C++11" CACHE STRING "Enable C++ standard") | ||
set_property(CACHE BUILD_ENABLE_CXX_STD PROPERTY STRINGS | ||
"C++11" | ||
"C++14" | ||
"C++17" | ||
"C++20" | ||
) | ||
|
||
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) | ||
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}") | ||
elseif(CMAKE_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3) | ||
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}") | ||
endif() | ||
endif(FREECAD_VERSION VERSION_GREATER 0.16) | ||
|
||
# Log the compiler and version | ||
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}, version: ${CMAKE_CXX_COMPILER_VERSION}") | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||
include(${CMAKE_SOURCE_DIR}/cMake/ConfigureChecks.cmake) | ||
configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) | ||
add_definitions(-DHAVE_CONFIG_H) | ||
|
||
# Escape the two plus chars as otherwise cmake complains about invalid regex | ||
if(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+20") | ||
set(CMAKE_CXX_STANDARD 20) | ||
elseif(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+17") | ||
set(CMAKE_CXX_STANDARD 17) | ||
elseif(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+14") | ||
set(CMAKE_CXX_STANDARD 14) | ||
elseif (${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+11") | ||
set(CMAKE_CXX_STANDARD 11) | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-write-strings ${CMAKE_CXX_FLAGS}") | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
# get linker errors as soon as possible and not at runtime e.g. for modules | ||
if(BUILD_DYNAMIC_LINK_PYTHON) | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error") | ||
elseif(UNIX) | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") | ||
endif() | ||
else(BUILD_DYNAMIC_LINK_PYTHON) | ||
if(CMAKE_COMPILER_IS_CLANGXX) | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,dynamic_lookup") | ||
endif() | ||
endif(BUILD_DYNAMIC_LINK_PYTHON) | ||
endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||
|
||
if(CMAKE_COMPILER_IS_CLANGXX) | ||
# Disable warning about potentially uninstantiated static members | ||
# because it leads to a lot of false-positives. | ||
# | ||
# https://en.wikipedia.org/wiki/Xcode#Latest_versions | ||
if (APPLE) | ||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") | ||
endif() | ||
elseif (UNIX) | ||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") | ||
endif() | ||
endif() | ||
|
||
# older boost.preprocessor turn off variadics for clang | ||
add_definitions(-DBOOST_PP_VARIADICS=1) | ||
message(STATUS "Force BOOST_PP_VARIADICS=1 for clang") | ||
endif() | ||
endmacro(CompilerChecksAndSetups) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
macro(ConfigureCMakeVariables) | ||
# ================================================================================ | ||
# Output directories for install target | ||
|
||
if(WIN32) | ||
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation root directory") | ||
set(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for executables") | ||
set(CMAKE_INSTALL_DATADIR data CACHE PATH "Output directory for data and resource files") | ||
set(CMAKE_INSTALL_INCLUDEDIR include CACHE PATH "Output directory for header files") | ||
set(CMAKE_INSTALL_DOCDIR doc CACHE PATH "Output directory for documentation and license files") | ||
# Don't set it without manual adoption of LibDir variable in src/App/FreeCADInit.py | ||
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries") | ||
else() | ||
set(CMAKE_INSTALL_PREFIX "/usr/lib${LIB_SUFFIX}/freecad" CACHE PATH "Installation root directory") | ||
include(GNUInstallDirs) | ||
endif() | ||
|
||
set(PYCXX_INCLUDE_DIR | ||
"${CMAKE_SOURCE_DIR}/src" CACHE PATH | ||
"Path to the directory containing PyCXX's CXX/Config.hxx include file") | ||
set(PYCXX_SOURCE_DIR | ||
"${CMAKE_SOURCE_DIR}/src/CXX" CACHE PATH | ||
"Path to the directory containing PyCXX's cxxextensions.c source file") | ||
|
||
# used as compiler defines | ||
set(RESOURCEDIR "${CMAKE_INSTALL_DATADIR}") | ||
set(DOCDIR "${CMAKE_INSTALL_DOCDIR}") | ||
|
||
message(STATUS "prefix: ${CMAKE_INSTALL_PREFIX}") | ||
message(STATUS "bindir: ${CMAKE_INSTALL_BINDIR}") | ||
message(STATUS "datadir: ${CMAKE_INSTALL_DATADIR}") | ||
message(STATUS "docdir: ${CMAKE_INSTALL_DOCDIR}") | ||
message(STATUS "includedir: ${CMAKE_INSTALL_INCLUDEDIR}") | ||
message(STATUS "libdir: ${CMAKE_INSTALL_LIBDIR}") | ||
message(STATUS "cmake: ${CMAKE_VERSION}") | ||
endmacro(ConfigureCMakeVariables) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
macro(CreatePackagingTargets) | ||
# ================================================================================ | ||
# == Packaging =================================================================== | ||
# | ||
#add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) | ||
add_custom_target(dist-git | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py | ||
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
add_custom_target(distdfsg-git | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py | ||
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW) | ||
add_custom_target(distcheck-git | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py | ||
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --check | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
add_custom_target(distcheckdfsg-git | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py | ||
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg --check | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
endif(CMAKE_COMPILER_IS_GNUCXX OR MINGW) | ||
|
||
endmacro(CreatePackagingTargets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
macro(FindSalomeSMESH) | ||
# -------------------------------- Salome SMESH -------------------------- | ||
|
||
# Salome SMESH sources are under src/3rdParty now | ||
if(BUILD_SMESH) | ||
# set the internal smesh version: | ||
# 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 | ||
set(SMESH_VERSION_MAJOR 7) | ||
set(SMESH_VERSION_MINOR 7) | ||
set(SMESH_VERSION_PATCH 1) | ||
set(SMESH_VERSION_TWEAK 0) | ||
|
||
#if we use smesh we definitely also need vtk, no matter of external or internal smesh | ||
set (VTK_COMPONENTS | ||
vtkCommonCore | ||
vtkCommonDataModel | ||
vtkFiltersVerdict | ||
vtkIOXML | ||
vtkFiltersCore | ||
vtkFiltersGeneral | ||
vtkIOLegacy | ||
vtkFiltersExtraction | ||
vtkFiltersSources | ||
vtkFiltersGeometry | ||
) | ||
|
||
# check which modules are available | ||
if(UNIX OR WIN32) | ||
find_package(VTK COMPONENTS vtkCommonCore REQUIRED NO_MODULE) | ||
list(APPEND VTK_COMPONENTS vtkIOMPIParallel vtkParallelMPI vtkhdf5 vtkFiltersParallelDIY2 vtkRenderingCore vtkInteractionStyle vtkRenderingFreeType vtkRenderingOpenGL2) | ||
foreach(_module ${VTK_COMPONENTS}) | ||
list (FIND VTK_MODULES_ENABLED ${_module} _index) | ||
if (${_index} GREATER -1) | ||
list(APPEND AVAILABLE_VTK_COMPONENTS ${_module}) | ||
endif() | ||
endforeach() | ||
endif() | ||
|
||
# don't check VERSION 6 as this would exclude VERSION 7 | ||
if(AVAILABLE_VTK_COMPONENTS) | ||
message(STATUS "VTK components: ${AVAILABLE_VTK_COMPONENTS}") | ||
find_package(VTK COMPONENTS ${AVAILABLE_VTK_COMPONENTS} REQUIRED NO_MODULE) | ||
else() | ||
message(STATUS "VTK components: not found or used") | ||
find_package(VTK REQUIRED NO_MODULE) | ||
endif() | ||
|
||
set(BUILD_FEM_VTK ON) | ||
if(${VTK_MAJOR_VERSION} LESS 6) | ||
message( FATAL_ERROR "Found VTK version is <6, this is not compatible" ) | ||
endif() | ||
if(${VTK_MAJOR_VERSION} EQUAL 6) | ||
if(${VTK_MINOR_VERSION} LESS 2) | ||
set(VTK_OPTIONS -DVTK_NO_QUAD_POLY) | ||
endif() | ||
if(${VTK_MINOR_VERSION} EQUAL 0) | ||
message(WARNING "VTK equal to 6.0 cannot be used with c++11, FEM postprocessing is disabled") | ||
set(BUILD_FEM_VTK OFF) | ||
endif() | ||
endif() | ||
# on openSUSE 13.1 VTK_LIBRARIES ends with "optimized" keyword | ||
list(REMOVE_ITEM VTK_LIBRARIES "optimized" "debug") | ||
|
||
if(NOT FREECAD_USE_EXTERNAL_SMESH) | ||
find_package(MEDFile REQUIRED) | ||
# See https://www.hdfgroup.org/HDF5/release/cmakebuild.html | ||
if (WIN32) | ||
find_package(HDF5 COMPONENTS NO_MODULE REQUIRED static) | ||
else() | ||
find_package(PkgConfig) | ||
file(READ ${meddotH} TMPTXT) | ||
string(FIND "${TMPTXT}" "#define MED_HAVE_MPI" matchres) | ||
if(${matchres} EQUAL -1) | ||
message(STATUS "We guess that libmed was built using hdf5-serial version") | ||
set(HDF5_VARIANT "hdf5-serial") | ||
else() | ||
message(STATUS "We guess that libmed was built using hdf5-openmpi version") | ||
set(HDF5_VARIANT "hdf5-openmpi") | ||
set(HDF5_PREFER_PARALLEL TRUE) # if pkg-config fails, find_package(HDF5) needs this | ||
endif() | ||
pkg_search_module(HDF5 ${HDF5_VARIANT}) | ||
if(NOT HDF5_FOUND) | ||
find_package(HDF5 REQUIRED) | ||
else() | ||
add_compile_options(${HDF5_CFLAGS}) | ||
link_directories(${HDF5_LIBRARY_DIRS}) | ||
link_libraries(${HDF5_LIBRARIES}) | ||
find_file(Hdf5dotH hdf5.h PATHS ${HDF5_INCLUDE_DIRS} NO_DEFAULT_PATH) | ||
if(NOT Hdf5dotH) | ||
message( FATAL_ERROR "${HDF5_VARIANT} development header not found.") | ||
endif() | ||
endif() | ||
check_include_file_cxx(hdf5.h HDF5_FOUND) | ||
if(NOT HDF5_FOUND) | ||
message( FATAL_ERROR "hdf5.h was not found.") | ||
endif() | ||
|
||
# Med Fichier can require MPI | ||
pkg_search_module(OPENMPI ompi-cxx) | ||
add_compile_options(${OPENMPI_CFLAGS}) | ||
link_directories(${OPENMPI_LIBRARY_DIRS}) | ||
link_libraries(${OPENMPI_LIBRARIES}) | ||
find_file(MpidotH mpi.h PATHS ${OPENMPI_INCLUDE_DIRS} NO_DEFAULT_PATH) | ||
if(NOT MpidotH) | ||
message( WARNING "mpi.h was not found. Check for error above.") | ||
endif() | ||
endif() | ||
set(SMESH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc) | ||
|
||
else(NOT FREECAD_USE_EXTERNAL_SMESH) | ||
find_package(SMESH CONFIG) | ||
set (SMESH_INCLUDE_DIR ${SMESH_INCLUDE_PATH}) | ||
set(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES}) | ||
if(NOT SMESH_FOUND) | ||
message(ERROR "================\n" | ||
"SMESH not found.\n" | ||
"================\n") | ||
endif() | ||
include_directories(${SMESH_INCLUDE_DIR}) | ||
endif() | ||
|
||
set(SMESH_FOUND TRUE) | ||
configure_file(SMESH_Version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/SMESH_Version.h) | ||
endif(BUILD_SMESH) | ||
|
||
endmacro(FindSalomeSMESH) |
Oops, something went wrong.