Skip to content

Commit

Permalink
Merge pull request #96 from gostefan/modernizeXercescLinking
Browse files Browse the repository at this point in the history
Allow findinging XercesC with CMake's FindXercesC.cmake.
  • Loading branch information
jklimke authored Sep 4, 2024
2 parents aab8481 + 396bda4 commit 7a7d210
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The project is based on the CMAKE build system and should be pretty straight for

Dependencies:

The XercesC xml parsing library is the only requirement compiling and using libcitygml. Please use a version > 3.1 compiled with an SDK that is compatible with C++11.
The XercesC xml parsing library is the only requirement compiling and using libcitygml. Please use a version > 3.1 compiled with an SDK that is compatible with C++11. If the library is not found by CMake use `-DCMAKE_SYSTEM_PREFIX_PATH=<XercesC install path>`.

OpenGL is required if you want to use the tesselator provided in the project. Otherwise, you can provide another implementation by inheriting TesselatorBase, or not use tesselation. Set the cmake option "LIBCITYGML_USE_OPENGL" to OFF to disable the use of OpenGL.

Expand Down
16 changes: 13 additions & 3 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ IF( LIBCITYGML_USE_OPENGL)
ELSE( LIBCITYGML_USE_OPENGL )
SET( GLU_INCLUDE_PATH "" )
ENDIF( LIBCITYGML_USE_OPENGL )
FIND_PACKAGE( Xerces REQUIRED )
FIND_PACKAGE( XercesC )
IF( NOT XercesC_FOUND )
FIND_PACKAGE( Xerces REQUIRED )
ENDIF( NOT XercesC_FOUND)

# gdal library
OPTION(LIBCITYGML_USE_GDAL "Set to ON to build libcitygml with GDAL library so that it supports coordinates transformations." ON)
Expand Down Expand Up @@ -50,9 +53,11 @@ configure_file("${CMAKE_MODULE_PATH}/citygml_api.h.in" ${CMAKE_CURRENT_SOURCE_DI
SET(EXPORT_HEADER_FILE_NAME ${CMAKE_CURRENT_SOURCE_DIR}/include/citygml/citygml_export.h)

INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include
${XERCESC_INCLUDE}
${GLU_INCLUDE_PATH}
${GDAL_INCLUDE_DIR})
IF ( NOT XercesC_FOUND )
INCLUDE_DIRECTORIES( ${XERCESC_INCLUDE})
ENDIF ( NOT XercesC_FOUND )

SET(SOURCES
src/citygml/attributesmap.cpp
Expand Down Expand Up @@ -225,7 +230,12 @@ generate_export_header(citygml
EXPORT_MACRO_NAME LIBCITYGML_EXPORT
EXPORT_FILE_NAME ${EXPORT_HEADER_FILE_NAME})

TARGET_LINK_LIBRARIES( ${target} PUBLIC ${XERCESC_LIBRARIES} )
if(XercesC_FOUND)
TARGET_LINK_LIBRARIES( ${target} PUBLIC XercesC::XercesC)
else(XercesC_FOUND)
TARGET_LINK_LIBRARIES( ${target} PUBLIC ${XERCESC_LIBRARIES} )
endif(XercesC_FOUND)

if(LIBCITYGML_USE_OPENGL)
TARGET_LINK_LIBRARIES( ${target} PUBLIC ${OPENGL_LIBRARIES} )
endif(LIBCITYGML_USE_OPENGL)
Expand Down
11 changes: 9 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ ENDIF()
IF( LIBCITYGML_USE_OPENGL)
FIND_PACKAGE( OpenGL REQUIRED )
ENDIF( LIBCITYGML_USE_OPENGL )
FIND_PACKAGE( Xerces REQUIRED )
FIND_PACKAGE( XercesC )
IF( NOT XercesC_FOUND )
FIND_PACKAGE( Xerces REQUIRED )
ENDIF( NOT XercesC_FOUND)

IF( LIBCITYGML_DYNAMIC )
ADD_DEFINITIONS( -DLIBCITYGML_DYNAMIC )
Expand All @@ -20,7 +23,11 @@ SET( PRG_SRCS citygmltest.cpp )

ADD_EXECUTABLE( citygmltest ${PRG_SRCS} )

TARGET_LINK_LIBRARIES( citygmltest citygml ${XERCESC_LIBRARY})
IF( XercesC_FOUND )
TARGET_LINK_LIBRARIES( citygmltest citygml XercesC::XercesC)
ELSE( XercesC_FOUND )
TARGET_LINK_LIBRARIES( citygmltest citygml ${XERCESC_LIBRARY} )
ENDIF( XercesC_FOUND )
IF(LIBCITYGML_USE_OPENGL)
TARGET_COMPILE_DEFINITIONS( citygmltest PUBLIC LIBCITYGML_USE_OPENGL)
TARGET_LINK_LIBRARIES( citygmltest citygml ${OPENGL_LIBRARIES} )
Expand Down

0 comments on commit 7a7d210

Please sign in to comment.