Fix linking issues with EXPAT and the xmp static library (on windows)

v0.27.3
Luis Díaz Más 8 years ago committed by Luis Diaz Mas
parent 8f0a2721fc
commit 557d056add

@ -41,25 +41,33 @@ endforeach()
# We generate a CMake OBJECT LIBRARY (a bunch of object files) # We generate a CMake OBJECT LIBRARY (a bunch of object files)
add_library( xmp_object OBJECT ${XMPSRC} ) add_library( xmp_object OBJECT ${XMPSRC} )
target_include_directories(xmp_object PRIVATE ${EXPAT_INCLUDE_DIR}) target_include_directories(xmp_object
target_include_directories(xmp_object PRIVATE ${CMAKE_SOURCE_DIR}/xmpsdk/include) PRIVATE
${EXPAT_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/xmpsdk/include
)
check_include_file( "stdint.h" EXV_HAVE_STDINT_H ) check_include_file( "stdint.h" EXV_HAVE_STDINT_H )
if (EXV_HAVE_STDINT_H) if (EXV_HAVE_STDINT_H)
target_compile_definitions(xmp_object PUBLIC EXV_HAVE_STDINT_H) target_compile_definitions(xmp_object PUBLIC EXV_HAVE_STDINT_H)
endif() 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 ) if( EXIV2_ENABLE_LIBXMP )
add_library(xmp STATIC $<TARGET_OBJECTS:xmp_object>) add_library(xmp STATIC $<TARGET_OBJECTS:xmp_object>)
target_link_libraries(xmp PUBLIC ${EXPAT_LIBRARIES}) target_link_libraries(xmp PUBLIC ${EXPAT_LIBRARY})
target_include_directories(xmp PUBLIC ${EXPAT_INCLUDE_DIR})
target_include_directories(xmp PUBLIC ${CMAKE_SOURCE_DIR}/xmpsdk/include)
# http://stackoverflow.com/questions/10046114/in-cmake-how-can-i-test-if-the-compiler-is-clang # This is also needed for the xmp static library
if ( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang") target_include_directories(xmp PUBLIC ${EXPAT_INCLUDE_DIR})
# 1123 - hide xmpsdk symbols target_compile_definitions(xmp PUBLIC XML_STATIC)
target_compile_definitions(xmp PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden )
endif()
# 1119 Install libxmp.a for use by third party applications (Thanks, Emmanuel) # 1119 Install libxmp.a for use by third party applications (Thanks, Emmanuel)
install(TARGETS xmp install(TARGETS xmp

Loading…
Cancel
Save