From ea6fbc77dd8fab2188aa9c86ede7a0f7fc57f092 Mon Sep 17 00:00:00 2001 From: Johannes Obermayr Date: Tue, 14 Jun 2016 20:30:02 +0200 Subject: [PATCH 1/2] Bring back logic for BUILD_SHARED_LIBS. Also remove C++11 code. --- cmake/CMakeLists.txt | 12 ++++++++---- src/ifcparse/IfcParse.cpp | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 1d90a0a5bf..59dc4781ad 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -432,7 +432,11 @@ if(NOT WIN32) LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64) endif() -SET(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom) +if(BUILD_SHARED_LIBS) + SET(IFCOPENSHELL_LIBRARIES IfcGeom) +else() + SET(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom) +endif() # IfcParse file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h) @@ -448,7 +452,7 @@ endforeach() set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES}) -add_library(IfcParse ${IFCPARSE_FILES}) +add_library(IfcParse STATIC ${IFCPARSE_FILES}) set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIfcParse_EXPORTS) IF(UNICODE_SUPPORT) @@ -461,7 +465,7 @@ file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) IF(BUILD_SHARED_LIBS) message(WARNING "Building IfcGeom as shared library not currently supported") - add_library(IfcGeom STATIC ${IFCGEOM_FILES}) + add_library(IfcGeom SHARED ${IFCGEOM_FILES}) ELSE() add_library(IfcGeom ${IFCGEOM_FILES}) ENDIF() @@ -524,7 +528,7 @@ INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION ${INCLUDEDIR}/ifcgeom ) -INSTALL(TARGETS IfcParse IfcGeom IfcConvert IfcGeomServer +INSTALL(TARGETS ${IFCOPENSHELL_LIBRARIES} IfcConvert IfcGeomServer ARCHIVE DESTINATION ${LIBDIR} LIBRARY DESTINATION ${LIBDIR} RUNTIME DESTINATION ${BINDIR} diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index f720a09986..7698bb5dd6 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -559,9 +559,9 @@ double TokenFunc::asFloat(const Token& t) { const std::string &TokenFunc::asStringRef(const Token& t) { std::string &str = t.lexer->GetTempString(); t.lexer->TokenString(t.startPos, str); - if (isString(t) || isEnumeration(t) || isBinary(t)) { + if ((isString(t) || isEnumeration(t) || isBinary(t)) && !str.empty()) { //remove start+end characters in-place - str.pop_back(); + str.erase(str.end()-1); str.erase(str.begin()); } return str; From 478bda30bcf64dc97a85a2443be16dd12d632bc6 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 22 Jun 2016 14:54:55 +0200 Subject: [PATCH 2/2] Install both libraries. Force IfcGeom to static on Windows. Correct IfcParse linkage. Update IfcMax --- cmake/CMakeLists.txt | 16 ++++++++++------ src/ifcmax/CMakeLists.txt | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 59dc4781ad..205fb336e3 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -452,7 +452,7 @@ endforeach() set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES}) -add_library(IfcParse STATIC ${IFCPARSE_FILES}) +add_library(IfcParse ${IFCPARSE_FILES}) set_target_properties(IfcParse PROPERTIES COMPILE_FLAGS -DIfcParse_EXPORTS) IF(UNICODE_SUPPORT) @@ -463,13 +463,17 @@ ENDIF() file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h) file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) + IF(BUILD_SHARED_LIBS) - message(WARNING "Building IfcGeom as shared library not currently supported") - add_library(IfcGeom SHARED ${IFCGEOM_FILES}) -ELSE() - add_library(IfcGeom ${IFCGEOM_FILES}) + message(WARNING "Building IfcGeom as shared library currently not supported depending on platform and compiler options") ENDIF() +if(WIN32) + add_library(IfcGeom STATIC ${IFCGEOM_FILES}) +else() + add_library(IfcGeom ${IFCGEOM_FILES}) +endif() + TARGET_LINK_LIBRARIES(IfcGeom IfcParse) # IfcConvert @@ -528,7 +532,7 @@ INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION ${INCLUDEDIR}/ifcgeom ) -INSTALL(TARGETS ${IFCOPENSHELL_LIBRARIES} IfcConvert IfcGeomServer +INSTALL(TARGETS IfcParse IfcGeom IfcConvert IfcGeomServer ARCHIVE DESTINATION ${LIBDIR} LIBRARY DESTINATION ${LIBDIR} RUNTIME DESTINATION ${BINDIR} diff --git a/src/ifcmax/CMakeLists.txt b/src/ifcmax/CMakeLists.txt index 6dbff071a5..c9096f846f 100644 --- a/src/ifcmax/CMakeLists.txt +++ b/src/ifcmax/CMakeLists.txt @@ -28,7 +28,8 @@ LINK_DIRECTORIES(${LINK_DIRECTORIES} ${IfcOpenShell_BINARY_DIR} ${OCC_LIBRARY_DI ADD_LIBRARY(IfcMax SHARED IfcMax.h IfcMax.cpp) -TARGET_LINK_LIBRARIES(IfcMax ${IFCLIBS} Comctl32.lib zlibdll.lib bmm.lib core.lib CustDlg.lib edmodel.lib expr.lib +# TODO: find the minimal subset of 3dsmax libraries to reference +TARGET_LINK_LIBRARIES(IfcMax ${IFCOPENSHELL_LIBRARIES} Comctl32.lib zlibdll.lib bmm.lib core.lib CustDlg.lib edmodel.lib expr.lib flt.lib geom.lib gfx.lib gup.lib imageViewers.lib ManipSys.lib maxnet.lib Maxscrpt.lib maxutil.lib MenuMan.lib menus.lib mesh.lib MNMath.lib Paramblk2.lib particle.lib Poly.lib RenderUtil.lib tessint.lib viewfile.lib ${OPENCASCADE_LIBRARIES}