@@ -453,14 +453,18 @@ function(files_for_ifc_version IFC_VERSION RESULT_NAME)
453453 )
454454endfunction ()
455455
456+ set (SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2" )
457+
456458if (COMPILE_SCHEMA)
459+ # @todo, this appears to be untested at the moment
460+
457461 find_package (PythonInterp )
458462
459463 IF (NOT PYTHONINTERP_FOUND)
460464 MESSAGE (FATAL_ERROR "A Python interpreter is necessary when COMPILE_SCHEMA is enabled. Disable COMPILE_SCHEMA or fix Python paths to proceed." )
461465 ENDIF ()
462466
463- set (IFC_RELEASE_NOT_USED "2x3" "4" )
467+ set (IFC_RELEASE_NOT_USED ${SCHEMA_VERSIONS} )
464468
465469 # Install pyparsing if necessary
466470 execute_process (COMMAND ${PYTHON_EXECUTABLE} -m pip freeze OUTPUT_VARIABLE PYTHON_PACKAGE_LIST )
@@ -501,13 +505,11 @@ if(COMPILE_SCHEMA)
501505 OUTPUT_VARIABLE COMPILED_SCHEMA_NAME )
502506
503507 # Prevent the schema that had just been compiled from being excluded
504- if ("${COMPILED_SCHEMA_NAME} " STREQUAL "IFC2X3" )
505- list (REMOVE_ITEM IFC_RELEASE_NOT_USED "2x3" )
506- add_definitions (-DUSE_IFC2x3 )
507- elseif ("${COMPILED_SCHEMA_NAME} " STREQUAL "IFC4" )
508- list (REMOVE_ITEM IFC_RELEASE_NOT_USED "4" )
509- add_definitions (-DUSE_IFC4 )
510- endif ()
508+ foreach (s ${SCHEMA_VERSIONS} )
509+ if ("${COMPILED_SCHEMA_NAME} " STREQUAL "${s} " )
510+ list (REMOVE_ITEM IFC_RELEASE_NOT_USED "${s} " )
511+ endif ()
512+ endforeach ()
511513endif ()
512514
513515# Boost >= 1.58 requires BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE to build on some Linux distros.
@@ -517,10 +519,16 @@ endif()
517519
518520set (IFCOPENSHELL_LIBRARIES IfcParse)
519521if (BUILD_IFCGEOM)
520- set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom)
522+ foreach (s ${SCHEMA_VERSIONS} )
523+ set (IFCGEOM_SCHEMA_LIBRARIES ${IFCGEOM_SCHEMA_LIBRARIES} IfcGeom_ifc${s} )
524+ endforeach ()
525+ set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} )
521526endif ()
522527if (BUILD_CONVERT)
523- set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} Serializers_ifc2x3 Serializers_ifc4 Serializers Serializers_ifc2x3 Serializers_ifc4 Serializers)
528+ foreach (s ${SCHEMA_VERSIONS} )
529+ set (SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} Serializers_ifc${s} )
530+ endforeach ()
531+ set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} Serializers ${SERIALIZER_SCHEMA_LIBRARIES} )
524532endif ()
525533
526534# IfcParse
@@ -540,15 +548,11 @@ file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h)
540548file (GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp )
541549set (IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES} )
542550
543- add_library (IfcGeom_ifc2x3 STATIC ${IFCGEOM_FILES} )
544- add_library (IfcGeom_ifc4 STATIC ${IFCGEOM_FILES} )
545-
546- set_target_properties (IfcGeom_ifc2x3 PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc2x3" )
547- # TODO: Detect based on IfcSchema
548- set_target_properties (IfcGeom_ifc4 PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc4 -DUSE_IFC4" )
549-
550- TARGET_LINK_LIBRARIES (IfcGeom_ifc2x3 IfcParse ${OPENCASCADE_LIBRARIES} )
551- TARGET_LINK_LIBRARIES (IfcGeom_ifc4 IfcParse ${OPENCASCADE_LIBRARIES} )
551+ foreach (s ${SCHEMA_VERSIONS} )
552+ add_library (IfcGeom_ifc${s} STATIC ${IFCGEOM_FILES} )
553+ set_target_properties (IfcGeom_ifc${s} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${s} " )
554+ TARGET_LINK_LIBRARIES (IfcGeom_ifc${s} IfcParse ${OPENCASCADE_LIBRARIES} )
555+ endforeach ()
552556
553557# IfcGeom (schema agnostic)
554558file (GLOB SCHEMA_AGNOSTIC_H_FILES ../src/ifcgeom_schema_agnostic/*.h )
@@ -557,7 +561,7 @@ set(SCHEMA_AGNOSTIC_FILES ${SCHEMA_AGNOSTIC_H_FILES} ${SCHEMA_AGNOSTIC_CPP_FILES
557561
558562add_library (IfcGeom ${SCHEMA_AGNOSTIC_FILES} )
559563set_target_properties (IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS )
560- TARGET_LINK_LIBRARIES (IfcGeom IfcGeom_ifc2x3 IfcGeom_ifc4 )
564+ TARGET_LINK_LIBRARIES (IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} )
561565
562566endif (BUILD_IFCGEOM )
563567
@@ -571,20 +575,16 @@ file(GLOB SERIALIZERS_S_H_FILES ../src/serializers/schema_dependent/*.h)
571575file (GLOB SERIALIZERS_S_CPP_FILES ../src/serializers/schema_dependent/*.cpp )
572576set (SERIALIZERS_S_FILES ${SERIALIZERS_S_H_FILES} ${SERIALIZERS_S_CPP_FILES} )
573577
574- add_library (Serializers_ifc2x3 STATIC ${SERIALIZERS_S_FILES} )
575- add_library (Serializers_ifc4 STATIC ${SERIALIZERS_S_FILES} )
576-
577- set_target_properties (Serializers_ifc2x3 PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc2x3 ${CONVERT_PRECISION} " )
578- # TODO: Detect based on IfcSchema
579- set_target_properties (Serializers_ifc4 PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc4 -DUSE_IFC4 ${CONVERT_PRECISION} " )
580-
581- TARGET_LINK_LIBRARIES (Serializers_ifc2x3 IfcGeom ${OPENCASCADE_LIBRARIES} )
582- TARGET_LINK_LIBRARIES (Serializers_ifc4 IfcGeom ${OPENCASCADE_LIBRARIES} )
578+ foreach (s ${SCHEMA_VERSIONS} )
579+ add_library (Serializers_ifc${s} STATIC ${SERIALIZERS_S_FILES} )
580+ set_target_properties (Serializers_ifc${s} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${s} ${CONVERT_PRECISION} " )
581+ TARGET_LINK_LIBRARIES (Serializers_ifc${s} IfcGeom ${OPENCASCADE_LIBRARIES} )
582+ endforeach ()
583583
584584add_library (Serializers ${SERIALIZERS_FILES} )
585585set_target_properties (Serializers PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS ${CONVERT_PRECISION} " )
586586
587- TARGET_LINK_LIBRARIES (Serializers Serializers_ifc2x3 Serializers_ifc4 )
587+ TARGET_LINK_LIBRARIES (Serializers ${SERIALIZER_SCHEMA_LIBRARIES} )
588588
589589# IfcConvert
590590file (GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp )
@@ -663,15 +663,15 @@ INSTALL(FILES ${SCHEMA_AGNOSTIC_H_FILES}
663663 DESTINATION ${INCLUDEDIR} /ifcgeom_schema_agnostic
664664)
665665
666- INSTALL (TARGETS IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom
666+ INSTALL (TARGETS ${IFCGEOM_SCHEMA_LIBRARIES} IfcGeom
667667 ARCHIVE DESTINATION ${LIBDIR}
668668 LIBRARY DESTINATION ${LIBDIR}
669669 RUNTIME DESTINATION ${BINDIR}
670670)
671671endif ()
672672
673673if (BUILD_CONVERT)
674- INSTALL (TARGETS Serializers Serializers_ifc2x3 Serializers_ifc4
674+ INSTALL (TARGETS Serializers ${SERIALIZER_SCHEMA_LIBRARIES}
675675 ARCHIVE DESTINATION ${LIBDIR}
676676 LIBRARY DESTINATION ${LIBDIR}
677677 RUNTIME DESTINATION ${BINDIR}
0 commit comments