From 557d056addc46c9ab19413c15481d8d39c900416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Sun, 27 Aug 2017 16:23:23 +0200 Subject: [PATCH] Fix linking issues with EXPAT and the xmp static library (on windows) --- xmpsdk/CMakeLists.txt | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt index 68a8eab3..e6e8dd3c 100644 --- a/xmpsdk/CMakeLists.txt +++ b/xmpsdk/CMakeLists.txt @@ -41,25 +41,33 @@ endforeach() # We generate a CMake OBJECT LIBRARY (a bunch of object files) add_library( xmp_object OBJECT ${XMPSRC} ) -target_include_directories(xmp_object PRIVATE ${EXPAT_INCLUDE_DIR}) -target_include_directories(xmp_object PRIVATE ${CMAKE_SOURCE_DIR}/xmpsdk/include) +target_include_directories(xmp_object + PRIVATE + ${EXPAT_INCLUDE_DIR} + ${CMAKE_SOURCE_DIR}/xmpsdk/include +) check_include_file( "stdint.h" EXV_HAVE_STDINT_H ) if (EXV_HAVE_STDINT_H) target_compile_definitions(xmp_object PUBLIC EXV_HAVE_STDINT_H) endif() +# TODO : We should only add this definition if EXPAT is static +target_compile_definitions(xmp_object PRIVATE XML_STATIC) + +# http://stackoverflow.com/questions/10046114/in-cmake-how-can-i-test-if-the-compiler-is-clang +if ( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang") + # 1123 - hide xmpsdk symbols + target_compile_definitions(xmp_object PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) +endif() + if( EXIV2_ENABLE_LIBXMP ) add_library(xmp STATIC $) - target_link_libraries(xmp PUBLIC ${EXPAT_LIBRARIES}) - target_include_directories(xmp PUBLIC ${EXPAT_INCLUDE_DIR}) - target_include_directories(xmp PUBLIC ${CMAKE_SOURCE_DIR}/xmpsdk/include) + target_link_libraries(xmp PUBLIC ${EXPAT_LIBRARY}) - # http://stackoverflow.com/questions/10046114/in-cmake-how-can-i-test-if-the-compiler-is-clang - if ( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang") - # 1123 - hide xmpsdk symbols - target_compile_definitions(xmp PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) - endif() + # This is also needed for the xmp static library + target_include_directories(xmp PUBLIC ${EXPAT_INCLUDE_DIR}) + target_compile_definitions(xmp PUBLIC XML_STATIC) # 1119 Install libxmp.a for use by third party applications (Thanks, Emmanuel) install(TARGETS xmp