Skip to content

Commit 1876a78

Browse files
EstebanDugueperoux2aothms
authored andcommitted
cmake: Externalize cmake config for Serializers
1 parent 9d28628 commit 1876a78

3 files changed

Lines changed: 52 additions & 55 deletions

File tree

cmake/CMakeLists.txt

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -963,12 +963,7 @@ if(BUILD_IFCGEOM)
963963
endif()
964964

965965
if(BUILD_CONVERT OR BUILD_IFCPYTHON)
966-
foreach(schema ${SCHEMA_VERSIONS})
967-
set(SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} Serializers_ifc${schema})
968-
endforeach()
969-
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} Serializers ${SERIALIZER_SCHEMA_LIBRARIES})
970-
971-
if(WITH_OPENCASCADE)
966+
if(WITH_OPENCASCADE)
972967
foreach(schema ${SCHEMA_VERSIONS})
973968
set(GEOM_SERIALIZER_SCHEMA_LIBRARIES ${GEOM_SERIALIZER_SCHEMA_LIBRARIES} GeometrySerializers_ifc${schema})
974969

@@ -1041,39 +1036,8 @@ if(BUILD_IFCGEOM)
10411036
endif(BUILD_IFCGEOM)
10421037

10431038
if(BUILD_CONVERT OR BUILD_IFCPYTHON)
1044-
# Serializers
1045-
file(GLOB SERIALIZERS_H_FILES ../src/serializers/*.h)
1046-
file(GLOB SERIALIZERS_CPP_FILES ../src/serializers/*.cpp)
1047-
set(SERIALIZERS_FILES ${SERIALIZERS_H_FILES} ${SERIALIZERS_CPP_FILES})
1048-
file(GLOB SERIALIZERS_S_H_FILES ../src/serializers/schema_dependent/*.h)
1049-
file(GLOB SERIALIZERS_S_CPP_FILES ../src/serializers/schema_dependent/*.cpp)
1050-
set(SERIALIZERS_S_FILES ${SERIALIZERS_S_H_FILES} ${SERIALIZERS_S_CPP_FILES})
1051-
1052-
foreach(schema ${SCHEMA_VERSIONS})
1053-
add_library(Serializers_ifc${schema} STATIC ${SERIALIZERS_S_FILES})
1054-
set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORTS -DIfcSchema=Ifc${schema}")
1055-
1056-
if(WASM_BUILD)
1057-
target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES})
1058-
else()
1059-
target_link_libraries(Serializers_ifc${schema} IfcGeom ${OPENCASCADE_LIBRARIES} ${HDF5_LIBRARIES})
1060-
endif()
1061-
endforeach()
1062-
1063-
add_library(Serializers ${SERIALIZERS_FILES})
1064-
set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORTS" VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
1065-
1066-
if(WITH_PROJ)
1067-
target_compile_definitions(Serializers PRIVATE "WITH_PROJ")
1068-
if (PROJ_STATIC)
1069-
target_compile_definitions(Serializers PRIVATE "PROJ_DLL=")
1070-
endif()
1071-
target_include_directories(Serializers PRIVATE ${PROJ_INCLUDE_DIR} ${SQLITE_INCLUDE_DIR})
1072-
target_link_libraries(Serializers ${PROJ_LIBRARIES})
1073-
endif()
1074-
1075-
target_link_libraries(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES} IfcGeom ${OPENCASCADE_LIBRARIES} ${kernel_libraries} IfcParse)
1076-
1039+
add_subdirectory(../src/serializers serializers)
1040+
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} ${SERIALIZER_SCHEMA_LIBRARIES})
10771041
endif(BUILD_CONVERT OR BUILD_IFCPYTHON)
10781042

10791043
if(BUILD_CONVERT)
@@ -1224,22 +1188,6 @@ if(BUILD_IFCGEOM)
12241188
)
12251189
endif(BUILD_IFCGEOM)
12261190

1227-
if(BUILD_CONVERT)
1228-
install(TARGETS Serializers ${SERIALIZER_SCHEMA_LIBRARIES}
1229-
ARCHIVE DESTINATION ${LIBDIR}
1230-
LIBRARY DESTINATION ${LIBDIR}
1231-
RUNTIME DESTINATION ${BINDIR}
1232-
)
1233-
1234-
install(FILES ${SERIALIZERS_H_FILES}
1235-
DESTINATION ${INCLUDEDIR}/serializers/
1236-
)
1237-
1238-
install(FILES ${SERIALIZERS_S_H_FILES}
1239-
DESTINATION ${INCLUDEDIR}/serializers/schema_dependent
1240-
)
1241-
endif(BUILD_CONVERT)
1242-
12431191
if(BUILD_CONVERT OR BUILD_IFCPYTHON)
12441192
if(WITH_OPENCASCADE)
12451193
install(TARGETS geometry_serializer ${geometry_serializer_libraries}

src/serializers/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
add_subdirectory(schema_dependent)
2+
3+
file(GLOB SERIALIZERS_H_FILES *.h)
4+
file(GLOB SERIALIZERS_CPP_FILES *.cpp)
5+
set(SERIALIZERS_FILES ${SERIALIZERS_H_FILES} ${SERIALIZERS_CPP_FILES})
6+
7+
add_library(Serializers ${SERIALIZERS_FILES})
8+
set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORTS" VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
9+
set(SERIALIZER_SCHEMA_LIBRARIES Serializers ${SERIALIZER_SCHEMA_LIBRARIES} PARENT_SCOPE)
10+
11+
if(WITH_PROJ)
12+
find_package(proj REQUIRED)
13+
target_compile_definitions(Serializers PRIVATE "WITH_PROJ")
14+
if(PROJ_STATIC)
15+
target_compile_definitions(Serializers PRIVATE "PROJ_DLL=")
16+
endif()
17+
target_link_libraries(Serializers PRIVATE proj::proj)
18+
endif()
19+
20+
target_link_libraries(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES} IfcGeom ${OPENCASCADE_LIBRARIES} ${kernel_libraries} IfcParse)
21+
22+
install(TARGETS Serializers)
23+
24+
install(FILES ${SERIALIZERS_H_FILES}
25+
DESTINATION ${INCLUDEDIR}/serializers/
26+
)
27+
28+
install(FILES ${SERIALIZERS_S_H_FILES}
29+
DESTINATION ${INCLUDEDIR}/serializers/schema_dependent
30+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
file(GLOB SERIALIZERS_S_H_FILES *.h)
2+
file(GLOB SERIALIZERS_S_CPP_FILES *.cpp)
3+
set(SERIALIZERS_S_FILES ${SERIALIZERS_S_H_FILES} ${SERIALIZERS_S_CPP_FILES})
4+
5+
foreach(schema ${SCHEMA_VERSIONS})
6+
add_library(Serializers_ifc${schema} STATIC ${SERIALIZERS_S_FILES})
7+
set(SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} Serializers_ifc${schema})
8+
set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}")
9+
if(WASM_BUILD)
10+
target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES})
11+
else()
12+
target_link_libraries(Serializers_ifc${schema} IfcGeom ${OPENCASCADE_LIBRARIES} ${HDF5_LIBRARIES})
13+
endif()
14+
15+
install(TARGETS Serializers_ifc${schema})
16+
endforeach()
17+
18+
19+
set(SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} PARENT_SCOPE)

0 commit comments

Comments
 (0)