From 41308cf122fa15d5eaffc1da1c160f3f189ac293 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 30 Jul 2026 08:54:08 +0200 Subject: [PATCH] Cmake install config fixes --- cmake/CMakeLists.txt | 11 ++++++++++- src/examples/CMakeLists.txt | 10 ++++++++-- src/examples/IfcAdvancedHouse.cpp | 9 +++++++-- src/ifcconvert/CMakeLists.txt | 2 +- src/ifcgeom/CMakeLists.txt | 4 ++++ src/ifcgeom/Serialization/CMakeLists.txt | 12 +++++++++++- ...opencascade_geometry_ifc_writer_plugin.cpp | 2 +- src/ifcgeom/kernels/CMakeLists.txt | 9 +++++++++ src/ifcgeom/mapping/CMakeLists.txt | 2 +- src/ifcparse/CMakeLists.txt | 19 +++++++++++++++---- src/plugin/CMakeLists.txt | 6 +++++- src/plugin/plugin.cpp | 3 --- src/plugin/plugin.h | 3 +++ 13 files changed, 75 insertions(+), 17 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index af3ee1456f..0e5d7bc01f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -208,6 +208,8 @@ endif() include(GNUInstallDirs) +set(IFCOPENSHELL_EXPORT_TARGETS "${PROJECT_NAME}Targets") + if(NOT INCLUDEDIR) set(INCLUDEDIR include) endif() @@ -317,6 +319,8 @@ if (WITH_ROCKSDB) find_package(zstd CONFIG REQUIRED) message(STATUS "zstd: found at '${zstd_DIR}'.") endif() + + install(TARGETS IFCOPENSHELL_RocksDB EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}) endif() # Find Boost: On win32 the (hardcoded) default is to use static libraries and @@ -734,7 +738,10 @@ if(BUILD_IFCGEOM) ) endforeach() - install(TARGETS ${IFCGEOM_SCHEMA_LIBRARIES} ${kernel_libraries} IfcGeom) + install( + TARGETS ${IFCGEOM_SCHEMA_LIBRARIES} ${kernel_libraries} IfcGeom + EXPORT ${IFCOPENSHELL_EXPORT_TARGETS} + ) endif(BUILD_IFCGEOM) if(BUILD_BONSAIVIEWER) # IfcViewer is the unified scene + render lib since the wgpu/ifcviewer @@ -797,3 +804,5 @@ set(CPACK_DEBIAN_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/debian/postinst") include(CPack) + +include(package_export.cmake) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index b0e9ef78e4..96de111ddb 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -75,8 +75,14 @@ macro(build_example exe_name) endmacro() macro(build_schema_example exe_name schema) - build_example(${exe_name} ${ARGN}) - if(NOT STANDALONE_PROJECT) + build_example(${exe_name} ${schema} ${ARGN}) + if(STANDALONE_PROJECT) + target_link_libraries(${exe_name} IfcOpenShell::parse_schema_ifc${schema}) + target_compile_definitions( + ${exe_name} + PRIVATE IFCOPENSHELL_EXAMPLE_PLUGIN_PATH="$" + ) + else() target_link_libraries(${exe_name} parse_schema_ifc${schema}) endif() endmacro() diff --git a/src/examples/IfcAdvancedHouse.cpp b/src/examples/IfcAdvancedHouse.cpp index a07ed94ed9..5d13a516f5 100644 --- a/src/examples/IfcAdvancedHouse.cpp +++ b/src/examples/IfcAdvancedHouse.cpp @@ -48,6 +48,7 @@ #include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) #include "ifcparse/hierarchy_helper.h" +#include "plugin/plugin.h" #include "../ifcgeom/Serialization/Serialization.h" @@ -62,6 +63,10 @@ void createGroundShape(TopoDS_Shape& shape); int main() { +#ifdef IFCOPENSHELL_EXAMPLE_PLUGIN_PATH + ifcopenshell::plugin::set_search_paths({IFCOPENSHELL_EXAMPLE_PLUGIN_PATH}); +#endif + // The hierarchy_helper is a subclass of the regular file that provides several // convenience functions for working with geometry in IFC files. hierarchy_helper file; @@ -99,8 +104,8 @@ int main() { auto building_shape = IfcGeom::serialise(file, building_shell, false).as(); file.add_entity(building_shape); - auto rep = building_shape.Representations().begin(); - rep->setContextOfItems(file.getRepresentationContext("model")); + auto building_representations = building_shape.Representations(); + building_representations.front().setContextOfItems(file.getRepresentationContext("model")); building.setRepresentation(building_shape); diff --git a/src/ifcconvert/CMakeLists.txt b/src/ifcconvert/CMakeLists.txt index 474e4fcf92..d6be2bd21c 100644 --- a/src/ifcconvert/CMakeLists.txt +++ b/src/ifcconvert/CMakeLists.txt @@ -39,4 +39,4 @@ if((NOT WIN32) AND BUILD_SHARED_LIBS AND NOT WASM_BUILD AND NOT CREATE_BUNDLE AN endif() endif() -install(TARGETS IfcConvert) +install(TARGETS IfcConvert EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}) diff --git a/src/ifcgeom/CMakeLists.txt b/src/ifcgeom/CMakeLists.txt index f2b66a6ab7..7729d51501 100644 --- a/src/ifcgeom/CMakeLists.txt +++ b/src/ifcgeom/CMakeLists.txt @@ -14,6 +14,10 @@ add_library(IfcGeom ${SCHEMA_AGNOSTIC_FILES}) set_target_properties(IfcGeom PROPERTIES OUTPUT_NAME "ifcopenshell.geometry" ) +target_include_directories(IfcGeom PUBLIC + $ + $ +) if((NOT WIN32) AND BUILD_SHARED_LIBS AND NOT WASM_BUILD AND NOT CREATE_BUNDLE AND NOT CMAKE_INSTALL_RPATH AND COMMAND SET_INSTALL_SELF_RPATH) SET_INSTALL_SELF_RPATH(IfcGeom) diff --git a/src/ifcgeom/Serialization/CMakeLists.txt b/src/ifcgeom/Serialization/CMakeLists.txt index d086578241..90317141e5 100644 --- a/src/ifcgeom/Serialization/CMakeLists.txt +++ b/src/ifcgeom/Serialization/CMakeLists.txt @@ -3,6 +3,13 @@ set(geometry_serialization_plugin_runtime_dir "${CMAKE_CURRENT_BINARY_DIR}/$ + $ +) +if((NOT WIN32) AND BUILD_SHARED_LIBS AND NOT WASM_BUILD AND NOT CREATE_BUNDLE AND NOT CMAKE_INSTALL_RPATH AND COMMAND SET_INSTALL_SELF_RPATH) + SET_INSTALL_SELF_RPATH(geometry_serializer) +endif() set_target_properties(geometry_serializer PROPERTIES OUTPUT_NAME "ifcopenshell.geometry.writer" COMPILE_FLAGS "-DIFC_GEOMSERIALIZATION_EXPORTS" @@ -18,6 +25,9 @@ install(FILES Serialization.h DESTINATION ${INCLUDEDIR}/ifcgeom/Serialization ) -install(TARGETS geometry_serializer ${geometry_serializer_libraries}) +install( + TARGETS geometry_serializer ${geometry_serializer_libraries} + EXPORT ${IFCOPENSHELL_EXPORT_TARGETS} +) set(geometry_serializer_libraries ${geometry_serializer_libraries} PARENT_SCOPE) diff --git a/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp b/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp index d4964d5758..81f6bfa82c 100644 --- a/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp +++ b/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp @@ -28,7 +28,7 @@ PLUGIN_API std::filesystem::path add_search_paths_or_default(manager& manager, s } namespace { - constexpr const char* opencascade_geometry_ifc_writer_plugin_prefix = "geometry.serialization."; + constexpr const char* opencascade_geometry_ifc_writer_plugin_prefix = "geometry.writer."; } const char* IfcGeom::opencascade_geometry_ifc_writer_plugin_registration_symbol() { diff --git a/src/ifcgeom/kernels/CMakeLists.txt b/src/ifcgeom/kernels/CMakeLists.txt index 9a8fa79f34..8b5f6d1b41 100644 --- a/src/ifcgeom/kernels/CMakeLists.txt +++ b/src/ifcgeom/kernels/CMakeLists.txt @@ -22,6 +22,9 @@ foreach(kernel ${GEOMETRY_KERNELS}) set(KERNEL_TARGET "geometry_kernel_${kernel}") add_library(${KERNEL_TARGET} SHARED ${IFCGEOM_FILES}) + if((NOT WIN32) AND NOT WASM_BUILD AND NOT CREATE_BUNDLE AND NOT CMAKE_INSTALL_RPATH AND COMMAND SET_INSTALL_SELF_RPATH) + SET_INSTALL_SELF_RPATH(${KERNEL_TARGET}) + endif() if(${kernel} STREQUAL "opencascade") ifcopenshell_wasm_plugin_link_options(${KERNEL_TARGET} ifcopenshell_register_kernel_plugin_v1 OPTIMIZATION -O0) @@ -45,6 +48,9 @@ foreach(kernel ${GEOMETRY_KERNELS}) set(KERNEL_TARGET_SIMPLE "${KERNEL_TARGET}_simple") add_library(${KERNEL_TARGET_SIMPLE} SHARED ${IFCGEOM_FILES}) + if((NOT WIN32) AND NOT CREATE_BUNDLE AND NOT CMAKE_INSTALL_RPATH AND COMMAND SET_INSTALL_SELF_RPATH) + SET_INSTALL_SELF_RPATH(${KERNEL_TARGET_SIMPLE}) + endif() ifcopenshell_wasm_plugin_link_options(${KERNEL_TARGET_SIMPLE} ifcopenshell_register_kernel_plugin_v1) @@ -74,6 +80,9 @@ foreach(kernel ${GEOMETRY_KERNELS}) ${kernel}/tree_${tree_backend}_plugin.cpp ${kernel}/tree_backends.h ) + if((NOT WIN32) AND NOT CREATE_BUNDLE AND NOT CMAKE_INSTALL_RPATH AND COMMAND SET_INSTALL_SELF_RPATH) + SET_INSTALL_SELF_RPATH(${TREE_TARGET}) + endif() set_target_properties(${TREE_TARGET} PROPERTIES COMPILE_FLAGS "-DIFC_GEOMLIBRARY_EXPORTS" OUTPUT_NAME "ifcopenshell.geometry.tree.opencascade.${tree_backend}" diff --git a/src/ifcgeom/mapping/CMakeLists.txt b/src/ifcgeom/mapping/CMakeLists.txt index aec66fd5d7..76d71f6c00 100644 --- a/src/ifcgeom/mapping/CMakeLists.txt +++ b/src/ifcgeom/mapping/CMakeLists.txt @@ -37,7 +37,7 @@ foreach(schema ${SCHEMA_VERSIONS}) list(APPEND mapping_libraries geometry_mapping_ifc${schema}) - install(TARGETS geometry_mapping_ifc${schema}) + install(TARGETS geometry_mapping_ifc${schema} EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}) endforeach() set(mapping_libraries ${mapping_libraries} PARENT_SCOPE) diff --git a/src/ifcparse/CMakeLists.txt b/src/ifcparse/CMakeLists.txt index 5c7031d65b..8cc5807512 100644 --- a/src/ifcparse/CMakeLists.txt +++ b/src/ifcparse/CMakeLists.txt @@ -18,13 +18,13 @@ list(REMOVE_ITEM IFCPARSE_CPP_FILES message(STATUS "SCHEMA_VERSIONS from ifcparse: ${SCHEMA_VERSIONS}") foreach(schema ${SCHEMA_VERSIONS}) - list(APPEND IFCPARSE_H_FILES + list(APPEND IFCPARSE_SCHEMA_H_FILES schemas/Ifc${schema}.h schemas/Ifc${schema}-definitions.h ) endforeach() -list(APPEND IFCPARSE_H_FILES +list(APPEND IFCPARSE_SCHEMA_H_FILES schemas/Header_section_schema.h ) list(APPEND IFCPARSE_CPP_FILES @@ -32,12 +32,16 @@ list(APPEND IFCPARSE_CPP_FILES schemas/Header_section_schema-schema.cpp ) -set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES}) +set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES} ${IFCPARSE_SCHEMA_H_FILES}) add_library(IfcParse ${IFCPARSE_FILES}) set_target_properties(IfcParse PROPERTIES OUTPUT_NAME "ifcopenshell.parse" ) +target_include_directories(IfcParse PUBLIC + $ + $ +) if((NOT WIN32) AND BUILD_SHARED_LIBS AND NOT WASM_BUILD AND NOT CREATE_BUNDLE AND NOT CMAKE_INSTALL_RPATH AND COMMAND SET_INSTALL_SELF_RPATH) SET_INSTALL_SELF_RPATH(IfcParse) @@ -107,6 +111,13 @@ install(FILES ${IFCPARSE_H_FILES} DESTINATION ${INCLUDEDIR}/ifcparse ) -install(TARGETS IfcParse ${schema_libraries}) +install(FILES ${IFCPARSE_SCHEMA_H_FILES} + DESTINATION ${INCLUDEDIR}/ifcparse/schemas +) + +install( + TARGETS IfcParse ${schema_libraries} + EXPORT ${IFCOPENSHELL_EXPORT_TARGETS} +) set(schema_libraries ${schema_libraries} PARENT_SCOPE) diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 0c21ebb853..0976e25fc1 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -5,6 +5,10 @@ add_library(plugin ${PLUGIN_CPP_FILES} ${PLUGIN_H_FILES}) set_target_properties(plugin PROPERTIES OUTPUT_NAME "ifcopenshell.plugin" COMPILE_FLAGS "-DPLUGIN_EXPORTS") +target_include_directories(plugin PUBLIC + $ + $ +) if (NOT CREATE_BUNDLE) set_target_properties(plugin PROPERTIES @@ -20,7 +24,7 @@ target_compile_definitions(plugin PRIVATE target_link_libraries(plugin PRIVATE ${Boost_LIBRARIES}) -install(TARGETS plugin) +install(TARGETS plugin EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}) install(FILES ${PLUGIN_H_FILES} DESTINATION ${INCLUDEDIR}/plugin diff --git a/src/plugin/plugin.cpp b/src/plugin/plugin.cpp index 52941dd9e1..215d2d93d4 100644 --- a/src/plugin/plugin.cpp +++ b/src/plugin/plugin.cpp @@ -153,9 +153,6 @@ namespace { namespace ifcopenshell { namespace plugin { -PLUGIN_API void set_search_paths(const std::vector& paths); -PLUGIN_API std::vector search_paths(); -PLUGIN_API void clear_search_paths(); PLUGIN_API std::filesystem::path add_search_paths_or_default(manager& manager, std::filesystem::path (*default_search_path)()); } } diff --git a/src/plugin/plugin.h b/src/plugin/plugin.h index 398af12514..10e99211ec 100644 --- a/src/plugin/plugin.h +++ b/src/plugin/plugin.h @@ -105,6 +105,9 @@ private: PLUGIN_API abi_info host_abi(); PLUGIN_API void validate_abi(const abi_info& abi); PLUGIN_API std::filesystem::path module_directory(const void* symbol); +PLUGIN_API void set_search_paths(const std::vector& paths); +PLUGIN_API std::vector search_paths(); +PLUGIN_API void clear_search_paths(); } }