Merge pull request #63 from piponazo/conanSupport

Add Conan support
v0.27.3
Robin Mills 8 years ago committed by GitHub
commit 7338024f45

1
.gitignore vendored

@ -4,6 +4,7 @@
*.lo
*.o
*.swp
*.pyc
.DS_Store
config.log
config.status

@ -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

@ -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

@ -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

@ -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
##

@ -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

@ -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)

@ -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()

@ -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 )

@ -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
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
)
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}

@ -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" },

@ -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_OBJECTS:xmp_object>)
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)

Loading…
Cancel
Save