Revert revert

This commit is contained in:
Thomas Krijnen
2025-10-03 09:04:43 +02:00
parent efa8382fc5
commit 804a670454
+154 -158
View File
@@ -30,10 +30,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_program(CCACHE_FOUND ccache) find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND) if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
message(STATUS "`ccache` is found, using it as a compiler launcher.")
endif() endif()
add_definitions(-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) add_definitions(-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
if(POLICY CMP0141) # 3.25+
cmake_policy(SET CMP0141 NEW) # Support for `CMAKE_MSVC_DEBUG_INFORMATION_FORMAT`.
endif()
if(POLICY CMP0144) # 3.27 if(POLICY CMP0144) # 3.27
cmake_policy(SET CMP0144 NEW) # find_package() uses upper-case <PACKAGENAME>_ROOT variables. cmake_policy(SET CMP0144 NEW) # find_package() uses upper-case <PACKAGENAME>_ROOT variables.
endif() endif()
@@ -87,8 +91,8 @@ option(WITH_ROCKSDB "Support a RocksDB key-value store as a file backend in IfcO
option(WITH_ZSTD "Use Zstd compression in RocksDB writes" OFF) option(WITH_ZSTD "Use Zstd compression in RocksDB writes" OFF)
option(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only instead of system-wide." OFF) option(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only instead of system-wide." OFF)
option(ADD_COMMIT_SHA "Add commit sha and branch in version number, warning results in many rebuilds, requires git" OFF) option(ADD_COMMIT_SHA "Add commit sha and branch in version number, requires git" OFF)
option(VERSION_OVERRIDE "Override the version defined in IfcParse.h with the file VERSION in the repository root" OFF) option(VERSION_OVERRIDE "Override the version defined in buildinfo.cpp with the file VERSION in the repository root" OFF)
set( set(
PYTHON_MODULE_INSTALL_DIR PYTHON_MODULE_INSTALL_DIR
@@ -123,10 +127,35 @@ if((BUILD_CONVERT OR BUILD_GEOMSERVER OR BUILD_IFCPYTHON) AND(NOT BUILD_IFCGEOM)
set(BUILD_IFCGEOM ON) set(BUILD_IFCGEOM ON)
endif() endif()
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
if(MSVC)
# By default Visual Studio generators will use /Zi which is not compatible
# with ccache, so tell Visual Studio to use /Z7 instead.
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
# Not needed for Ninja.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
file(COPY_FILE
${CCACHE_FOUND} ${CMAKE_BINARY_DIR}/cl.exe
ONLY_IF_DIFFERENT)
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"UseMultiToolTask=true"
)
endif()
endif()
endif()
if(MSVC AND MSVC_PARALLEL_BUILD) if(MSVC AND MSVC_PARALLEL_BUILD)
add_definitions("/MP") add_definitions("/MP")
endif() endif()
if (MSVC AND BUILD_SHARED_LIBS)
# @todo how do projects normally deal with this regarding classes derived from std::exception?
add_compile_options(/wd4275)
endif()
if(NO_WARN) if(NO_WARN)
if(MSVC) if(MSVC)
add_compile_options("/w") add_compile_options("/w")
@@ -229,8 +258,16 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endmacro() endmacro()
if(WITH_CGAL) if(WITH_CGAL)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT EXISTS "${CGAL_INCLUDE_DIR}") if(NOT CGAL_INCLUDE_DIR)
message(FATAL_ERROR "CGAL_INCLUDE_DIR ('${CGAL_INCLUDE_DIR}') is not provided or doesn't exist.") find_package(CGAL REQUIRED)
if(NOT CGAL_DIR)
message(
FATAL_ERROR
"CGAL_SUPPORT enabled, but CGAL_INCLUDE_DIR wasn't provided and CGAL package couldn't be found."
)
endif()
message(STATUS "CGAL: found config at '${CGAL_DIR}'.")
link_libraries(CGAL::CGAL)
endif() endif()
add_definitions(-DIFOPSH_WITH_CGAL) add_definitions(-DIFOPSH_WITH_CGAL)
@@ -251,15 +288,26 @@ endif()
if(GLTF_SUPPORT OR CITYJSON_SUPPORT) if(GLTF_SUPPORT OR CITYJSON_SUPPORT)
UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR) UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR)
if(NOT JSON_INCLUDE_DIR)
find_package(nlohmann_json CONFIG)
if(nlohmann_json_DIR)
link_libraries(nlohmann_json::nlohmann_json)
else()
message(STATUS "Unable to find nlohmann_json package, trying to find it as a header-only library.")
endif()
endif()
if(NOT nlohmann_json_DIR)
clear_wasm_sysroot() clear_wasm_sysroot()
find_path(json_header_path "nlohmann/json.hpp" HINTS ${JSON_INCLUDE_DIR}) find_path(json_header_path "nlohmann/json.hpp" HINTS ${JSON_INCLUDE_DIR})
restore_wasm_sysroot() restore_wasm_sysroot()
set(JSON_INCLUDE_DIR ${json_header_path}) set(JSON_INCLUDE_DIR ${json_header_path})
if(json_header_path) if(json_header_path)
message(STATUS "JSON for Modern C++ header file found in ${JSON_INCLUDE_DIR}") message(STATUS "JSON for Modern C++ header file found in '${JSON_INCLUDE_DIR}'.")
else() else()
message(FATAL_ERROR "Unable to find JSON for Modern C++ header file, aborting") message(FATAL_ERROR "Unable to find JSON for Modern C++ header file / package, aborting")
endif()
endif() endif()
add_definitions(-DWITH_GLTF) add_definitions(-DWITH_GLTF)
@@ -314,77 +362,35 @@ if(USD_SUPPORT)
endif(USD_SUPPORT) endif(USD_SUPPORT)
if (WITH_ROCKSDB) if (WITH_ROCKSDB)
UNIFY_ENVVARS_AND_CACHE(ROCKSDB_INCLUDE_DIR) # Temporaily mess with CMAKE_FIND_PACKAGE_PREFER_CONFIG to help RocksDB
UNIFY_ENVVARS_AND_CACHE(ROCKSDB_LIBRARY_DIR) # find it's zstd dependency on Windows.
UNIFY_ENVVARS_AND_CACHE(ZSTD_INCLUDE_DIR) # Only do it on Windows, otherwise it might create problems as
UNIFY_ENVVARS_AND_CACHE(ZSTD_LIBRARY_DIR) # findzstd and zstd-config target names do not match.
if(WIN32)
if("${ROCKSDB_INCLUDE_DIR}" STREQUAL "") set(TEMP CMAKE_FIND_PACKAGE_PREFER_CONFIG)
find_path(ROCKSDB_INCLUDE_DIR rocksdb/db.h set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
PATHS
/usr/include
/usr/local/include
REQUIRED
)
if(ROCKSDB_INCLUDE_DIR)
message(STATUS "Found rocksdb include files in: ${ROCKSDB_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Unable to find rocksdb include directory, specify ROCKSDB_INCLUDE_DIR manually.")
endif() endif()
else() find_package(RocksDB CONFIG REQUIRED)
set(ROCKSDB_INCLUDE_DIR ${ROCKSDB_INCLUDE_DIR} CACHE FILEPATH "rocksdb header files") if(WIN32)
message(STATUS "Looking for rocksdb include files in: ${ROCKSDB_INCLUDE_DIR}") set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${TEMP})
endif()
find_library(ROCKSDB_LIBRARY
NAMES rocksdb
PATHS ${ROCKSDB_LIBRARY_DIR})
if(ROCKSDB_LIBRARY)
message(STATUS "rocksdb library ${ROCKSDB_LIBRARY} found in: ${ROCKSDB_LIBRARY_DIR}")
else()
message(FATAL_ERROR "Unable to find rocksdb library in: ${ROCKSDB_LIBRARY_DIR}")
endif() endif()
message(STATUS "RocksDB: found at '${RocksDB_DIR}'.")
add_definitions(-DIFOPSH_WITH_ROCKSDB) add_definitions(-DIFOPSH_WITH_ROCKSDB)
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB)
link_libraries(RocksDB::rocksdb)
if (WITH_ZSTD) if (WITH_ZSTD)
# @todo do we actually need the zstd include dir or rather just pass # @todo do we actually need the zstd include dir or rather just pass
# the libzstd.a along with the rocksdb library when needed and feature # the libzstd.a along with the rocksdb library when needed and feature
# detect based on rocksdb API? # detect based on rocksdb API?
if("${ZSTD_INCLUDE_DIR}" STREQUAL "") find_package(zstd CONFIG REQUIRED)
find_path(ZSTD_INCLUDE_DIR zstd.h message(STATUS "zstd: found at '${zstd_DIR}'.")
PATHS link_libraries(zstd::libzstd_static)
/usr/include
/usr/local/include
REQUIRED
)
if(ZSTD_INCLUDE_DIR)
message(STATUS "Found zstd include files in: ${ZSTD_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Unable to find zstd include directory, specify ZSTD_INCLUDE_DIR manually.")
endif()
else()
set(ZSTD_INCLUDE_DIR ${ZSTD_INCLUDE_DIR} CACHE FILEPATH "zstd header files")
message(STATUS "Looking for zstd include files in: ${ZSTD_INCLUDE_DIR}")
endif()
find_library(ZSTD_LIBRARY
NAMES zstd zstd_static
PATHS ${ZSTD_LIBRARY_DIR})
if(ZSTD_LIBRARY)
message(STATUS "zstd library ${ZSTD_LIBRARY} found in: ${ZSTD_LIBRARY_DIR}")
else()
message(FATAL_ERROR "Unable to find zstd library in: ${ZSTD_LIBRARY_DIR}")
endif()
add_definitions(-DIFOPSH_WITH_ROCKSDB_ZSTD) add_definitions(-DIFOPSH_WITH_ROCKSDB_ZSTD)
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB_ZSTD) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB_ZSTD)
endif() endif()
if(WIN32)
set(RPCRT_LIBRARIES "rpcrt4.lib" "shlwapi.lib")
endif()
endif() endif()
# Find Boost: On win32 the (hardcoded) default is to use static libraries and # Find Boost: On win32 the (hardcoded) default is to use static libraries and
@@ -483,37 +489,12 @@ if(BUILD_IFCGEOM)
# Open CASCADE # Open CASCADE
if(WITH_OPENCASCADE) if(WITH_OPENCASCADE)
# Fallback for missing OCC_INCLUDE_DIR.
if(NOT OCC_INCLUDE_DIR)
clear_wasm_sysroot()
find_path(OCC_INCLUDE_DIR Standard_Version.hxx
PATHS
/usr/include/occt
/usr/include/oce
/usr/include/opencascade
)
restore_wasm_sysroot()
if(OCC_INCLUDE_DIR) if(OCC_INCLUDE_DIR)
message(STATUS "Found Open CASCADE include files in: ${OCC_INCLUDE_DIR}")
endif()
else()
set(OCC_INCLUDE_DIR ${OCC_INCLUDE_DIR} CACHE FILEPATH "Open CASCADE header files") set(OCC_INCLUDE_DIR ${OCC_INCLUDE_DIR} CACHE FILEPATH "Open CASCADE header files")
message(STATUS "Looking for Open CASCADE include files in: ${OCC_INCLUDE_DIR}") message(STATUS "Looking for Open CASCADE include files in: ${OCC_INCLUDE_DIR}")
endif() endif()
if("${OCC_LIBRARY_DIR}" STREQUAL "") if(OCC_LIBRARY_DIR)
find_library(OCC_LIBRARY TKernel
PATHS
/usr/lib
)
if(OCC_LIBRARY)
GET_FILENAME_COMPONENT(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH)
message(STATUS "Found Open CASCADE library files in: ${OCC_LIBRARY_DIR}")
endif()
else()
set(OCC_LIBRARY_DIR ${OCC_LIBRARY_DIR} CACHE FILEPATH "Open CASCADE library files") set(OCC_LIBRARY_DIR ${OCC_LIBRARY_DIR} CACHE FILEPATH "Open CASCADE library files")
message(STATUS "Looking for Open CASCADE library files in: ${OCC_LIBRARY_DIR}") message(STATUS "Looking for Open CASCADE library files in: ${OCC_LIBRARY_DIR}")
endif() endif()
@@ -522,29 +503,9 @@ if(BUILD_IFCGEOM)
if(OCC_INCLUDE_DIR AND OCC_LIBRARY_DIR) if(OCC_INCLUDE_DIR AND OCC_LIBRARY_DIR)
message( message(
STATUS STATUS
"Using provided OCCT_INCLUDE_DIR ('${OCC_INCLUDE_DIR}') " "Using provided OCC_INCLUDE_DIR ('${OCC_INCLUDE_DIR}') "
"and OCC_LIBRARY_DIR ('${OCC_LIBRARY_DIR}')." "and OCC_LIBRARY_DIR ('${OCC_LIBRARY_DIR}')."
) )
elseif(NOT OCC_INCLUDE_DIR AND NOT OCC_LIBRARY_DIR)
find_package(OpenCASCADE CONFIG REQUIRED)
get_target_property(OCC_INCLUDE_DIR TKernel INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(TKERNEL_LIB_PATH TKernel LOCATION)
get_filename_component(OCC_LIBRARY_DIR "${TKERNEL_LIB_PATH}" DIRECTORY)
message(
STATUS
"Found Open CASCADE package at '${OpenCASCADE_DIR}', "
"deducing from it OCC_INCLUDE_DIR: '${OCC_INCLUDE_DIR}' "
"and OCC_LIBRARY_DIR: '${OCC_LIBRARY_DIR}'."
)
else()
message(
FATAL_ERROR
"Couldn't find Open CASCADE installation. "
"Either both OCC_INCLUDE_DIR ('${OCC_INCLUDE_DIR}') and OCC_LIBRARY_DIR ('${OCC_LIBRARY_DIR}') "
"must be specified or OpenCASCADE package should be discoverable."
)
endif()
# Parse OCC_VERSION_STRING. # Parse OCC_VERSION_STRING.
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
REGEX "#define OCC_VERSION_MAJOR.*" REGEX "#define OCC_VERSION_MAJOR.*"
@@ -559,6 +520,33 @@ if(BUILD_IFCGEOM)
) )
string(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT}) string(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT})
set(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}") set(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
elseif(NOT OCC_INCLUDE_DIR AND NOT OCC_LIBRARY_DIR)
# OCE is not supported for find_package, because it's using a different name (`oce`)
# and also has an odd directory structure (install/lib/oce-0.18/*.cmake).
find_package(OpenCASCADE CONFIG REQUIRED)
set(OCC_INCLUDE_DIR ${OpenCASCADE_INCLUDE_DIR})
# Do not use OpenCASCADE_LIBRARY_DIR for OCC_LIBRARY_DIR - check target property explicitly.
# On Windows there is a case with OpenCASCADE_LIBRARY_DIR points to `lib` folder,
# while TKernel is actually in `libi`.
get_target_property(TKERNEL_LIB_PATH TKernel LOCATION)
get_filename_component(OCC_LIBRARY_DIR "${TKERNEL_LIB_PATH}" DIRECTORY)
set(OCC_VERSION_STRING ${OpenCASCADE_VERSION})
message(
STATUS
"Found Open CASCADE package at '${OpenCASCADE_DIR}', "
"deducing from it OCC_INCLUDE_DIR: '${OCC_INCLUDE_DIR}' "
"and OCC_LIBRARY_DIR: '${OCC_LIBRARY_DIR}'."
)
else()
message(
FATAL_ERROR
"Couldn't find Open CASCADE installation. "
"Either both OCC_INCLUDE_DIR ('${OCC_INCLUDE_DIR}') and OCC_LIBRARY_DIR ('${OCC_LIBRARY_DIR}') "
"must be specified or OpenCASCADE package should be discoverable. "
"If you're using OCE, then providing a package is not available "
"and you need to provide OCE_INCLUDE_DIR and OCE_LIBRARY_DIR directly."
)
endif()
set( set(
OPENCASCADE_LIBRARY_NAMES OPENCASCADE_LIBRARY_NAMES
@@ -582,7 +570,10 @@ if(BUILD_IFCGEOM)
if(libTKernel) if(libTKernel)
message(STATUS "Required Open Cascade Library files found") message(STATUS "Required Open Cascade Library files found")
else() else()
message(FATAL_ERROR "Unable to find Open Cascade library files, aborting") message(
FATAL_ERROR
"Unable to find Open Cascade library files in OCC_LIBRARY_DIR ('${OCC_LIBRARY_DIR}'), aborting"
)
endif() endif()
# Use the found libTKernel as a template for all other OCC libraries # Use the found libTKernel as a template for all other OCC libraries
@@ -800,27 +791,24 @@ if(HDF5_SUPPORT)
endif() endif()
endif() endif()
if(NOT HDF5_LIBRARIES) if(NOT HDF5_INCLUDE_DIR)
if(NOT WIN32 AND NOT APPLE) # First try to find it as a config.
# debian default
set(HDF5_LIBRARIES
/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so
/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so
/usr/lib/x86_64-linux-gnu/libsz.so
/usr/lib/x86_64-linux-gnu/libaec.so
z dl
)
else()
find_package(HDF5 CONFIG) find_package(HDF5 CONFIG)
if(NOT HDF5_DIR) if(HDF5_DIR)
message(STATUS "HDF5: found config at '${HDF5_DIR}'.")
set(HDF5_LIBRARIES hdf5_cpp-static)
else()
# If it failed, still try to find as a module.
# E.g. on Ubuntu `libhdf5-dev` doesn't provie hdf5-config.cmake.
# Will automatically fill HDF5_LIBRARIES and HDF5_INCLUDE_DIR.
find_package(HDF5)
if(NOT HDF5_INCLUDE_DIR)
message( message(
FATAL_ERROR FATAL_ERROR
"HDF5_LIBRARY_DIR is not provided (current value: '${HDF5_LIBRARY_DIR}'). " "HDF5_LIBRARY_DIR is not provided (current value: '${HDF5_LIBRARY_DIR}'). "
"Also could not find HDF5 package." "Also could not find HDF5 package (neither module or config)."
) )
endif() endif()
message(STATUS "Found HDF5 package: '${HDF5_DIR}'.")
set(HDF5_LIBRARIES hdf5_cpp-static)
endif() endif()
endif() endif()
@@ -942,7 +930,9 @@ endif(MSVC)
# Ensure other dependencies are provided. # Ensure other dependencies are provided.
if(NOT EXISTS "${EIGEN_DIR}") if(NOT EXISTS "${EIGEN_DIR}")
find_package(Eigen3 CONFIG) find_package(Eigen3 CONFIG)
if(NOT Eigen3_DIR) if(Eigen3_DIR)
message(STATUS "Eigen3: found config at '${Eigen3_DIR}'.")
else()
message( message(
FATAL_ERROR FATAL_ERROR
"EIGEN_DIR is not provided or provided folder doesn't exist (current value: '${EIGEN_DIR}'). " "EIGEN_DIR is not provided or provided folder doesn't exist (current value: '${EIGEN_DIR}'). "
@@ -956,7 +946,7 @@ endif()
include_directories(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} include_directories(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}
${EIGEN_DIR} ${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${USD_INCLUDE_DIR} ${EIGEN_DIR} ${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${USD_INCLUDE_DIR}
${TBB_INCLUDE_DIR} ${ROCKSDB_INCLUDE_DIR} ${ZSTD_INCLUDE_DIR} ${TBB_INCLUDE_DIR}
) )
if(NOT SCHEMA_VERSIONS) if(NOT SCHEMA_VERSIONS)
@@ -1068,12 +1058,14 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON)
set(GEOM_SERIALIZER_SCHEMA_LIBRARIES ${GEOM_SERIALIZER_SCHEMA_LIBRARIES} GeometrySerializers_ifc${schema}) set(GEOM_SERIALIZER_SCHEMA_LIBRARIES ${GEOM_SERIALIZER_SCHEMA_LIBRARIES} GeometrySerializers_ifc${schema})
add_library(geometry_serializer_ifc${schema} STATIC ../src/ifcgeom/Serialization/schema/Serialization.cpp) add_library(geometry_serializer_ifc${schema} STATIC ../src/ifcgeom/Serialization/schema/Serialization.cpp)
set_target_properties(geometry_serializer_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") set_target_properties(geometry_serializer_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOMSERIALIZATION_EXPORTS -DIfcSchema=Ifc${schema}")
target_link_libraries(geometry_serializer_ifc${schema} ${OPENCASCADE_LIBRARIES})
list(APPEND geometry_serializer_libraries geometry_serializer_ifc${schema}) list(APPEND geometry_serializer_libraries geometry_serializer_ifc${schema})
endforeach() endforeach()
add_library(geometry_serializer STATIC ../src/ifcgeom/Serialization/Serialization.cpp) add_library(geometry_serializer STATIC ../src/ifcgeom/Serialization/Serialization.h ../src/ifcgeom/Serialization/Serialization.cpp)
target_link_libraries(geometry_serializer ${geometry_serializer_libraries}) set_target_properties(geometry_serializer PROPERTIES COMPILE_FLAGS "-DIFC_GEOMSERIALIZATION_EXPORTS")
target_link_libraries(geometry_serializer ${geometry_serializer_libraries} IfcParse)
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} geometry_serializer ${geometry_serializer_libraries}) set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} geometry_serializer ${geometry_serializer_libraries})
endif() endif()
endif() endif()
@@ -1111,15 +1103,8 @@ endforeach()
set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES}) set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES})
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
message(STATUS "GCC < 9 detected, linking stdc++fs explicitly")
set(STDCPPFS stdc++fs)
endif()
endif()
add_library(IfcParse ${IFCPARSE_FILES}) add_library(IfcParse ${IFCPARSE_FILES})
target_link_libraries(IfcParse ${ROCKSDB_LIBRARY} ${ZSTD_LIBRARY} ${RPCRT_LIBRARIES} ${STDCPPFS}) target_link_libraries(IfcParse ${STDCPPFS})
set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
if(LibXml2_DIR) if(LibXml2_DIR)
@@ -1132,7 +1117,11 @@ else()
endif() endif()
if(BUILD_IFCGEOM) if(BUILD_IFCGEOM)
if(WITH_CGAL) # CGAL::CGAL target already has dependencies resolved.
if(WITH_CGAL AND CGAL_DIR)
set(CGAL_LIBRARIES CGAL::CGAL)
message(STATUS "Using found CGAL package at '${CGAL_DIR}'")
elseif(WITH_CGAL AND NOT CGAL_DIR)
clear_wasm_sysroot() clear_wasm_sysroot()
find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH) find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH) find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH)
@@ -1154,23 +1143,23 @@ if(BUILD_IFCGEOM)
file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/kernels/${kernel}/*.cpp) file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/kernels/${kernel}/*.cpp)
set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
add_library(geometry_kernel_${kernel} ${IFCGEOM_FILES}) add_library(geometry_kernel_${kernel} ${IFCGEOM_FILES} ../src/ifcgeom/kernels/ifc_geomlibrary_api.h)
set_property(TARGET geometry_kernel_${kernel} APPEND PROPERTY COMPILE_FLAGS "-DIFC_GEOM_EXPORTS") set_property(TARGET geometry_kernel_${kernel} APPEND PROPERTY COMPILE_FLAGS "-DIFC_GEOMLIBRARY_EXPORTS")
# needed? # needed?
# if(NOT WASM_BUILD) # if(NOT WASM_BUILD)
# endif() # endif()
target_link_libraries(geometry_kernel_${kernel} ${${KERNEL_UPPER}_LIBRARIES}) target_link_libraries(geometry_kernel_${kernel} ${${KERNEL_UPPER}_LIBRARIES} IfcGeom IfcParse)
list(APPEND kernel_libraries geometry_kernel_${kernel}) list(APPEND kernel_libraries geometry_kernel_${kernel})
if(${kernel} STREQUAL "cgal") if(${kernel} STREQUAL "cgal")
set_property(TARGET geometry_kernel_${kernel} APPEND_STRING PROPERTY COMPILE_FLAGS " -DCGAL_HAS_THREADS") set_property(TARGET geometry_kernel_${kernel} APPEND_STRING PROPERTY COMPILE_FLAGS " -DCGAL_HAS_THREADS")
add_library(geometry_kernel_${kernel}_simple ${IFCGEOM_FILES}) add_library(geometry_kernel_${kernel}_simple ${IFCGEOM_FILES})
set_target_properties(geometry_kernel_${kernel}_simple PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIFOPSH_SIMPLE_KERNEL -DCGAL_HAS_THREADS") set_target_properties(geometry_kernel_${kernel}_simple PROPERTIES COMPILE_FLAGS "-DIFC_GEOMLIBRARY_EXPORTS -DIFOPSH_SIMPLE_KERNEL -DCGAL_HAS_THREADS")
# needed? # needed?
# if(NOT WASM_BUILD) # if(NOT WASM_BUILD)
# endif() # endif()
target_link_libraries(geometry_kernel_${kernel}_simple ${${KERNEL_UPPER}_LIBRARIES}) target_link_libraries(geometry_kernel_${kernel}_simple ${${KERNEL_UPPER}_LIBRARIES} IfcGeom IfcParse)
list(APPEND kernel_libraries geometry_kernel_${kernel}_simple) list(APPEND kernel_libraries geometry_kernel_${kernel}_simple)
endif() endif()
endforeach() endforeach()
@@ -1184,7 +1173,7 @@ if(BUILD_IFCGEOM)
add_library(geometry_mapping_ifc${schema} STATIC ${IFCGEOM_FILES}) add_library(geometry_mapping_ifc${schema} STATIC ${IFCGEOM_FILES})
set_target_properties(geometry_mapping_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") set_target_properties(geometry_mapping_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}")
target_link_libraries(geometry_mapping_ifc${schema} IfcParse) target_link_libraries(geometry_mapping_ifc${schema} IfcParse IfcGeom)
list(APPEND mapping_libraries geometry_mapping_ifc${schema}) list(APPEND mapping_libraries geometry_mapping_ifc${schema})
endforeach() endforeach()
@@ -1200,11 +1189,7 @@ if(BUILD_IFCGEOM)
find_package(Threads) find_package(Threads)
endif() endif()
if(WASM_BUILD) target_link_libraries(IfcGeom IfcParse ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(IfcGeom ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT})
else()
target_link_libraries(IfcGeom IfcParse ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif(BUILD_IFCGEOM) endif(BUILD_IFCGEOM)
@@ -1219,7 +1204,7 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON)
foreach(schema ${SCHEMA_VERSIONS}) foreach(schema ${SCHEMA_VERSIONS})
add_library(Serializers_ifc${schema} STATIC ${SERIALIZERS_S_FILES}) add_library(Serializers_ifc${schema} STATIC ${SERIALIZERS_S_FILES})
set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORTS -DIfcSchema=Ifc${schema}")
if(WASM_BUILD) if(WASM_BUILD)
target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES}) target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES})
@@ -1229,7 +1214,7 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON)
endforeach() endforeach()
add_library(Serializers ${SERIALIZERS_FILES}) add_library(Serializers ${SERIALIZERS_FILES})
set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS" VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORTS" VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
if(WITH_PROJ) if(WITH_PROJ)
target_compile_definitions(Serializers PRIVATE "WITH_PROJ") target_compile_definitions(Serializers PRIVATE "WITH_PROJ")
@@ -1240,7 +1225,7 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON)
target_link_libraries(Serializers ${PROJ_LIBRARIES}) target_link_libraries(Serializers ${PROJ_LIBRARIES})
endif() endif()
target_link_libraries(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES}) target_link_libraries(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES} IfcGeom ${OPENCASCADE_LIBRARIES} ${kernel_libraries} IfcParse)
endif(BUILD_CONVERT OR BUILD_IFCPYTHON) endif(BUILD_CONVERT OR BUILD_IFCPYTHON)
@@ -1287,7 +1272,7 @@ if(BUILD_CONVERT)
set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES}) set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES})
add_executable(IfcConvert ${IFCCONVERT_FILES}) add_executable(IfcConvert ${IFCCONVERT_FILES})
target_link_libraries(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_LIBRARIES} ${USD_LIBRARIES}) target_link_libraries(IfcConvert IfcGeom IfcParse Serializers ${kernel_libraries} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_LIBRARIES} ${USD_LIBRARIES})
if (WITH_RELATIONSHIP_VALIDATION) if (WITH_RELATIONSHIP_VALIDATION)
set_property(TARGET IfcConvert APPEND_STRING PROPERTY COMPILE_FLAGS " -DWITH_RELATIONSHIP_VALIDATION") set_property(TARGET IfcConvert APPEND_STRING PROPERTY COMPILE_FLAGS " -DWITH_RELATIONSHIP_VALIDATION")
endif() endif()
@@ -1321,7 +1306,7 @@ if(BUILD_GEOMSERVER)
file(GLOB H_FILES ../src/ifcgeomserver/*.h) file(GLOB H_FILES ../src/ifcgeomserver/*.h)
set(SOURCE_FILES ${CPP_FILES} ${H_FILES}) set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
add_executable(IfcGeomServer ${SOURCE_FILES}) add_executable(IfcGeomServer ${SOURCE_FILES})
target_link_libraries(IfcGeomServer ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(IfcGeomServer IfcGeom IfcParse Serializers ${kernel_libraries} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES})
if((NOT WIN32) AND BUILD_SHARED_LIBS) if((NOT WIN32) AND BUILD_SHARED_LIBS)
SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS}") SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS}")
@@ -1337,6 +1322,10 @@ endif(BUILD_GEOMSERVER)
if(ADD_COMMIT_SHA) if(ADD_COMMIT_SHA)
find_package(Git) find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "Failed to find Git for ADD_COMMIT_SHA option.")
endif()
if(GIT_FOUND) if(GIT_FOUND)
if (VERSION_OVERRIDE) if (VERSION_OVERRIDE)
set (git_branch ${RELEASE_VERSION}) set (git_branch ${RELEASE_VERSION})
@@ -1374,8 +1363,10 @@ if(ADD_COMMIT_SHA)
message(FATAL_ERROR "Unable to determine commit sha and/or branch") message(FATAL_ERROR "Unable to determine commit sha and/or branch")
endif() endif()
add_definitions(-DIFCOPENSHELL_BRANCH=${git_branch}) target_compile_definitions(IfcParse PRIVATE
add_definitions(-DIFCOPENSHELL_COMMIT=${git_sha}) -DIFCOPENSHELL_BRANCH=${git_branch}
-DIFCOPENSHELL_COMMIT=${git_sha}
)
endif() endif()
endif(ADD_COMMIT_SHA) endif(ADD_COMMIT_SHA)
@@ -1432,6 +1423,11 @@ if(BUILD_IFCGEOM)
DESTINATION ${INCLUDEDIR}/ifcgeom DESTINATION ${INCLUDEDIR}/ifcgeom
) )
file(GLOB SERIALIZATION_H_FILES ../src/ifcgeom/serialization/*.h)
install(FILES ${SERIALIZATION_H_FILES}
DESTINATION ${INCLUDEDIR}/ifcgeom/serialization
)
foreach(kernel ${GEOMETRY_KERNELS}) foreach(kernel ${GEOMETRY_KERNELS})
file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernels/${kernel}/*.h) file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernels/${kernel}/*.h)
install(FILES ${IFCGEOM_H_FILES} install(FILES ${IFCGEOM_H_FILES}