From ca97b4371b83fba90eac3872e42d2f0e3d37a789 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 5 Oct 2019 17:19:09 +0100 Subject: [PATCH] Use alternative name for internal expat_config.h Avoid clashes when system has expat installed. --- 3rdparty/expat/CMakeLists.txt | 2 +- 3rdparty/expat/xmlparse.c | 2 ++ 3rdparty/expat/xmlrole.c | 2 ++ 3rdparty/expat/xmltok.c | 2 ++ CMakeLists.txt | 3 --- simgear/CMakeLists.txt | 32 ++++++++++++++++++++++---------- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/3rdparty/expat/CMakeLists.txt b/3rdparty/expat/CMakeLists.txt index 550a52c9..badfd61c 100644 --- a/3rdparty/expat/CMakeLists.txt +++ b/3rdparty/expat/CMakeLists.txt @@ -1,7 +1,7 @@ configure_file ( "${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 diff --git a/3rdparty/expat/xmlparse.c b/3rdparty/expat/xmlparse.c index e4fb313f..83ab782d 100644 --- a/3rdparty/expat/xmlparse.c +++ b/3rdparty/expat/xmlparse.c @@ -18,6 +18,8 @@ #include "amigaconfig.h" #elif defined(__WATCOMC__) #include "watcomconfig.h" +#elif defined(HAVE_SIMGEAR_EXPAT_CONFIG_H) +#include "simgear_expat_config.h" #elif defined(HAVE_EXPAT_CONFIG_H) #include "expat_config.h" #endif /* ndef COMPILED_FROM_DSP */ diff --git a/3rdparty/expat/xmlrole.c b/3rdparty/expat/xmlrole.c index 0bb159f5..84ce13dd 100644 --- a/3rdparty/expat/xmlrole.c +++ b/3rdparty/expat/xmlrole.c @@ -12,6 +12,8 @@ #include "amigaconfig.h" #elif defined(__WATCOMC__) #include "watcomconfig.h" +#elif defined(HAVE_SIMGEAR_EXPAT_CONFIG_H) +#include "simgear_expat_config.h" #else #ifdef HAVE_EXPAT_CONFIG_H #include "expat_config.h" diff --git a/3rdparty/expat/xmltok.c b/3rdparty/expat/xmltok.c index 5a8bd132..674d8cc5 100644 --- a/3rdparty/expat/xmltok.c +++ b/3rdparty/expat/xmltok.c @@ -12,6 +12,8 @@ #include "amigaconfig.h" #elif defined(__WATCOMC__) #include "watcomconfig.h" +#elif defined(HAVE_SIMGEAR_EXPAT_CONFIG_H) +#include "simgear_expat_config.h" #else #ifdef HAVE_EXPAT_CONFIG_H #include "expat_config.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7710db08..705b610d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,9 +273,6 @@ if (SYSTEM_EXPAT) else() 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 ${PROJECT_SOURCE_DIR}/3rdparty/expat ${PROJECT_BINARY_DIR}/3rdparty/expat) diff --git a/simgear/CMakeLists.txt b/simgear/CMakeLists.txt index ca26c9d2..7646ac09 100644 --- a/simgear/CMakeLists.txt +++ b/simgear/CMakeLists.txt @@ -115,11 +115,22 @@ target_include_directories(SimGearCore BEFORE PUBLIC $ $) +# so simgear/simgear_config.h is found +target_include_directories(SimGearCore BEFORE PUBLIC + $ + $) + target_include_directories(SimGearCore PUBLIC ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) target_include_directories(SimGearCore PRIVATE ${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 EXPORT SimGearTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -144,9 +155,10 @@ if (NOT SIMGEAR_HEADLESS) endif() endif() +# we expose ZLib in some of our headers +target_link_libraries(SimGearCore PUBLIC ${ZLIB_LIBRARY}) -target_link_libraries(SimGearCore - ${ZLIB_LIBRARY} +target_link_libraries(SimGearCore PRIVATE ${RT_LIBRARY} ${DL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} @@ -155,29 +167,29 @@ target_link_libraries(SimGearCore ${WINSOCK_LIBRARY}) if(SYSTEM_EXPAT) - target_link_libraries(SimGearCore - ${EXPAT_LIBRARIES}) + target_link_libraries(SimGearCore PRIVATE ${EXPAT_LIBRARIES}) endif() if(ENABLE_DNS AND SYSTEM_UDNS) - target_link_libraries(SimGearCore - ${UDNS_LIBRARIES}) + target_link_libraries(SimGearCore PRIVATE ${UDNS_LIBRARIES}) endif() if(NOT SIMGEAR_HEADLESS) target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) - target_link_libraries(SimGearScene + target_link_libraries(SimGearScene PUBLIC SimGearCore - ${ZLIB_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} + ) + + target_link_libraries(SimGearScene PRIVATE + ${ZLIB_LIBRARY} ${OPENAL_LIBRARY} ${OPENGL_LIBRARY} ${JPEG_LIBRARY}) if(ENABLE_GDAL) - target_link_libraries(SimGearScene - ${GDAL_LIBRARIES}) + target_link_libraries(SimGearScene PRIVATE ${GDAL_LIBRARIES}) endif() # only actually needed by canvas/KeyboardEvent.cxx