From 5d56025014b4412910ae16fbd5a0324b05818f02 Mon Sep 17 00:00:00 2001 From: Esteban DUGUEPEROUX Date: Sun, 9 Nov 2025 08:26:33 +0100 Subject: [PATCH] cmake: Separate ifcparse build in its own CMakeLists.txt file --- cmake/CMakeLists.txt | 60 ++--------------------------------- src/ifcparse/CMakeLists.txt | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 58 deletions(-) create mode 100644 src/ifcparse/CMakeLists.txt diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 149be34461..0deeb512fe 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -262,7 +262,7 @@ if(WITH_CGAL) else() set(CGAL_Boost_USE_STATIC_LIBS "${Boost_USE_STATIC_LIBS}") endif() - find_package(CGAL REQUIRED) + find_package(CGAL REQUIRED) if(NOT CGAL_DIR) message( FATAL_ERROR @@ -957,6 +957,7 @@ if(NOT Boost_VERSION LESS 105800) add_definitions(-DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE) endif() +add_subdirectory(../src/ifcparse ifcparse) set(IFCOPENSHELL_LIBRARIES IfcParse) if(BUILD_IFCGEOM) @@ -989,52 +990,6 @@ if(BUILD_CONVERT OR BUILD_IFCPYTHON) endif() endif() -# IfcParse -file(GLOB IFCPARSE_H_FILES_ALL ../src/ifcparse/*.h) -file(GLOB IFCPARSE_CPP_FILES_ALL ../src/ifcparse/*.cpp) - -foreach(file ${IFCPARSE_H_FILES_ALL}) - get_filename_component(filename "${file}" NAME) - - if(NOT "${filename}" MATCHES "[0-9]") - list(APPEND IFCPARSE_H_FILES "${file}") - endif() -endforeach() - -foreach(file ${IFCPARSE_CPP_FILES_ALL}) - get_filename_component(filename "${file}" NAME) - - if(NOT "${filename}" MATCHES "[0-9]") - list(APPEND IFCPARSE_CPP_FILES "${file}") - endif() -endforeach() - -foreach(schema ${SCHEMA_VERSIONS}) - list(APPEND IFCPARSE_H_FILES - ../src/ifcparse/Ifc${schema}.h - ../src/ifcparse/Ifc${schema}-definitions.h - ) - list(APPEND IFCPARSE_CPP_FILES - ../src/ifcparse/Ifc${schema}.cpp - ../src/ifcparse/Ifc${schema}-schema.cpp - ) -endforeach() - -set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES}) - -add_library(IfcParse ${IFCPARSE_FILES}) -target_link_libraries(IfcParse ${STDCPPFS}) -set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") - -if(LibXml2_DIR) - target_compile_definitions(IfcParse PRIVATE ${LIBXML2_DEFINITIONS}) -endif() -if(WASM_BUILD) - target_link_libraries(IfcParse ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES}) -else() - target_link_libraries(IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES}) -endif() - if(BUILD_IFCGEOM) # CGAL::CGAL target already has dependencies resolved. if(WITH_CGAL AND CGAL_DIR) @@ -1325,17 +1280,6 @@ if(BUILD_QTVIEWER) add_subdirectory(../src/qtviewer qtviewer) endif() -# CMake installation targets -install(FILES ${IFCPARSE_H_FILES} - DESTINATION ${INCLUDEDIR}/ifcparse -) - -install(TARGETS IfcParse - ARCHIVE DESTINATION ${LIBDIR} - LIBRARY DESTINATION ${LIBDIR} - RUNTIME DESTINATION ${BINDIR} -) - if(BUILD_IFCGEOM) # install(FILES ${IFCGEOM_H_FILES} # DESTINATION ${INCLUDEDIR}/ifcgeom diff --git a/src/ifcparse/CMakeLists.txt b/src/ifcparse/CMakeLists.txt new file mode 100644 index 0000000000..dd1f47eea6 --- /dev/null +++ b/src/ifcparse/CMakeLists.txt @@ -0,0 +1,62 @@ +file(GLOB IFCPARSE_H_FILES_ALL *.h) +file(GLOB IFCPARSE_CPP_FILES_ALL *.cpp) + +foreach(file ${IFCPARSE_H_FILES_ALL}) + get_filename_component(filename "${file}" NAME) + + if(NOT "${filename}" MATCHES "[0-9]") + list(APPEND IFCPARSE_H_FILES "${file}") + endif() +endforeach() + +foreach(file ${IFCPARSE_CPP_FILES_ALL}) + get_filename_component(filename "${file}" NAME) + + if(NOT "${filename}" MATCHES "[0-9]") + list(APPEND IFCPARSE_CPP_FILES "${file}") + endif() +endforeach() + +message(STATUS "SCHEMA_VERSIONS from ifcparse: ${SCHEMA_VERSIONS}") +foreach(schema ${SCHEMA_VERSIONS}) + list(APPEND IFCPARSE_H_FILES + Ifc${schema}.h + Ifc${schema}-definitions.h + ) + list(APPEND IFCPARSE_CPP_FILES + Ifc${schema}.cpp + Ifc${schema}-schema.cpp + ) +endforeach() + +set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES}) + +add_library(IfcParse ${IFCPARSE_FILES}) +set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") + +if(IFCXML_SUPPORT) + + if(LibXml2_DIR) + target_compile_definitions(IfcParse PRIVATE ${LIBXML2_DEFINITIONS}) + endif() + + add_definitions(-DWITH_IFCXML) + target_link_libraries(IfcParse LibXml2::LibXml2) +endif() + +if(WASM_BUILD) + target_link_libraries(IfcParse ${BCRYPT_LIBRARIES}) +else() + target_link_libraries(IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES}) +endif() + +# CMake installation targets +install(FILES ${IFCPARSE_H_FILES} + DESTINATION ${INCLUDEDIR}/ifcparse +) + +install(TARGETS IfcParse + ARCHIVE DESTINATION ${LIBDIR} + LIBRARY DESTINATION ${LIBDIR} + RUNTIME DESTINATION ${BINDIR} +)