diff --git a/.gitignore b/.gitignore index b63261af..c0482fed 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.lo *.o *.swp +*.pyc .DS_Store config.log config.status diff --git a/.travis.yml b/.travis.yml index 746856be..7fbf81c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,16 @@ os: - linux - osx +matrix: + exclude: + - os: osx + compiler: gcc + env: - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release" # Default - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF" # Default (Debug mode + static libs) + #- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release" # Default + #- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF" # Default (Debug mode + static libs) - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON" # All enabled - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_XMP=OFF -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_LENSDATA=OFF" # All disabled + #- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_XMP=OFF -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_LENSDATA=OFF" # All disabled #- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=OFF -DEXIV2_ENABLE_SSH=OFF" # WebReady without SSH nor CURL install: ./.travis/install.sh diff --git a/.travis/install.sh b/.travis/install.sh index 52057cfc..7c249293 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -4,9 +4,25 @@ set -x if [[ "$(uname -s)" == 'Linux' ]]; then sudo apt-get install cmake zlib1g-dev libssh-dev libcurl4-openssl-dev gettext libexpat1-dev + sudo apt-get install python-pip + sudo pip install virtualenv else brew update brew install expat gettext libssh + brew install pyenv-virtualenv # By default it already has cmake 3.6.2 fi +virtualenv conan +source conan/bin/activate +pip install conan +conan --version +conan remote add conan-pix4d https://api.bintray.com/conan/pix4d/conan +mkdir -p ~/.conan/profiles + +if [[ "$(uname -s)" == 'Linux' ]]; then + printf "os=Linux\narch=x86_64\ncompiler=gcc\ncompiler.version=4.8\nbuild_type=Release\n" > ~/.conan/profiles/release +else + printf "os=Macos\narch=x86_64\ncompiler=apple-clang\ncompiler.version=7.3\nbuild_type=Release\n" > ~/.conan/profiles/release +fi + diff --git a/.travis/run.sh b/.travis/run.sh index 5b047c54..060b1106 100755 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -3,7 +3,9 @@ set -e set -x +source conan/bin/activate mkdir build && cd build +conan install .. --build missing --profile release cmake ${CMAKE_OPTIONS} .. cmake -DCMAKE_INSTALL_PREFIX=install .. make -j diff --git a/README-CMAKE b/README-CMAKE index 46fbb1f6..7cae5a6f 100644 --- a/README-CMAKE +++ b/README-CMAKE @@ -179,5 +179,26 @@ We have two contributed CMake Build Environments: It is possible to use CMake/MinGW if you put in some effort. This is documented in TODO-CMAKE. +5 Using conan from bringing project dependencies +========================================= + +Conan is a portable package manager for c++ (https://www.conan.io/). We added the option to use it +in Exiv2 so you can get all the Exiv2 dependencies (Expat, Zlib, Libcurl, Libssh) in a very easy +way. Basically, all you need to do is to have conan installed on your system and run the command +`conan install` before calling CMake: + + $ mkdir build && cd build + $ conan install .. + $ cmake .. or cmake-gui .. + +Conan will search for the dependencies in different repositories. At the moment of writing this +text, the conan-expat is not available in the official conan repositories, so you have to add the +following remote to your conan configuration: + + $ conan remote add conan-pix4d https://api.bintray.com/conan/pix4d/conan + +To learn more about Conan, please visit their documentation page: http://docs.conan.io/en/latest/ + + # That's all Folks ## diff --git a/appveyor.yml b/appveyor.yml index 4fc068e7..73039e3e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,25 @@ -image: -- Visual Studio 2017 +image: Visual Studio 2017 + +shallow_clone: true + +environment: + VS150COMNTOOLS: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\" + +before_build: +- cmd: mkdir envs && cd envs +- cmd: python -m virtualenv conan +- cmd: conan/Scripts/activate +- cmd: python -m pip install conan==0.26.0 +- cmd: cd .. +- cmd: conan remote add conan-pix4d https://api.bintray.com/conan/pix4d/conan +- cmd: mkdir c:\Users\appveyor\.conan\profiles +- cmd: printf "os=Windows\narch=x86\ncompiler=Visual Studio\ncompiler.version=15\ncompiler.runtime=MD\nbuild_type=Release\n" > c:\Users\appveyor\.conan\profiles\release +- cmd: cat c:\Users\appveyor\.conan\profiles\release build_script: - md build - cd build - - cmake -DEXIV2_ENABLE_XMP=OFF -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_PNG=OFF -DCMAKE_INSTALL_PREFIX=install .. + - conan install .. --build missing --profile release + - cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" -DEXIV2_ENABLE_XMP=ON -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=ON -DCMAKE_INSTALL_PREFIX=install .. - cmake --build . --config Release - - cmake --build . --config Debug - cmake --build . --target install diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..a2f6d443 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile +from conans.tools import os_info + +class Exiv2Conan(ConanFile): + settings = 'os', 'compiler', 'build_type', 'arch' + generators = 'cmake' + + def configure(self): + # Note : The linking in exiv2lib fails if we try to use the static version of libcurl. + # The libcurl CMake code is not mature enough and therefore the conan recipe for + # Windows also has some problems (since it uses CMake for configuring the project). + if os_info.is_windows: + self.options['libcurl'].shared = True + + def requirements(self): + self.requires('Expat/2.2.1@pix4d/stable') # From pix4d + self.requires('zlib/1.2.8@lasote/stable') # From conan-center + self.requires('libcurl/7.50.3@lasote/stable') # From conan-transit (It also brings OpenSSL) diff --git a/config/compilerFlags.cmake b/config/compilerFlags.cmake index dee3cfa0..c02a4139 100644 --- a/config/compilerFlags.cmake +++ b/config/compilerFlags.cmake @@ -58,4 +58,9 @@ if(MSVC) set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:MSVCRT") endif() + # Resolving Redefinition Errors Betwen ws2def.h and winsock.h: + # - http://www.zachburlingame.com/2011/05/resolving-redefinition-errors-betwen-ws2def-h-and-winsock-h/ + # - https://stackoverflow.com/questions/11040133/what-does-defining-win32-lean-and-mean-exclude-exactly + add_definitions(-DWIN32_LEAN_AND_MEAN) + endif() diff --git a/config/findDependencies.cmake b/config/findDependencies.cmake index cb522449..16967763 100644 --- a/config/findDependencies.cmake +++ b/config/findDependencies.cmake @@ -1,6 +1,13 @@ # set include path for FindXXX.cmake files set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/config/") +# Check if the conan file exist to find the dependencies +if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + set(USING_CONAN ON) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_set_find_paths() +endif() + find_package(Threads REQUIRED) if( EXIV2_ENABLE_PNG ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87a4d6f1..6c6f32b9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,6 +160,10 @@ if( EXIV2_ENABLE_PNG ) set( LIBEXIV2_HDR ${LIBEXIV2_HDR} ../include/exiv2/pngimage.hpp ) endif() +source_group("Header Files" FILES ${LIBEXIV2_HDR} ) +source_group("Header Files" FILES ${LIBCURL_HDR} ) +source_group("Header Files" FILES ${SSH_HDR} ) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) # ****************************************************************************** @@ -191,6 +195,9 @@ endif() if ( EXIV2_ENABLE_XMP ) target_include_directories(exiv2lib PRIVATE ${CMAKE_SOURCE_DIR}/xmpsdk/include) + if( EXIV2_ENABLE_LIBXMP ) + target_link_libraries( exiv2lib PUBLIC xmp ) + endif() endif() # TODO : We should not include include/exiv2 but only include !!! @@ -199,37 +206,49 @@ target_include_directories(exiv2lib PUBLIC $ ) -if (EXIV2_ENABLE_WEBREADY AND EXIV2_ENABLE_CURL) - target_include_directories(exiv2lib SYSTEM PUBLIC ${CURL_INCLUDE_DIR} ) -endif() +if (EXIV2_ENABLE_WEBREADY) + + if( EXIV2_ENABLE_SSH ) + target_include_directories(exiv2lib SYSTEM PUBLIC ${SSH_INCLUDE_DIR} ) + target_link_libraries( exiv2lib PUBLIC ${SSH_LIBRARIES}) + endif() + + if( EXIV2_ENABLE_CURL ) + target_include_directories(exiv2lib SYSTEM PUBLIC ${CURL_INCLUDE_DIR} ) + + if (USING_CONAN) + # TODO : Improve libcurl recipe so we do not need to have all these conditionals here + if ( MSVC ) + target_link_libraries( exiv2lib PUBLIC ${CURL_LIBRARY}) + else() + target_link_libraries( exiv2lib PUBLIC ${CONAN_LIBS_LIBCURL}) + endif() + target_compile_definitions(exiv2lib PUBLIC ${CONAN_COMPILE_DEFINITIONS_LIBCURL}) + else() + target_link_libraries( exiv2lib PUBLIC ${CURL_LIBRARIES}) + endif() + + endif() -if (EXIV2_ENABLE_WEBREADY AND EXIV2_ENABLE_SSH) - target_include_directories(exiv2lib SYSTEM PUBLIC ${SSH_INCLUDE_DIR} ) endif() if ( MSVC ) - target_compile_definitions(exiv2lib PRIVATE PSAPI_VERSION=1) # to be compatible with <= WinVista (#905) + target_compile_definitions(exiv2lib + PRIVATE + PSAPI_VERSION=1 # to be compatible with <= WinVista (#905) + ) - if ( EXIV2_ENABLE_STATIC ) - target_link_libraries( exiv2lib zlibstatic ${ZLIB_LIBRARIES} ) - else() - target_link_libraries( exiv2lib PRIVATE ${ZLIB_LIBRARIES} ) - endif() - source_group("Header Files" FILES ${LIBEXIV2_HDR} ) - source_group("Header Files" FILES ${LIBCURL_HDR} ) - source_group("Header Files" FILES ${SSH_HDR} ) - target_link_libraries( exiv2lib PRIVATE ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} ${SSH_LIBRARIES}) else() # TODO: Check if this is really needed. if ( UNIX AND NOT FREEBSD ) target_link_libraries( exiv2lib PRIVATE dl) endif() - target_link_libraries( exiv2lib PRIVATE Threads::Threads) - target_link_libraries( exiv2lib PUBLIC ${CURL_LIBRARIES} ${SSH_LIBRARIES}) -endif() -if( EXIV2_ENABLE_XMP AND EXIV2_ENABLE_LIBXMP ) - target_link_libraries( exiv2lib PUBLIC xmp ) + if (CYGWIN OR MINGW) + target_link_libraries( exiv2lib PRIVATE psapi ws2_32 ) + endif() + + target_link_libraries( exiv2lib PRIVATE Threads::Threads) endif() if( EXIV2_ENABLE_PNG ) @@ -245,9 +264,6 @@ if( ICONV_FOUND ) target_link_libraries( exiv2lib PRIVATE ${ICONV_LIBRARIES} ) endif() -if (CYGWIN OR MINGW) - target_link_libraries( exiv2lib PRIVATE psapi ws2_32 ) -endif() install(TARGETS exiv2lib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/src/canonmn.cpp b/src/canonmn.cpp index cbfaad44..68684c1d 100644 --- a/src/canonmn.cpp +++ b/src/canonmn.cpp @@ -857,6 +857,7 @@ namespace Exiv2 { { 144, "Canon EF 35-135mm f/4-5.6 USM" }, { 145, "Canon EF 100-300mm f/4.5-5.6 USM" }, { 146, "Canon EF 70-210mm f/3.5-4.5 USM" }, + { 147, "Canon EF 35-135mm f/4-5.6 USM" }, { 148, "Canon EF 28-80mm f/3.5-5.6 USM" }, { 149, "Canon EF 100mm f/2 USM" }, diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt index 68a8eab3..35359e3b 100644 --- a/xmpsdk/CMakeLists.txt +++ b/xmpsdk/CMakeLists.txt @@ -41,24 +41,37 @@ 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 ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # 1123 - hide xmpsdk symbols + set_property(SOURCE ${XMPSRC} PROPERTY + COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden") +endif() + if( EXIV2_ENABLE_LIBXMP ) add_library(xmp STATIC $) - target_link_libraries(xmp PUBLIC ${EXPAT_LIBRARIES}) + target_link_libraries(xmp PUBLIC ${EXPAT_LIBRARY}) + + # This is also needed for the xmp static library target_include_directories(xmp PUBLIC ${EXPAT_INCLUDE_DIR}) - target_include_directories(xmp PUBLIC ${CMAKE_SOURCE_DIR}/xmpsdk/include) + target_compile_definitions(xmp PUBLIC 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 PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden ) + if (BUILD_SHARED_LIBS) + set_property(TARGET xmp_object PROPERTY POSITION_INDEPENDENT_CODE ON) endif() # 1119 Install libxmp.a for use by third party applications (Thanks, Emmanuel)