Use alternative name for internal expat_config.h

Avoid clashes when system has expat installed.
This commit is contained in:
James Turner 2019-10-05 17:19:09 +01:00
parent b742607c76
commit ca97b4371b
6 changed files with 29 additions and 14 deletions

View File

@ -1,7 +1,7 @@
configure_file ( configure_file (
"${PROJECT_SOURCE_DIR}/3rdparty/expat/expat_config_cmake.in" "${PROJECT_SOURCE_DIR}/3rdparty/expat/expat_config_cmake.in"
"${PROJECT_BINARY_DIR}/3rdparty/expat/expat_config.h" "${PROJECT_BINARY_DIR}/3rdparty/expat/simgear_expat_config.h"
) )
set(expat_sources set(expat_sources

View File

@ -18,6 +18,8 @@
#include "amigaconfig.h" #include "amigaconfig.h"
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
#include "watcomconfig.h" #include "watcomconfig.h"
#elif defined(HAVE_SIMGEAR_EXPAT_CONFIG_H)
#include "simgear_expat_config.h"
#elif defined(HAVE_EXPAT_CONFIG_H) #elif defined(HAVE_EXPAT_CONFIG_H)
#include "expat_config.h" #include "expat_config.h"
#endif /* ndef COMPILED_FROM_DSP */ #endif /* ndef COMPILED_FROM_DSP */

View File

@ -12,6 +12,8 @@
#include "amigaconfig.h" #include "amigaconfig.h"
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
#include "watcomconfig.h" #include "watcomconfig.h"
#elif defined(HAVE_SIMGEAR_EXPAT_CONFIG_H)
#include "simgear_expat_config.h"
#else #else
#ifdef HAVE_EXPAT_CONFIG_H #ifdef HAVE_EXPAT_CONFIG_H
#include "expat_config.h" #include "expat_config.h"

View File

@ -12,6 +12,8 @@
#include "amigaconfig.h" #include "amigaconfig.h"
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
#include "watcomconfig.h" #include "watcomconfig.h"
#elif defined(HAVE_SIMGEAR_EXPAT_CONFIG_H)
#include "simgear_expat_config.h"
#else #else
#ifdef HAVE_EXPAT_CONFIG_H #ifdef HAVE_EXPAT_CONFIG_H
#include "expat_config.h" #include "expat_config.h"

View File

@ -273,9 +273,6 @@ if (SYSTEM_EXPAT)
else() else()
message(STATUS "Using built-in expat code") message(STATUS "Using built-in expat code")
# XML_STATIC is important to avoid sg_expat_external.h
# declaring symbols as declspec(import)
add_definitions(-DHAVE_EXPAT_CONFIG_H -DXML_STATIC)
set(EXPAT_INCLUDE_DIRS set(EXPAT_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/3rdparty/expat ${PROJECT_SOURCE_DIR}/3rdparty/expat
${PROJECT_BINARY_DIR}/3rdparty/expat) ${PROJECT_BINARY_DIR}/3rdparty/expat)

View File

@ -115,11 +115,22 @@ target_include_directories(SimGearCore BEFORE PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>) $<INSTALL_INTERFACE:include>)
# so simgear/simgear_config.h is found
target_include_directories(SimGearCore BEFORE PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
target_include_directories(SimGearCore PUBLIC target_include_directories(SimGearCore PUBLIC
${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
target_include_directories(SimGearCore PRIVATE target_include_directories(SimGearCore PRIVATE
${EXPAT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS}) ${EXPAT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
if (NOT SYSTEM_EXPAT)
# XML_STATIC is important to avoid sg_expat_external.h
# declaring symbols as declspec(import)
target_compile_definitions(SimGearCore PRIVATE HAVE_SIMGEAR_EXPAT_CONFIG_H XML_STATIC)
endif()
install(TARGETS SimGearCore install(TARGETS SimGearCore
EXPORT SimGearTargets EXPORT SimGearTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@ -144,9 +155,10 @@ if (NOT SIMGEAR_HEADLESS)
endif() endif()
endif() endif()
# we expose ZLib in some of our headers
target_link_libraries(SimGearCore PUBLIC ${ZLIB_LIBRARY})
target_link_libraries(SimGearCore target_link_libraries(SimGearCore PRIVATE
${ZLIB_LIBRARY}
${RT_LIBRARY} ${RT_LIBRARY}
${DL_LIBRARY} ${DL_LIBRARY}
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
@ -155,29 +167,29 @@ target_link_libraries(SimGearCore
${WINSOCK_LIBRARY}) ${WINSOCK_LIBRARY})
if(SYSTEM_EXPAT) if(SYSTEM_EXPAT)
target_link_libraries(SimGearCore target_link_libraries(SimGearCore PRIVATE ${EXPAT_LIBRARIES})
${EXPAT_LIBRARIES})
endif() endif()
if(ENABLE_DNS AND SYSTEM_UDNS) if(ENABLE_DNS AND SYSTEM_UDNS)
target_link_libraries(SimGearCore target_link_libraries(SimGearCore PRIVATE ${UDNS_LIBRARIES})
${UDNS_LIBRARIES})
endif() endif()
if(NOT SIMGEAR_HEADLESS) if(NOT SIMGEAR_HEADLESS)
target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include)
target_link_libraries(SimGearScene target_link_libraries(SimGearScene PUBLIC
SimGearCore SimGearCore
${ZLIB_LIBRARY}
${OPENSCENEGRAPH_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES}
)
target_link_libraries(SimGearScene PRIVATE
${ZLIB_LIBRARY}
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${JPEG_LIBRARY}) ${JPEG_LIBRARY})
if(ENABLE_GDAL) if(ENABLE_GDAL)
target_link_libraries(SimGearScene target_link_libraries(SimGearScene PRIVATE ${GDAL_LIBRARIES})
${GDAL_LIBRARIES})
endif() endif()
# only actually needed by canvas/KeyboardEvent.cxx # only actually needed by canvas/KeyboardEvent.cxx