Skip to content

Commit 2627052

Browse files
committed
cmake - export IfcOpenShellConfig.cmake
1 parent f5b1d76 commit 2627052

File tree

11 files changed

+72
-8
lines changed

11 files changed

+72
-8
lines changed

cmake/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ if(NOT IS_ABSOLUTE ${INCLUDEDIR})
170170
endif()
171171
message(STATUS "INCLUDEDIR: ${INCLUDEDIR}")
172172

173+
set(IFCOPENSHELL_EXPORT_TARGETS "${PROJECT_NAME}Targets")
174+
173175
if(BUILD_SHARED_LIBS)
174176
add_definitions(-DIFC_SHARED_BUILD)
175177
if(MSVC)
@@ -681,3 +683,5 @@ set(CPACK_DEBIAN_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
681683
# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/debian/postinst")
682684

683685
include(CPack)
686+
687+
include(package_export.cmake)

cmake/IfcOpenShellConfig.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/@CONFIG_TARGETS_FILENAME@")
4+
5+
check_required_components("@PROJECT_NAME@")

cmake/package_export.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
2+
set(CONFIG_NAMESPACE "${PROJECT_NAME}")
3+
set(CONFIG_TARGETS_FILENAME ${PROJECT_NAME}Targets.cmake)
4+
set(CONFIG_VERSION_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
5+
set(CONFIG_PACKAGE_INPUT "${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in")
6+
set(CONFIG_PACKAGE_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
7+
8+
# Allow linking against build directory.
9+
export(
10+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
11+
FILE ${CONFIG_TARGETS_FILENAME}
12+
NAMESPACE ${CONFIG_NAMESPACE}::
13+
)
14+
15+
install(
16+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
17+
NAMESPACE ${CONFIG_NAMESPACE}::
18+
DESTINATION "${CONFIG_PACKAGE_LOCATION}"
19+
)
20+
21+
22+
include(CMakePackageConfigHelpers)
23+
write_basic_package_version_file(${CONFIG_VERSION_OUTPUT}
24+
COMPATIBILITY ExactVersion)
25+
26+
configure_package_config_file(${CONFIG_PACKAGE_INPUT}
27+
${CONFIG_PACKAGE_OUTPUT}
28+
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
29+
)
30+
31+
install(FILES
32+
"${CONFIG_PACKAGE_OUTPUT}"
33+
"${CONFIG_VERSION_OUTPUT}"
34+
DESTINATION ${CONFIG_PACKAGE_LOCATION}
35+
)

src/ifcconvert/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ target_link_libraries(IfcConvert
1616
${CGAL_LIBRARIES} ${GLTF_LIBRARIES}
1717
)
1818

19-
install(TARGETS IfcConvert)
19+
install(TARGETS IfcConvert
20+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
21+
)

src/ifcgeom/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ if(NOT WASM_BUILD)
3131
target_link_libraries(IfcGeom IfcParse)
3232
endif()
3333

34-
install(TARGETS IfcGeom)
35-
34+
install(TARGETS IfcGeom
35+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
36+
)
3637
install(FILES ${SCHEMA_AGNOSTIC_H_FILES}
3738
DESTINATION ${INCLUDEDIR}/ifcgeom
38-
)
39+
)

src/ifcgeom/Serialization/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ install(FILES ${IFCGEOM_SERIALIZATION_H_FILE}
1111
DESTINATION ${INCLUDEDIR}/ifcgeom/Serialization
1212
)
1313

14-
install(TARGETS geometry_serializer ${geometry_serializer_libraries})
14+
install(TARGETS geometry_serializer ${geometry_serializer_libraries}
15+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
16+
)
1517

1618
set(geometry_serializer_libraries ${geometry_serializer_libraries} PARENT_SCOPE)

src/ifcgeom/kernels/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ foreach(kernel ${GEOMETRY_KERNELS})
1212
set_property(TARGET ${KERNEL_TARGET} APPEND PROPERTY COMPILE_FLAGS "-DIFC_GEOM_EXPORTS")
1313
list(APPEND kernel_libraries ${KERNEL_TARGET})
1414
target_link_libraries(${KERNEL_TARGET} ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
15+
install(TARGETS ${KERNEL_TARGET}
16+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
17+
)
1518

1619
if(${kernel} STREQUAL "cgal")
1720
find_package(CGAL REQUIRED)
@@ -24,6 +27,9 @@ foreach(kernel ${GEOMETRY_KERNELS})
2427
list(APPEND kernel_libraries ${KERNEL_TARGET_SIMPLE})
2528
target_link_libraries(${KERNEL_TARGET_SIMPLE} ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
2629
target_link_libraries(${KERNEL_TARGET_SIMPLE} CGAL::CGAL_INTERFACE)
30+
install(TARGETS ${KERNEL_TARGET_SIMPLE}
31+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
32+
)
2733
elseif(${kernel} STREQUAL "opencascade")
2834
target_link_libraries(${KERNEL_TARGET} ${OpenCASCADE_LIBRARIES})
2935
endif()

src/ifcgeom/mapping/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ foreach(schema ${SCHEMA_VERSIONS})
1111
target_link_libraries(geometry_mapping_ifc${schema} IfcParse Eigen3::Eigen)
1212

1313
list(APPEND mapping_libraries geometry_mapping_ifc${schema})
14+
install(TARGETS geometry_mapping_ifc${schema}
15+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
16+
)
1417
endforeach()
1518

1619
set(mapping_libraries ${mapping_libraries} PARENT_SCOPE)

src/ifcgeomserver/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ set(SOURCE_FILES ${CPP_FILES})
55
add_executable(IfcGeomServer ${SOURCE_FILES})
66
target_link_libraries(IfcGeomServer IfcGeom ${kernel_libraries} ${OpenCASCADE_LIBRARIES})
77

8-
install(TARGETS IfcGeomServer)
8+
install(TARGETS IfcGeomServer
9+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
10+
)

src/ifcparse/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@ install(FILES ${IFCPARSE_H_FILES}
5353
DESTINATION ${INCLUDEDIR}/ifcparse
5454
)
5555

56-
install(TARGETS IfcParse)
56+
install(TARGETS IfcParse
57+
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
58+
)

0 commit comments

Comments
 (0)