From 7adaf71d44ff63203ec926d9113afacfc27f5559 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sun, 5 Jun 2016 06:15:30 +0000 Subject: [PATCH] #1187 and #1041. Fixing CMake/Linux build breakers concerning libpthread --- CMakeLists.txt | 4 +++- samples/CMakeLists.txt | 8 ++++---- src/CMakeLists.txt | 5 ++++- xmpsdk/CMakeLists.txt | 6 +++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1325532..747c4ac0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ if( EXISTS "${CMAKE_SOURCE_DIR}/include/exiv2/exv_conf.h" ) endif() ## -CMAKE_MINIMUM_REQUIRED( VERSION 2.8.11 ) +CMAKE_MINIMUM_REQUIRED( VERSION 3.1.0 ) PROJECT( exiv2 ) if( POLICY CMP0042 ) @@ -99,6 +99,8 @@ endif( MSVC ) IF( EXIV2_ENABLE_XMP ) SET( HAVE_XMP_TOOLKIT ON ) SET( XMPLIB "do" ) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) ENDIF( EXIV2_ENABLE_XMP ) INCLUDE( config/CMakeChecks.txt ) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 211fe9b5..1add0951 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -49,7 +49,7 @@ FOREACH(entry ${SAMPLES}) STRING( REPLACE ".cpp" "" target ${entry}) ADD_EXECUTABLE( ${target} ${target}.cpp ) ADD_TEST( ${target}_test ${target} ) - TARGET_LINK_LIBRARIES( ${target} ${PRIVATE_VAR} exiv2lib ${EXPAT_LIBRARIES}) + TARGET_LINK_LIBRARIES( ${target} ${PRIVATE_VAR} exiv2lib Threads::Threads ${EXPAT_LIBRARIES}) INSTALL( TARGETS ${target} ${INSTALL_TARGET_STANDARD_ARGS} ) ENDFOREACH(entry ${SAMPLES}) @@ -62,19 +62,19 @@ ENDIF( MSVC ) SET( MC_SRC ${MC_SRC} metacopy.cpp ../src/utils.cpp ) ADD_EXECUTABLE( metacopy ${MC_SRC} ) -TARGET_LINK_LIBRARIES( metacopy exiv2lib ) +TARGET_LINK_LIBRARIES( metacopy exiv2lib Threads::Threads) INSTALL( TARGETS metacopy ${INSTALL_TARGET_STANDARD_ARGS} ) SET( PATHTEST_SRC ${PATHTEST_SRC} path-test.cpp ../src/utils.cpp ) ADD_EXECUTABLE( pathtest ${PATHTEST_SRC} ) SET_TARGET_PROPERTIES( pathtest PROPERTIES OUTPUT_NAME path-test ) -TARGET_LINK_LIBRARIES( pathtest exiv2lib ) +TARGET_LINK_LIBRARIES( pathtest exiv2lib Threads::Threads ) INSTALL( TARGETS pathtest ${INSTALL_TARGET_STANDARD_ARGS} ) SET( EXIV2JSON_SRC exiv2json.cpp Jzon.cpp ) ADD_EXECUTABLE( exiv2json ${EXIV2JSON_SRC} ) SET_TARGET_PROPERTIES( exiv2json PROPERTIES OUTPUT_NAME exiv2json ) -TARGET_LINK_LIBRARIES( exiv2json exiv2lib ) +TARGET_LINK_LIBRARIES( exiv2json exiv2lib Threads::Threads) INSTALL( TARGETS exiv2json ${INSTALL_TARGET_STANDARD_ARGS} ) # ****************************************************************************** diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 976abee7..2f646375 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -249,7 +249,7 @@ else() TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} dl ${EXPAT_LIBRARIES} ) TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} dl ${CURL_LIBRARIES} ) TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} dl ${SSH_LIBRARIES} ) - else() + else() TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} ${EXPAT_LIBRARIES} ) TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} ${CURL_LIBRARIES} ) TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} ${SSH_LIBRARIES} ) @@ -260,6 +260,9 @@ if( EXIV2_ENABLE_LIBXMP ) ADD_DEPENDENCIES( exiv2lib xmp ) if ( MSVC ) LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH}/$(ConfigurationName)) + else() + ADD_DEPENDENCIES( exiv2lib xmp Threads::Threads) + TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} ${EXPAT_LIBRARIES} Threads::Threads) endif(MSVC) TARGET_LINK_LIBRARIES( exiv2lib ${PRIVATE_VAR} xmp ) ENDIF() diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt index cf03a4e2..8fe4a485 100644 --- a/xmpsdk/CMakeLists.txt +++ b/xmpsdk/CMakeLists.txt @@ -31,7 +31,11 @@ endif() IF( EXIV2_ENABLE_XMP AND EXIV2_ENABLE_LIBXMP ) ADD_LIBRARY( xmp STATIC ${XMPSRC} ) GET_TARGET_PROPERTY( XMPLIB xmp LOCATION ) - TARGET_LINK_LIBRARIES(xmp ${EXPAT_LIBRARIES}) + if ( NOT MSVC ) + TARGET_LINK_LIBRARIES(xmp ${EXPAT_LIBRARIES}) + else() + TARGET_LINK_LIBRARIES(xmp Threads::Threads ${EXPAT_LIBRARIES}) + endif() # 1119 Install libxmp.a for use by third party applications (Thanks, Emmanuel) INSTALL(TARGETS xmp ${INSTALL_TARGET_STANDARD_ARGS} ) ENDIF()