diff --git a/recipes/ifcopenshell/all/conandata.yml b/recipes/ifcopenshell/all/conandata.yml new file mode 100644 index 0000000000000..803ff17086713 --- /dev/null +++ b/recipes/ifcopenshell/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "0.8.3.cci.20250613": + url: "https://github.com/IfcOpenShell/IfcOpenShell/archive/refs/tags/bonsai-0.8.3-alpha2506131434.tar.gz" + sha256: "369737ed12eb754c93319c7a5a4ee3dd9650ceca965349eb09ee30d327c20f0f" +patches: + "0.8.3.cci.20250613": + - patch_file: "patches/patchRootCMakeLists.patch" + patch_description: "Have options moved after project()" + patch_type: "conan" \ No newline at end of file diff --git a/recipes/ifcopenshell/all/conanfile.py b/recipes/ifcopenshell/all/conanfile.py new file mode 100644 index 0000000000000..7b5664d29ed72 --- /dev/null +++ b/recipes/ifcopenshell/all/conanfile.py @@ -0,0 +1,233 @@ + +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file +from conan.tools.apple import is_apple_os + +required_conan_version = ">=2.1" + +IFC_SCHEMAS = sorted(["2x3", "4", "4x1", "4x2", "4x3", "4x3_tc1", "4x3_add1", "4x3_add2"]) + +class IfcopenshellConan(ConanFile): + name = "ifcopenshell" + description = "Open source IFC library and geometry engine" + license = "LGPL-3.0-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://ifcopenshell.org/" + topics = ("ifc", "bim") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "build_ifcgeom": [True, False], + "build_convert": [True, False], + "ifcxml_support": [True, False], + "use_mmap": [True, False], + "with_cgal": [True, False], + "with_hdf5": [True, False], + } + options.update({f"schema_{schema}": [True, False] for schema in IFC_SCHEMAS}) + default_options = { + "shared": False, + "fPIC": True, + "build_ifcgeom": True, + "build_convert": True, + "ifcxml_support": True, + "use_mmap": True, + "with_cgal": True, + "with_hdf5": True, + } + # Limit the default set of schemas to the basic ones and the latest to limit the size of the build. + default_options.update({f"schema_{schema}": schema in ["4", "4x3_add2"] for schema in IFC_SCHEMAS}) + implements = ["auto_shared_fpic"] + + @property + def _selected_ifc_schemas(self): + return [schema for schema in IFC_SCHEMAS if self.options.get_safe(f"schema_{schema}")] + + def export_sources(self): + export_conandata_patches(self) + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + if not self.options.build_ifcgeom: + del self.options.with_cgal + if not self.options.build_convert: + del self.options.with_hdf5 + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + if self.options.build_convert and not self.options.build_ifcgeom: + raise ConanInvalidConfiguration("build_convert requires build_ifcgeom to be enabled") + if is_apple_os(self) or self.settings.os == "Windows": + raise ConanInvalidConfiguration("Disable temporary apple platform") + if self.options.shared: + raise ConanInvalidConfiguration("Disable temporary shared build") + + def requirements(self): + self.requires("boost/1.83.0", transitive_headers=True, transitive_libs=True) + if self.options.get_safe("with_hdf5"): + # Used in public serializers/HdfSerializer.h, ifcgeom/kernels/opencascade/IfcGeomTree.h + self.requires("hdf5/[^1.8]", transitive_headers=True, transitive_libs=True) + if self.options.build_ifcgeom: + self.requires("opencascade/[^7.5]", transitive_headers=True, transitive_libs=True) + # ifcgeom/taxonomy.h + self.requires("eigen/3.4.0", transitive_headers=True) + if self.options.with_cgal: + # Used in ifcgeom/kernels/cgal public headers + self.requires("cgal/[>=5.6]", transitive_headers=True, transitive_libs=True) + self.requires("gmp/[^6.3.0]") + self.requires("mpfr/[^4.2.1]") + if self.options.build_ifcgeom or self.options.ifcxml_support: + self.requires("libxml2/[^2.12.5]") + + def build_requirements(self): + self.tool_requires("cmake/[>=3.21 <5]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def generate(self): + def includedir(dep): + return self.dependencies[dep].cpp_info.includedirs[0].replace("\\", "/") + + def libdir(dep): + return self.dependencies[dep].cpp_info.libdirs[0].replace("\\", "/") + + tc = CMakeToolchain(self) + tc.variables["BUILD_IFCGEOM"] = self.options.build_ifcgeom + tc.variables["BUILD_CONVERT"] = self.options.build_convert + tc.variables["BUILD_GEOMSERVER"] = False + tc.variables["BUILD_IFCPYTHON"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["IFCXML_SUPPORT"] = self.options.ifcxml_support + tc.variables["USE_MMAP"] = self.options.use_mmap + tc.variables["SCHEMA_VERSIONS"] = ";".join(self._selected_ifc_schemas) + tc.variables["WITH_OPENCASCADE"] = self.options.build_ifcgeom + tc.variables["WITH_CGAL"] = self.options.get_safe("with_cgal") + tc.variables["HDF5_SUPPORT"] = self.options.get_safe("with_hdf5") + tc.variables["COLLADA_SUPPORT"] = False + if self.options.build_ifcgeom: + tc.variables["EIGEN_DIR"] = includedir("eigen") + "/eigen3/" + if self.options.get_safe("with_cgal"): + tc.variables["CGAL_INCLUDE_DIR"] = includedir("cgal") + tc.variables["CGAL_LIBRARY_DIR"] = libdir("cgal") + tc.variables["GMP_INCLUDE_DIR"] = includedir("gmp") + tc.variables["GMP_LIBRARY_DIR"] = libdir("gmp") + tc.variables["MPFR_INCLUDE_DIR"] = includedir("mpfr") + tc.variables["MPFR_LIBRARY_DIR"] = libdir("mpfr") + if self.options.get_safe("with_hdf5"): + tc.variables["HDF5_INCLUDE_DIR"] = includedir("hdf5") + tc.variables["HDF5_LIBRARY_DIR"] = libdir("hdf5") + + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder="cmake") + cmake.build() + + def package(self): + copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + # No official CMake or .pc config exported. Based on CPack values for consistency. + self.cpp_info.set_property("cmake_file_name", "IfcOpenShell") + + def _add_component(name, requires=None): + component = self.cpp_info.components[name] + component.set_property("cmake_target_name", name) + component.libs = [name] + component.requires = requires or [] + return component + + ifcparse = _add_component("IfcParse", requires=[ + "boost::system", + "boost::program_options", + "boost::regex", + "boost::thread", + "boost::date_time", + ]) + if self.options.use_mmap: + ifcparse.requires.extend(["boost::iostreams", "boost::filesystem",]) + ifcparse.defines.append("USE_MMAP") + if self.options.ifcxml_support: + ifcparse.requires.append("libxml2::libxml2") + ifcparse.defines.append("WITH_IFCXML") + ifcparse.defines.append(f"SCHEMA_SEQ=({')('.join(self._selected_ifc_schemas)})") + for schema in self._selected_ifc_schemas: + ifcparse.defines.append(f"HAS_SCHEMA_{schema}") + if self.options.shared: + ifcparse.defines.append("IFC_SHARED_BUILD") + if self.settings.os in ["Linux", "FreeBSD"]: + ifcparse.system_libs = ["m", "dl"] + + if self.options.build_ifcgeom: + ifcgeom = _add_component("IfcGeom", requires=["IfcParse", "eigen::eigen"]) + if self.settings.os in ["Linux", "FreeBSD"]: + ifcgeom.system_libs.append("pthread") + + if self.options.with_cgal: + _add_component("geometry_kernel_cgal", requires=["cgal::cgal", "mpfr::mpfr", "gmp::gmp", "eigen::eigen",]) + ifcgeom.requires.append("geometry_kernel_cgal") + simple = _add_component("geometry_kernel_cgal_simple", requires=["cgal::cgal", "gmp::gmp", "eigen::eigen",]) + simple.defines.append("IFOPSH_SIMPLE_KERNEL") + ifcgeom.requires.append("geometry_kernel_cgal_simple") + + _add_component("geometry_kernel_opencascade", requires=[ + "opencascade::occt_tkernel", + "opencascade::occt_tkmath", + "opencascade::occt_tkbrep", + "opencascade::occt_tkgeombase", + "opencascade::occt_tkgeomalgo", + "opencascade::occt_tkg3d", + "opencascade::occt_tkg2d", + "opencascade::occt_tkshhealing", + "opencascade::occt_tktopalgo", + "opencascade::occt_tkmesh", + "opencascade::occt_tkprim", + "opencascade::occt_tkbool", + "opencascade::occt_tkbo", + "opencascade::occt_tkfillet", + "opencascade::occt_tkxsbase", + "opencascade::occt_tkoffset", + "opencascade::occt_tkhlr", + "eigen::eigen", + ]) + ifcgeom.requires.append("geometry_kernel_opencascade") + ifcgeom.defines.append("IFOPSH_WITH_OPENCASCADE") + + for schema in self._selected_ifc_schemas: + _add_component(f"geometry_mapping_ifc{schema}", requires=["IfcParse"]) + ifcgeom.requires.append(f"geometry_mapping_ifc{schema}") + + if self.options.build_convert: + serializers = _add_component("Serializers", requires=["IfcGeom"]) + if self.options.with_hdf5: + serializers.requires.append("hdf5::hdf5_cpp") + + for schema in self._selected_ifc_schemas: + component_name = f"Serializers_ifc{schema}" + _add_component(component_name) + self.cpp_info.components["Serializers"].requires.append(component_name) + + geometry_serializer = _add_component("geometry_serializer", ["IfcParse", "IfcGeom", "opencascade::occt_tktopalgo", "opencascade::occt_tkbrep"]) + for schema in self._selected_ifc_schemas: + component_name = f"geometry_serializer_ifc{schema}" + _add_component(component_name, requires=["IfcParse", f"Serializers_ifc{schema}", f"geometry_mapping_ifc{schema}", "IfcGeom", "opencascade::occt_tkmesh", "opencascade::occt_tkxmesh", "opencascade::occt_tkmeshvs", "opencascade::occt_tktopalgo", "opencascade::occt_tkbrep", "opencascade::occt_tkgeomalgo"]) + geometry_serializer.requires.append(component_name) diff --git a/recipes/ifcopenshell/all/patches/patchRootCMakeLists.patch b/recipes/ifcopenshell/all/patches/patchRootCMakeLists.patch new file mode 100644 index 0000000000000..6b648e61d5467 --- /dev/null +++ b/recipes/ifcopenshell/all/patches/patchRootCMakeLists.patch @@ -0,0 +1,359 @@ +diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt +index 65e166aad..a3161b18c 100644 +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -18,6 +18,19 @@ + ################################################################################ + + cmake_minimum_required(VERSION 3.21) ++ ++option(VERSION_OVERRIDE "Override the version defined in IfcParse.h with the file VERSION in the repository root" OFF) ++ ++if (VERSION_OVERRIDE) ++ file(READ "../VERSION" "RELEASE_VERSION_") ++ string(STRIP "${RELEASE_VERSION_}" RELEASE_VERSION) ++ message(STATUS "Detected version '${RELEASE_VERSION}'") ++else() ++ set(RELEASE_VERSION "0.8.0") ++endif() ++ ++project(IfcOpenShell VERSION ${RELEASE_VERSION}) ++ + set(CMAKE_CXX_STANDARD_REQUIRED ON) # not necessary, but encouraged + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +@@ -81,17 +94,6 @@ option(WITH_RELATIONSHIP_VALIDATION "Build IfcConvert with option to validate ge + + 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(VERSION_OVERRIDE "Override the version defined in IfcParse.h with the file VERSION in the repository root" OFF) +- +-if (VERSION_OVERRIDE) +- file(READ "../VERSION" "RELEASE_VERSION_") +- string(STRIP "${RELEASE_VERSION_}" RELEASE_VERSION) +- message(STATUS "Detected version '${RELEASE_VERSION}'") +-else() +- set(RELEASE_VERSION "0.8.0") +-endif() +- +-project(IfcOpenShell VERSION ${RELEASE_VERSION}) + + if(MINIMAL_BUILD) + message(STATUS "Setting options for minimal build") +@@ -362,9 +364,7 @@ if(IFCXML_SUPPORT) + endif() + + if(BUILD_IFCGEOM) +- if(MSVC) +- add_debug_variants(LIBXML2_LIBRARIES "${LIBXML2_LIBRARIES}" d) +- endif() ++ find_package(Eigen3 REQUIRED CONFIG) + + # Open CASCADE + if(WITH_OPENCASCADE) +@@ -419,59 +419,46 @@ if(BUILD_IFCGEOM) + list(APPEND OPENCASCADE_LIBRARY_NAMES TKDESTEP TKDEIGES) + endif(OCC_VERSION_STRING VERSION_LESS 7.8.0) + +- if("${OCC_LIBRARY_DIR}" STREQUAL "") +- find_library(OCC_LIBRARY TKernel +- PATHS +- /usr/lib +- REQUIRED +- ) +- +- if(OCC_LIBRARY) +- GET_FILENAME_COMPONENT(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH) +- message(STATUS "Found Open CASCADE library files in: ${OCC_LIBRARY_DIR}") +- else() +- message(FATAL_ERROR "Unable find Open CASCADE library directory, specify OCC_LIBRARY_DIR manually.") +- endif() +- else() +- 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}") +- endif() ++ # if("${OCC_LIBRARY_DIR}" STREQUAL "") ++ # find_library(OCC_LIBRARY TKernel ++ # PATHS ++ # /usr/lib ++ # REQUIRED ++ # ) ++ ++ # if(OCC_LIBRARY) ++ # GET_FILENAME_COMPONENT(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH) ++ # message(STATUS "Found Open CASCADE library files in: ${OCC_LIBRARY_DIR}") ++ # else() ++ # message(FATAL_ERROR "Unable find Open CASCADE library directory, specify OCC_LIBRARY_DIR manually.") ++ # endif() ++ # else() ++ # 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}") ++ # endif() + + clear_wasm_sysroot() +- find_library(libTKernel NAMES TKernel TKerneld PATHS ${OCC_LIBRARY_DIR} NO_DEFAULT_PATH) ++ find_package(OpenCASCADE REQUIRED FoundationClasses ModelingData ModelingAlgorithms CONFIG) ++ # find_library(libTKernel NAMES TKernel TKerneld PATHS ${OCC_LIBRARY_DIR} NO_DEFAULT_PATH) + restore_wasm_sysroot() + +- if(libTKernel) +- message(STATUS "Required Open Cascade Library files found") +- else() +- message(FATAL_ERROR "Unable to find Open Cascade library files, aborting") +- endif() ++ # if(libTKernel) ++ # message(STATUS "Required Open Cascade Library files found") ++ # else() ++ # message(FATAL_ERROR "Unable to find Open Cascade library files, aborting") ++ # endif() + + # Use the found libTKernel as a template for all other OCC libraries + # TODO Extract this into macro/function +- foreach(lib ${OPENCASCADE_LIBRARY_NAMES}) +- # Make sure we'll handle the Windows/MSVC debug postfix convention too. +- string(REPLACE TKerneld "${lib}" lib_path "${libTKernel}") +- string(REPLACE TKernel "${lib}" lib_path "${lib_path}") +- list(APPEND OPENCASCADE_LIBRARIES "${lib_path}") +- endforeach() ++ set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARY_NAMES}) ++ # foreach(lib ${OPENCASCADE_LIBRARY_NAMES}) ++ # # Make sure we'll handle the Windows/MSVC debug postfix convention too. ++ # string(REPLACE TKerneld "${lib}" lib_path "${libTKernel}") ++ # string(REPLACE TKernel "${lib}" lib_path "${lib_path}") ++ # list(APPEND OPENCASCADE_LIBRARIES "${lib_path}") ++ # endforeach() + +- if(MSVC) +- add_definitions(-DHAVE_NO_DLL) +- add_debug_variants(OPENCASCADE_LIBRARIES "${OPENCASCADE_LIBRARIES}" d) +- endif() +- +- if(WIN32) +- # OCC might require linking to Winsock depending on the version and build configuration +- list(APPEND OPENCASCADE_LIBRARIES ws2_32.lib) +- endif() +- +- # Make sure cross-referenced symbols between static OCC libraries get +- # resolved. Also add thread and rt libraries. +- get_filename_component(libTKernelExt ${libTKernel} EXT) +- if("${libTKernelExt}" STREQUAL ".a") +- set(OCCT_STATIC ON) +- endif() ++ list(APPEND OPENCASCADE_LIBRARIES "Eigen3::Eigen") + + if(OCCT_STATIC) + find_package(Threads) +@@ -572,10 +559,6 @@ if(COLLADA_SUPPORT) + message(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find PCRE. " + "Disable COLLADA_SUPPORT or fix PCRE_LIBRARY_DIR path to proceed.") + endif() +- +- if(MSVC) +- add_debug_variants(OPENCOLLADA_LIBRARIES "${OPENCOLLADA_LIBRARIES}" d) +- endif() + else() + message(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find OpenCOLLADA headers. " + "Disable COLLADA_SUPPORT or fix OpenCOLLADA paths to proceed.") +@@ -583,6 +566,7 @@ if(COLLADA_SUPPORT) + endif(COLLADA_SUPPORT) + + if(HDF5_SUPPORT) ++ find_package(HDF5 REQUIRED) + if("${HDF5_INCLUDE_DIR}" STREQUAL "") + message(STATUS "No HDF5 include directory specified") + else() +@@ -612,12 +596,7 @@ if(HDF5_SUPPORT) + set(debug_postfix "_debug") + endif() + +- set(HDF5_LIBRARIES +- "${HDF5_LIBRARY_DIR}/libhdf5_cpp${debug_postfix}.${lib_ext}" +- "${HDF5_LIBRARY_DIR}/libhdf5${debug_postfix}.${lib_ext}" +- "${HDF5_LIBRARY_DIR}/libz${zlib_post}${debug_postfix}.${lib_ext}" +- "${HDF5_LIBRARY_DIR}/libsz${debug_postfix}.${lib_ext}" +- "${HDF5_LIBRARY_DIR}/libaec${debug_postfix}.${lib_ext}" ++ set(HDF5_LIBRARIES "HDF5::HDF5" + ) + + else() +@@ -886,12 +865,14 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON) + foreach(schema ${SCHEMA_VERSIONS}) + 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} ../src/ifcgeom/Serialization/schema/Serialization.cpp) + set_target_properties(geometry_serializer_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") + list(APPEND geometry_serializer_libraries geometry_serializer_ifc${schema}) ++ target_link_libraries(geometry_serializer_ifc${schema} TKBRep) + endforeach() + +- add_library(geometry_serializer STATIC ../src/ifcgeom/Serialization/Serialization.cpp) ++ add_library(geometry_serializer ../src/ifcgeom/Serialization/Serialization.cpp) ++ file(GLOB IFCGEOM_SERIALIZATION_H_FILE ../src/ifcgeom/Serialization/*.h) + target_link_libraries(geometry_serializer ${geometry_serializer_libraries}) + set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} geometry_serializer ${geometry_serializer_libraries}) + endif() +@@ -978,7 +959,7 @@ if(BUILD_IFCGEOM) + # needed? + # if(NOT WASM_BUILD) + # endif() +- target_link_libraries(geometry_kernel_${kernel}_simple ${${KERNEL_UPPER}_LIBRARIES}) ++ target_link_libraries(geometry_kernel_${kernel}_simple ${${KERNEL_UPPER}_LIBRARIES} "Eigen3::Eigen") + list(APPEND kernel_libraries geometry_kernel_${kernel}_simple) + endif() + endforeach() +@@ -990,7 +971,7 @@ if(BUILD_IFCGEOM) + file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/mapping/*.cpp) + set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES} ${IFCGEOM_I_FILES}) + +- add_library(geometry_mapping_ifc${schema} STATIC ${IFCGEOM_FILES}) ++ add_library(geometry_mapping_ifc${schema} ${IFCGEOM_FILES}) + set_target_properties(geometry_mapping_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") + target_link_libraries(geometry_mapping_ifc${schema} IfcParse) + list(APPEND mapping_libraries geometry_mapping_ifc${schema}) +@@ -1009,9 +990,9 @@ if(BUILD_IFCGEOM) + endif() + + if(WASM_BUILD) +- target_link_libraries(IfcGeom ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT}) ++ target_link_libraries(IfcGeom ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen") + else() +- target_link_libraries(IfcGeom IfcParse ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT}) ++ target_link_libraries(IfcGeom IfcParse ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen") + endif() + + endif(BUILD_IFCGEOM) +@@ -1026,7 +1007,7 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON) + set(SERIALIZERS_S_FILES ${SERIALIZERS_S_H_FILES} ${SERIALIZERS_S_CPP_FILES}) + + foreach(schema ${SCHEMA_VERSIONS}) +- add_library(Serializers_ifc${schema} STATIC ${SERIALIZERS_S_FILES}) ++ add_library(Serializers_ifc${schema} ${SERIALIZERS_S_FILES}) + set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") + + if(WASM_BUILD) +@@ -1104,12 +1085,12 @@ if(BUILD_CONVERT) + set_property(TARGET IfcConvert APPEND_STRING PROPERTY COMPILE_FLAGS " -DIFOPSH_WITH_CITYJSON") + endif() + +- if((NOT WIN32) AND BUILD_SHARED_LIBS) +- # Only set RPATHs when building shared libraries (i.e. IfcParse and +- # IfcGeom are dynamically linked). Not necessarily a perfect solution +- # but probably a good indication of whether RPATHs are necessary. +- SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR}") +- endif() ++ # if((NOT WIN32) AND BUILD_SHARED_LIBS) ++ # # Only set RPATHs when building shared libraries (i.e. IfcParse and ++ # # IfcGeom are dynamically linked). Not necessarily a perfect solution ++ # # but probably a good indication of whether RPATHs are necessary. ++ # SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR}") ++ # endif() + + install(TARGETS IfcConvert + ARCHIVE DESTINATION ${LIBDIR} +@@ -1126,9 +1107,9 @@ if(BUILD_GEOMSERVER) + add_executable(IfcGeomServer ${SOURCE_FILES}) + target_link_libraries(IfcGeomServer ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES}) + +- if((NOT WIN32) AND BUILD_SHARED_LIBS) +- SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS}") +- endif() ++ # if((NOT WIN32) AND BUILD_SHARED_LIBS) ++ # SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS}") ++ # endif() + + install(TARGETS IfcGeomServer + ARCHIVE DESTINATION ${LIBDIR} +@@ -1207,9 +1188,9 @@ if(BUILD_IFCMAX) + add_subdirectory(../src/ifcmax ifcmax) + endif() + +-if(WITH_CGAL) +- add_subdirectory(../src/svgfill svgfill) +-endif() ++# if(WITH_CGAL) ++# add_subdirectory(../src/svgfill svgfill) ++# endif() + + if(BUILD_QTVIEWER) + add_subdirectory(../src/qtviewer qtviewer) +@@ -1227,14 +1208,18 @@ install(TARGETS IfcParse + ) + + if(BUILD_IFCGEOM) +- # install(FILES ${IFCGEOM_H_FILES} +- # DESTINATION ${INCLUDEDIR}/ifcgeom +- # ) ++ install(FILES ${IFCGEOM_H_FILES} ++ DESTINATION ${INCLUDEDIR}/ifcgeom ++ ) + + install(FILES ${SCHEMA_AGNOSTIC_H_FILES} + DESTINATION ${INCLUDEDIR}/ifcgeom + ) + ++ install(FILES ${IFCGEOM_SERIALIZATION_H_FILE} ++ DESTINATION ${INCLUDEDIR}/ifcgeom/Serialization ++ ) ++ + foreach(kernel ${GEOMETRY_KERNELS}) + file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernels/${kernel}/*.h) + install(FILES ${IFCGEOM_H_FILES} +diff --git a/src/ifcwrap/CMakeLists.txt b/src/ifcwrap/CMakeLists.txt +index 187f0f958..7940104ee 100644 +--- a/src/ifcwrap/CMakeLists.txt ++++ b/src/ifcwrap/CMakeLists.txt +@@ -111,28 +111,28 @@ IF((PYTHONINTERP_FOUND AND NOT "${PYTHON_EXECUTABLE}" STREQUAL "") OR PYTHON_MOD + set(python_package_dir ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}/dist-packages/) + endif() + endif() +- IF("${python_package_dir}" STREQUAL "") +- MESSAGE(WARNING "Unable to locate Python site-package directory, unable to install the Python wrapper") +- ELSE() +- FILE(GLOB_RECURSE sourcefiles +- "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/*" +- ) +- FOREACH(file ${sourcefiles}) +- FILE(RELATIVE_PATH relative "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/" "${file}") +- GET_FILENAME_COMPONENT(dir "${relative}" DIRECTORY) +- if(NOT IS_DIRECTORY "${file}") +- INSTALL(FILES "${file}" +- DESTINATION "${python_package_dir}/ifcopenshell/${dir}") +- endif() +- ENDFOREACH() +- INSTALL(FILES "${CMAKE_BINARY_DIR}/ifcwrap/ifcopenshell_wrapper.py" +- DESTINATION "${python_package_dir}/ifcopenshell") +- INSTALL(TARGETS ${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} +- DESTINATION "${python_package_dir}/ifcopenshell") +- if (MSVC) +- INSTALL(FILES $ DESTINATION bin OPTIONAL) +- endif() +- ENDIF() ++ # IF("${python_package_dir}" STREQUAL "") ++ # MESSAGE(WARNING "Unable to locate Python site-package directory, unable to install the Python wrapper") ++ # ELSE() ++ # FILE(GLOB_RECURSE sourcefiles ++ # "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/*" ++ # ) ++ # FOREACH(file ${sourcefiles}) ++ # FILE(RELATIVE_PATH relative "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/" "${file}") ++ # GET_FILENAME_COMPONENT(dir "${relative}" DIRECTORY) ++ # if(NOT IS_DIRECTORY "${file}") ++ # INSTALL(FILES "${file}" ++ # DESTINATION "${python_package_dir}/ifcopenshell/${dir}") ++ # endif() ++ # ENDFOREACH() ++ # INSTALL(FILES "${CMAKE_BINARY_DIR}/ifcwrap/ifcopenshell_wrapper.py" ++ # DESTINATION "${python_package_dir}/ifcopenshell") ++ # INSTALL(TARGETS ${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} ++ # DESTINATION "${python_package_dir}/ifcopenshell") ++ # if (MSVC) ++ # INSTALL(FILES $ DESTINATION bin OPTIONAL) ++ # endif() ++ # ENDIF() + ELSE() + MESSAGE(WARNING "No Python interpreter found, unable to install the Python wrapper") + ENDIF() +-- +2.43.0 + diff --git a/recipes/ifcopenshell/all/test_package/CMakeLists.txt b/recipes/ifcopenshell/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b10c02dd9fe1d --- /dev/null +++ b/recipes/ifcopenshell/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(IfcOpenShell CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE + IfcParse + IfcGeom + geometry_serializer + ) \ No newline at end of file diff --git a/recipes/ifcopenshell/all/test_package/conanfile.py b/recipes/ifcopenshell/all/test_package/conanfile.py new file mode 100644 index 0000000000000..2e77b4246fa81 --- /dev/null +++ b/recipes/ifcopenshell/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ifcopenshell/all/test_package/test_package.cpp b/recipes/ifcopenshell/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c779f88919538 --- /dev/null +++ b/recipes/ifcopenshell/all/test_package/test_package.cpp @@ -0,0 +1,157 @@ +/******************************************************************************** + * * + * This file is part of IfcOpenShell. * + * * + * IfcOpenShell is free software: you can redistribute it and/or modify * + * it under the terms of the Lesser GNU General Public License as published by * + * the Free Software Foundation, either version 3.0 of the License, or * + * (at your option) any later version. * + * * + * IfcOpenShell is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * Lesser GNU General Public License for more details. * + * * + * You should have received a copy of the Lesser GNU General Public License * + * along with this program. If not, see . * + * * + ********************************************************************************/ + + // Schema selection for IFC schemas in descending order (highest first) +#ifdef HAS_SCHEMA_4x3_add2 +#define IfcSchema Ifc4x3_add2 +#elif defined(HAS_SCHEMA_4x3_add1) +#define IfcSchema Ifc4x3_add1 +#elif defined(HAS_SCHEMA_4x3_tc1) +#define IfcSchema Ifc4x3_tc1 +#elif defined(HAS_SCHEMA_4x3) +#define IfcSchema Ifc4x3 +#elif defined(HAS_SCHEMA_4x2) +#define IfcSchema Ifc4x2 +#elif defined(HAS_SCHEMA_4x1) +#define IfcSchema Ifc4x1 +#elif defined(HAS_SCHEMA_4) +#define IfcSchema Ifc4 +#elif defined(HAS_SCHEMA_2x3) +#define IfcSchema Ifc2x3 +#else +#error "No IFC schema defined. At least one HAS_SCHEMA_ must be defined." +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +#include + + // Schema selection for IFC schemas in descending order (highest first) +#ifdef HAS_SCHEMA_4x3_add2 +#define IfcSchema Ifc4x3_add2 +#include +#elif defined(HAS_SCHEMA_4x3_add1) +#define IfcSchema Ifc4x3_add1 +#include +#elif defined(HAS_SCHEMA_4x3_tc1) +#define IfcSchema Ifc4x3_tc1 +#include +#elif defined(HAS_SCHEMA_4x3) +#define IfcSchema Ifc4x3 +#include +#elif defined(HAS_SCHEMA_4x2) +#define IfcSchema Ifc4x2 +#include +#elif defined(HAS_SCHEMA_4x1) +#define IfcSchema Ifc4x1 +#include +#elif defined(HAS_SCHEMA_4) +#define IfcSchema Ifc4 +#include +#elif defined(HAS_SCHEMA_2x3) +#define IfcSchema Ifc2x3 +#define IFC2X3_COMPATIBLE +#include +#else +#error "No compatible IFC schema defined. At least one HAS_SCHEMA_ must be defined." +#endif + +#include +#include +#include + +using namespace std::string_literals; +typedef IfcParse::IfcGlobalId guid; +boost::none_t const null = boost::none; + +// Create a simple NURBS surface for IfcSite to test Open CASCADE +void createGroundShape(TopoDS_Shape& shape) { + TColgp_Array2OfPnt cv(0, 1, 0, 1); + cv.SetValue(0, 0, gp_Pnt(-1000, -1000, 0)); + cv.SetValue(0, 1, gp_Pnt(-1000, 1000, 0)); + cv.SetValue(1, 0, gp_Pnt(1000, -1000, 0)); + cv.SetValue(1, 1, gp_Pnt(1000, 1000, 0)); + TColStd_Array1OfReal knots(0, 1); + knots(0) = 0; + knots(1) = 1; + TColStd_Array1OfInteger mult(0, 1); + mult(0) = 2; + mult(1) = 2; + Handle(Geom_BSplineSurface) surf = new Geom_BSplineSurface(cv, knots, knots, mult, mult, 1, 1); +#if OCC_VERSION_HEX < 0x60502 + shape = BRepBuilderAPI_MakeFace(surf); +#else + shape = BRepBuilderAPI_MakeFace(surf, Precision::Confusion()); +#endif +} + +int main() { + // Initialize IFC file + IfcHierarchyHelper file; + file.header().file_name().name("Test.ifc"); + + IfcSchema::IfcWall* wall = new IfcSchema::IfcWall( + guid(), // GlobalId + nullptr, // OwnerHistory + "Test Wall"s, // Name + boost::none, // Description + boost::none, // ObjectType + nullptr, // ObjectPlacement + nullptr, // Representation + boost::none // v8_Tag +#if !defined(IFC2X3_COMPATIBLE) + , boost::none // PredefinedType (required for IFC4 and later) +#endif + ); + + file.addBuildingProduct(wall); + wall->setOwnerHistory(file.getSingle()); + wall->setRepresentation(file.addBox(1000, 300, 2000)); + wall->setObjectPlacement(file.addLocalPlacement()); + + // Create a site with a simple NURBS surface to test Open CASCADE + TopoDS_Shape shape; + createGroundShape(shape); + IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(STRINGIFY(IfcSchema), shape, 100.)->as(); + file.getSingle()->setRepresentation(ground_representation); + file.addEntity(ground_representation); + + // Write IFC file + std::ofstream f("Test.ifc"); + if (!f.is_open()) { + std::cerr << "Failed to open Test.ifc" << std::endl; + return 1; + } + f << file; + f.close(); + + std::cout << "Test.ifc created successfully" << std::endl; + return 0; +} diff --git a/recipes/ifcopenshell/config.yml b/recipes/ifcopenshell/config.yml new file mode 100644 index 0000000000000..59ac08d9edc6e --- /dev/null +++ b/recipes/ifcopenshell/config.yml @@ -0,0 +1,3 @@ +versions: + "0.8.3.cci.20250613": + folder: all \ No newline at end of file