cmake export - propagate IFOPSH_WITH_ROCKSDB to cmake config

Apparently, cmake isn't exporting definitions defined globally `add_definitions`, so creating interface target to combine rocksdb and our definitions.
This commit is contained in:
Andrej730
2025-12-12 17:35:11 +05:00
parent 8f44f60546
commit d303acd660
3 changed files with 13 additions and 6 deletions
+9 -3
View File
@@ -230,6 +230,7 @@ if(USD_SUPPORT)
set(USD_LIBRARIES pxr::USD) set(USD_LIBRARIES pxr::USD)
endif(USD_SUPPORT) endif(USD_SUPPORT)
set(ROCKSDB_LIBRARIES "")
if (WITH_ROCKSDB) if (WITH_ROCKSDB)
# Temporaily mess with CMAKE_FIND_PACKAGE_PREFER_CONFIG to help RocksDB # Temporaily mess with CMAKE_FIND_PACKAGE_PREFER_CONFIG to help RocksDB
# find it's zstd dependency on Windows. # find it's zstd dependency on Windows.
@@ -246,9 +247,11 @@ if (WITH_ROCKSDB)
endif() endif()
message(STATUS "RocksDB: found at '${RocksDB_DIR}'.") message(STATUS "RocksDB: found at '${RocksDB_DIR}'.")
add_definitions(-DIFOPSH_WITH_ROCKSDB) add_library(IFCOPENSHELL_RocksDB INTERFACE)
set(ROCKSDB_LIBRARIES "IFCOPENSHELL_RocksDB")
target_compile_definitions(IFCOPENSHELL_RocksDB INTERFACE IFOPSH_WITH_ROCKSDB)
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB)
link_libraries($<IF:$<TARGET_EXISTS:RocksDB::rocksdb-shared>,RocksDB::rocksdb-shared,RocksDB::rocksdb>) target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE $<IF:$<TARGET_EXISTS:RocksDB::rocksdb-shared>,RocksDB::rocksdb-shared,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
@@ -257,8 +260,11 @@ if (WITH_ROCKSDB)
find_package(zstd CONFIG REQUIRED) find_package(zstd CONFIG REQUIRED)
mark_as_advanced(zstd_DIR) mark_as_advanced(zstd_DIR)
message(STATUS "zstd: found at '${zstd_DIR}'.") message(STATUS "zstd: found at '${zstd_DIR}'.")
link_libraries(zstd::libzstd_static) target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE zstd::libzstd_static)
endif() endif()
install(TARGETS IFCOPENSHELL_RocksDB
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS})
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
+3 -3
View File
@@ -47,7 +47,7 @@ if(STANDALONE_PROJECT OR SCHEMA_VERSIONS MATCHES "2x3")
target_link_libraries(IfcParseExamples ${Boost_LIBRARIES}) target_link_libraries(IfcParseExamples ${Boost_LIBRARIES})
target_link_libraries(IfcParseExamples IfcOpenShell::IfcParse) target_link_libraries(IfcParseExamples IfcOpenShell::IfcParse)
target_compile_features(IfcParseExamples PRIVATE cxx_std_17) target_compile_features(IfcParseExamples PRIVATE cxx_std_17)
target_compile_definitions(IfcParseExamples PRIVATE "SCHEMA_SEQ=(2x3)" HAS_SCHEMA_2x3 IFOPSH_WITH_ROCKSDB) target_compile_definitions(IfcParseExamples PRIVATE "SCHEMA_SEQ=(2x3)" HAS_SCHEMA_2x3)
else() else()
target_include_directories(IfcParseExamples PRIVATE "${CMAKE_SOURCE_DIR}/../src") target_include_directories(IfcParseExamples PRIVATE "${CMAKE_SOURCE_DIR}/../src")
target_link_libraries(IfcParseExamples IfcParse) target_link_libraries(IfcParseExamples IfcParse)
@@ -73,7 +73,7 @@ if(STANDALONE_PROJECT OR SCHEMA_VERSIONS MATCHES "2x3")
INTERFACE ${OpenCASCADE_LIBRARIES} RocksDB::rocksdb INTERFACE ${OpenCASCADE_LIBRARIES} RocksDB::rocksdb
IfcOpenShell::IfcParse IfcOpenShell::geometry_serializer IfcOpenShell::IfcParse IfcOpenShell::geometry_serializer
) )
target_compile_definitions(IfcHouseInterface INTERFACE "SCHEMA_SEQ=(2x3)" HAS_SCHEMA_2x3 IFOPSH_WITH_ROCKSDB) target_compile_definitions(IfcHouseInterface INTERFACE "SCHEMA_SEQ=(2x3)" HAS_SCHEMA_2x3)
else() else()
target_include_directories(IfcHouseInterface INTERFACE "${CMAKE_SOURCE_DIR}/../src") target_include_directories(IfcHouseInterface INTERFACE "${CMAKE_SOURCE_DIR}/../src")
target_link_libraries(IfcHouseInterface INTERFACE ${IFCOPENSHELL_LIBRARIES} ${OpenCASCADE_LIBRARIES}) target_link_libraries(IfcHouseInterface INTERFACE ${IFCOPENSHELL_LIBRARIES} ${OpenCASCADE_LIBRARIES})
@@ -93,7 +93,7 @@ if(STANDALONE_PROJECT OR SCHEMA_VERSIONS MATCHES "4x3_add2")
if(STANDALONE_PROJECT) if(STANDALONE_PROJECT)
target_include_directories(IfcAlignmentInterface INTERFACE ${Boost_INCLUDE_DIRS}) target_include_directories(IfcAlignmentInterface INTERFACE ${Boost_INCLUDE_DIRS})
target_compile_definitions(IfcAlignmentInterface INTERFACE HAS_SCHEMA_4x3_add2 IFOPSH_WITH_ROCKSDB) target_compile_definitions(IfcAlignmentInterface INTERFACE HAS_SCHEMA_4x3_add2)
target_link_libraries(IfcAlignment PRIVATE IfcOpenShell::IfcParse) target_link_libraries(IfcAlignment PRIVATE IfcOpenShell::IfcParse)
target_link_libraries(IfcSimplifiedAlignment PRIVATE IfcOpenShell::IfcParse) target_link_libraries(IfcSimplifiedAlignment PRIVATE IfcOpenShell::IfcParse)
else() else()
+1
View File
@@ -54,6 +54,7 @@ else()
target_link_libraries(IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES}) target_link_libraries(IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES})
endif() endif()
target_link_libraries(IfcParse ${ROCKSDB_LIBRARIES})
install(TARGETS IfcParse install(TARGETS IfcParse
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS} EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}