Feature #536 Modifications to CMake files to support MSVC 32/64 bit builds of Dynamic/Static libraries and applications.

This commit is contained in:
Robin Mills 2012-06-03 21:51:57 +00:00
parent 3c99aa336a
commit a292d57fd8
8 changed files with 426 additions and 148 deletions

View File

@ -1,7 +1,8 @@
# CMake build system for exiv2 library and executables
# Copyright 2008 by Patrick Spendrin <ps_ml at gmx dot de>
# Copyright 2010-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
#
# Copyright 2012- Robin Mills <robin@clanmills.com>
# Copyright 2010-2012 Gilles Caulier <caulier dot gilles at gmail dot com>
# Copyright 2008 Patrick Spendrin <ps_ml at gmx dot de>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
@ -23,13 +24,13 @@ SET( GENERIC_LIB_SOVERSION "12" )
# options and their default values
OPTION( EXIV2_ENABLE_SHARED "Build exiv2 as a shared library (dll)" ON )
OPTION( EXIV2_ENABLE_XMP "Build with XMP metadata support" ON )
OPTION( EXIV2_ENABLE_LIBXMP "Build a static convenience Library for XMP" OFF )
OPTION( EXIV2_ENABLE_LIBXMP "Build a static convenience Library for XMP" ON )
OPTION( EXIV2_ENABLE_PNG "Build with png support (requires libz)" ON )
OPTION( EXIV2_ENABLE_NLS "Build native language support (requires gettext)" ON )
OPTION( EXIV2_ENABLE_PRINTUCS2 "Build with Printucs2" ON )
OPTION( EXIV2_ENABLE_LENSDATA "Build including lens data" ON )
OPTION( EXIV2_ENABLE_COMMERCIAL "Build with the EXV_COMMERCIAL_VERSION symbol set" OFF )
OPTION( EXIV2_ENABLE_BUILD_SAMPLES "Build the unit tests" OFF )
OPTION( EXIV2_ENABLE_BUILD_SAMPLES "Build the unit tests" ON )
OPTION( EXIV2_ENABLE_BUILD_PO "Build translations files" OFF )
IF( MINGW OR UNIX )
@ -44,88 +45,82 @@ IF( MINGW OR UNIX )
ENDIF( MINGW OR UNIX )
if( MSVC )
include(CMake_msvc.txt)
msvc_runtime_report()
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
msvc_runtime_report()
# add_library("../zlib-1.2.5" SHARED IMPORTED)
##
# link dependant libraries
# apologies for the duplication of information
# I've been unable to simply this using the 'set' command
set(EXPAT_LIBRARY "../../expat-2.1.0/$(ConfigurationName)/expat")
set(ZLIB_LIBRARY "../../zlib-1.2.7/$(ConfigurationName)/zlib" )
include_directories( ../zlib-1.2.7 ../expat-2.1.0/lib)
set(EXPAT_INCLUDE_DIR ../expat-2.1.0/lib )
set(ZLIB_INCLUDE_DIR ../zlib-1.2.7 )
#include_directories( "../zlib-1.2.5" "../expat-2.0.1/lib" )
#set(EXPAT_INCLUDE_DIR "../expat-2.0.1/lib" )
#set(ZLIB_INCLUDE_DIR "../zlib-1.2.5" )
if ( EXIV2_ENABLE_SHARED )
add_library(expat-2.1.0 SHARED IMPORTED)
add_library(zlib-1.2.7 SHARED IMPORTED)
endif()
#set(EXPAT_LIBRARY "../expat-2.0.1")
#set(ZLIB_LIBRARY "../zlib-1.2.5" )
# target_link_libraries("zlibd.lib")
# add_subdirectory("../zlib-1.2.5" "../zlib-1.2.5" )
# set_target_properties(exiv2 PROPERTIES LINK_FLAGS "/LIBPATH:../zlib-1.2.5/$(ConfigurationName)")
# target_link_libraries(A B)
# set_property(TARGET PROPERTY LINK_FLAGS "/LIBPATH:../zlib-1.2.5/$(ConfigurationName)")
# cmake CMakeLists.txt -G "Visual Studio 9 2008" (Win64)
# cm.bat 2008 64 "-DEXIV2_ENABLE_SHARED=OFF" (32/ON) for 4 builds
# for %p in (Debug,Release) do devenv exiv2.sln /build %p for 2 builds
set( P_DIR Win32 )
set( T_DIR Static)
# 64 bit
##
# Set the output directory
# x64/Win32
if( CMAKE_SIZEOF_VOID_P MATCHES 8 )
SET( P_DIR x64)
endif( CMAKE_SIZEOF_VOID_P MATCHES 8 )
else()
set( P_DIR Win32 )
endif()
# DLL/static build
if( EXIV2_ENABLE_SHARED )
set( T_DIR Dynamic )
endif( EXIV2_ENABLE_SHARED )
else()
set( T_DIR Static)
endif()
set(B_DIR ${PROJECT_BINARY_DIR}/bin/${P_DIR}/${T_DIR})
set(CMAKE_CURRENT_BINARY_DIR ${B_DIR})
set(EXECUTABLE_OUTPUT_PATH ${B_DIR})
set(LIBRARY_OUTPUT_PATH ${B_DIR})
#if ( EXIV2_ENABLE_XMP )
# ..\expat\Win32\Debug\libexpat.lib
# ..\xmpsdk\Win32\Debug\xmpsdk.lib
# ..\zlib\Win32\Debug\zlib1d.lib
#endif( EXIV2_ENABLE_XMP )
endif( MSVC )
#IF( MINGW OR UNIX )
IF( EXIV2_ENABLE_XMP )
SET( HAVE_XMP_TOOLKIT ON )
SET( XMPLIB "do" )
ENDIF( EXIV2_ENABLE_XMP )
#ENDIF( MINGW OR UNIX )
IF( EXIV2_ENABLE_XMP )
SET( HAVE_XMP_TOOLKIT ON )
SET( XMPLIB "do" )
ENDIF( EXIV2_ENABLE_XMP )
#IF( MINGW OR UNIX )
INCLUDE( config/ConfigureChecks.cmake )
#ENDIF( MINGW OR UNIX )
INCLUDE( config/ConfigureChecks.cmake )
SET( INSTALL_TARGET_STANDARD_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
)
# add sources from XMPSDK directory - this needs to be done here
#IF( MINGW OR UNIX )
SET( XMPSRC ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ExpatAdapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/MD5.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ParseRDF.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/UnicodeConversions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPIterator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPMeta.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPUtils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XML_Node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPCore_Impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPIterator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-GetSet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Parse.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Serialize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils-FileInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils.cpp
)
#ENDIF( MINGW OR UNIX )
##
# add sources from XMPSDK directory
# this needs to be done here to be visible to xmpsdk, src and sample sub directories
SET( XMPSRC ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ExpatAdapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/MD5.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ParseRDF.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/UnicodeConversions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPIterator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPMeta.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPUtils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XML_Node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPCore_Impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPIterator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-GetSet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Parse.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Serialize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils-FileInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils.cpp
)
# the following lines need to be added to circumvent the error in xmpsdk\src\MD5.h
IF( ${EXV_HAVE_STDINT_H} )
@ -143,4 +138,5 @@ IF( EXIV2_ENABLE_BUILD_PO )
ADD_SUBDIRECTORY( po )
ENDIF( EXIV2_ENABLE_BUILD_PO )
# include(logger.txt)
# That's all Folks!
##

80
CMake_msvc.txt Normal file
View File

@ -0,0 +1,80 @@
##
# msvc tuning macros
macro(msvc_runtime_set_static_ignores bDynamic)
if(MSVC)
# don't link msvcrt for .exe which use shared libraries (use default libcmt)
if ( ${bDynamic} STREQUAL "OFF" )
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:MSVCRTD")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:MSVCRT")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/NODEFAULTLIB:MSVCRT")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:MSVCRT")
endif()
endif()
endmacro()
# http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake
macro(msvc_runtime_configure bDynamic)
if(MSVC)
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if( ${bDynamic} STREQUAL "ON" )
message(STATUS "MSVC -> forcing use of dynamically-linked runtime." )
foreach(variable ${variables})
if(${variable} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
endif()
endforeach()
else()
message(STATUS "MSVC -> forcing use of statically-linked runtime." )
foreach(variable ${variables})
if(${variable} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
endif()
set(${variable} "${${variable}} /DXML_STATIC /D_LIB")
endforeach()
endif()
# remove /Ob2 and /Ob1 - they cause linker issues
set(obs /Ob2 /Ob1)
foreach(ob ${obs})
foreach(variable ${variables})
if(${variable} MATCHES ${ob} )
string(REGEX REPLACE ${ob} "" ${variable} "${${variable}}")
endif()
endforeach()
endforeach()
msvc_runtime_set_static_ignores(${bDynamic})
endif()
endmacro()
macro(msvc_runtime_report)
if(MSVC)
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
# CMAKE_C_LINK_EXECUTABLE
)
message(STATUS "Build flags:")
foreach(variable ${variables})
message(STATUS " '${variable}': ${${variable}}")
endforeach()
message(STATUS "")
endif()
endmacro()
# That's all Folks!
##

View File

@ -1,22 +1,40 @@
-------------------------------------------------------------------------------
NOTE:
* CMake scripts still under developpement. Use them only if you're prepared
to fix them. Look TODO-CMAKE.txt for pending task. Thanks for your help.
* CMake scripts are "work in progress".
Use them only if you're prepared to fix them.
See TODO-CMAKE for pending tasks.
* The old make and MSVC build files are currently still around but will be
considered deprecated for 0.20.0 release. They will disappear once
the cmake build process is feature-complete, stable and documented. Or
maybe earlier to force me to get there.
* The existing make, msvc and msvc64 build files will continue
to be supported by exiv2 until at least v0.25.
We will flag them as "deprecated" for at least one release cycle (about 6 months).
Our plan is to only support CMake when our scripts are feature-complete, stable and documented.
All help is appreciated - especially if you are willing to run
builds and tests on any platform. Thanks for your help.
Robin Mills
robin@clanmills.com
2012-06-01
-------------------------------------------------------------------------------
Exiv2 uses cmake, a cross-platform build system, to control the
compilation process using simple platform and compiler independent
compilation process using platform/compiler independent
configuration files.
Cmake resources
===============
TABLE OF CONTENTS
-----------------
1 CMake resources
2 Building and Installing for Unix type systems
3 Building and Installing for DevStudio Users
4 Building and Installing for other users (Xcode, Eclipse, Qt)
1 CMake resources
=================
You have to install cmake on your target system.
Home: http://www.cmake.org/
Help: http://www.cmake.org/cmake/help/help.html
@ -24,9 +42,10 @@ Doc: http://www.cmake.org/cmake/help/documentation.html
Wiki: http://www.cmake.org/Wiki/CMake
FAQ: http://www.cmake.org/Wiki/CMake_FAQ
2 Building and Installing on Linux
==================================
Building and Installing
=======================
This process also covers MacOS-X Terminal, Cygwin and MinGW users.
a) From the command line
@ -57,7 +76,7 @@ Specific Exiv2 options :
-DEXIV2_ENABLE_SHARED : Build exiv2 as a shared library (dll). [default=on ]
-DEXIV2_ENABLE_XMP : Build with XMP metadata support. [default=on ]
-DEXIV2_ENABLE_LIBXMP : Build a static convenience Library for XMP. [default=off]
-DEXIV2_ENABLE_LIBXMP : Build a static convenience Library for XMP. [default=on ]
-DEXIV2_ENABLE_PNG : Build with png support (requires libz). [default=on ]
-DEXIV2_ENABLE_NLS : Build native language support (requires gettext). [default=on ]
-DEXIV2_ENABLE_PRINTUCS2 : Build with Printucs2. [default=on ]
@ -80,7 +99,105 @@ b) Using the cmake GUI
ccmake
Dependencies
============
3 Building and installing for DevStudio Users
=============================================
cmake itself
exiv2 provides three build environment for users of DevStudio:
msvc: 32 bit build environment for MSVC 2003 (and 2005 and 2008)
msvc64: 32 bit AND 64 bit build environment for MSVC 2005 (and 2008 and 2010)
cmake: This environment
CMake doesn't build code. It generates build environments.
CMake is a language for describing builds and the language interpreter generates
the build environment for your system.
CMake generates MSVC .sln and .vcproj files for your target environment.
The files generated by CMake provide 4 configs: Debug|Release|RelWithDebInfo|MinSizeRel
The current architecture of CMake requires you to decide before running cmake about:
1) The version of DevStudio
2) 32bit or 64 bit builds
3) Building static or shared libraries
Code FileSystem Layout
----------------------
I set up my environment as follows:
Directory of C:\gnu.cmake
2012-05-31 09:49 <DIR> exiv2 Vanilla
2012-05-31 09:45 <DIR> expat-2.1.0 source
2012-05-30 16:22 <DIR> zlib-1.2.7 trees
Other versions of expat and zlib make be used (although I've never tested them)
2012-05-19 21:29 <DIR> expat-2.0.1
2012-05-19 21:29 <DIR> zlib-1.2.3
2012-05-19 21:29 <DIR> zlib-1.2.5
The command to run cmake is of the form:
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
There are many options for the cmake command, and many generators. I've added a little
batch file cm.bat for my convenience.
c:\> cm 2008 64 == cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
Building with cmake involves 3 steps (build zlib/expat, build exiv2, test):
1) Building the support libraries expat and zlib (with cmake)
cd expat-2.1.0
Edit CMakeLists.txt to specify shared or static library
If you wish to use static libries, you'll need the following patch (around line 23)
See "Note about expat-2.1.0/CMakeLists.txt"
--- extract from CMakeLists.txt ---
option(XML_NS "Define to make XML Namespaces functionality available" ON)
# rmills patch begin
include(../exiv2/CMake_msvc.txt)
msvc_runtime_configure(${BUILD_shared})
# rmills patch end
if(XML_DTD)
--- extract end ---
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open expat.sln and build all.
Similar process for zlib-1.2.7
You will not need to edit CMakeLists.txt (zlib builds shared and dynamic libraries)
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open zlib.sln and build all.
2) Building exiv2
cd exiv2
Edit CMakeLists.txt to specify shared or static library (and other options)
You may need to change the path specifications to expat and zlib to match your setup
You will find path references in the three files:
CMakeLists.txt ./src/CMakeLists.txt and ./samples/CMakeLists.txt
cmake CMakeLists.txt -G "Visual Studio 9 2008 Win64"
.... rattle roll ....
Open exiv2.sln and build all.
3) Location of built files (exiv2.exe, exiv2.dll etc)
exiv2\bin\{ x64 | Win32 }\{ Dynamic|Static }\{Config}\exiv2.exe etc....
Config: Debug | MinSizeRel | Release | RelWithDebInfo
Note about expat-2.1.0/CMakeLists.txt
-------------------------------------
expat-2.1.0/CMakeLists.txt can build static or dynamic libraries.
However expat's CMakeLists.txt links with MSVCRTx.dll for both static and dynamic.
I've taken a decision to either link "All static" or "All dynamic" with no mixing.
This patch enforces my design and avoids linker headaches.
4 Building and Installing for other users (Xcode, Eclipse, Qt)
==============================================================
To be written
# That's all Folks
##

View File

@ -1,3 +1,20 @@
My current list
ToDo: * 2005/32/debug won't run "SideBySide" error (manifest trouble)
* try again to simplify path definitions for expat and zlib
* add the header files in MSVC
* write FindLibexiv2.cmake
* Test Cygwin, MinGW, Xcode and more versions of MSVC
Done: * Builds and passes the test suite on 2005/32, 2008/64, Mac-Lion/64/Makefiles and Ubuntu/12.04/32bit
* Updated documentation (README-CMAKE)
Robin Mills
robin@clanmills.com
2012-06-03
Inherited from Gilles Caulier <caulier dot gilles at gmail dot com>:
* Review how samples are built: They should use the *installed* version
of libexiv2, not some temporary version in the src or build tree.

View File

@ -1,10 +1,20 @@
# CMake build system for exiv2 library and executables
# Copyright 2008 by Patrick Spendrin <ps_ml@gmx.de>
# Copyright 2010-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
#
# Copyright 2012- Robin Mills <robin@clanmills.com>
# Copyright 2010-2012 Gilles Caulier <caulier dot gilles at gmail dot com>
# Copyright 2008 Patrick Spendrin <ps_ml@gmx.de>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if (MSVC)
include(../CMake_msvc.txt)
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../msvc64/include )
if ( NOT EXIV2_ENABLE_SHARED )
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../zlib-1.2.7/$(ConfigurationName))
endif()
endif()
SET( SAMPLES addmoddel.cpp
convert-test.cpp
easyaccess-test.cpp
@ -35,3 +45,6 @@ FOREACH(entry ${SAMPLES})
ADD_TEST( ${target}_test ${target} )
TARGET_LINK_LIBRARIES( ${target} exiv2 )
ENDFOREACH(entry ${SAMPLES})
# That's all Folks!
##

View File

@ -1,7 +1,8 @@
# CMake build system for exiv2 library and executables
# Copyright 2008 by Patrick Spendrin <ps_ml@gmx.de>
# Copyright 2010-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
#
# Copyright 2012- Robin Mills <robin@clanmills.com>
# Copyright 2010-2012 Gilles Caulier <caulier dot gilles at gmail dot com>
# Copyright 2008 Patrick Spendrin <ps_ml@gmx.de>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
@ -117,20 +118,8 @@ SET( LIBEXIV2_SRC basicio.cpp
xmpsidecar.cpp
)
# Add source files of simple applications to this list
SET( TAGLIST_SRC taglist.cpp )
# Source files for the Exiv2 application
SET( EXIV2_SRC exiv2.cpp
actions.cpp
utils.cpp
)
# Source files for the metacopy sample application
SET( MC_SRC metacopy.cpp
utils.cpp
)
##
# add png*.cpp files if PNG support requested
IF( EXIV2_ENABLE_PNG )
IF( ZLIB_FOUND )
SET( LIBEXIV2_SRC ${LIBEXIV2_SRC}
@ -141,80 +130,137 @@ IF( EXIV2_ENABLE_PNG )
ENDIF( ZLIB_FOUND )
ENDIF( EXIV2_ENABLE_PNG )
IF(NOT HAVE_TIMEGM )
SET( LIBEXIV2_SRC ${LIBEXIV2_SRC} localtime.c )
SET( EXIV2_SRC ${EXIV2_SRC} localtime.c )
ENDIF( NOT HAVE_TIMEGM )
IF( MSVC )
SET( MC_SRC ${MC_SRC} getopt_win32.c )
SET( EXIV2_SRC ${EXIV2_SRC} getopt_win32.c )
SET( LIBEXIV2_SRC ${LIBEXIV2_SRC} getopt_win32.c )
ENDIF( MSVC )
##
# add xmp source if xmp is requested and xmp library not built
IF( EXIV2_ENABLE_XMP )
IF( NOT EXIV2_ENABLE_LIBXMP )
SET( LIBEXIV2_SRC ${XMPSRC} ${LIBEXIV2_SRC} )
ENDIF( NOT EXIV2_ENABLE_LIBXMP )
ENDIF( EXIV2_ENABLE_XMP )
##
# Create source file lists for applications
# exiv2 application
SET( EXIV2_SRC exiv2.cpp
actions.cpp
utils.cpp
)
# taglist sample application
SET( TAGLIST_SRC taglist.cpp )
# metacopy sample application
SET( MC_SRC metacopy.cpp
utils.cpp
)
# pathtest sample application
SET( PATHTEST_SRC path-test.cpp
utils.cpp
)
##
# modify source lists to suit environment
IF(NOT HAVE_TIMEGM )
SET( LIBEXIV2_SRC ${LIBEXIV2_SRC} localtime.c )
SET( EXIV2_SRC ${EXIV2_SRC} localtime.c )
SET( PATHTEST_SRC ${PATHTEST_SRC} localtime.c )
ENDIF( NOT HAVE_TIMEGM )
IF( MSVC )
SET( MC_SRC ${MC_SRC} getopt_win32.c )
SET( EXIV2_SRC ${EXIV2_SRC} getopt_win32.c )
SET( LIBEXIV2_SRC ${LIBEXIV2_SRC} getopt_win32.c )
SET( PATHTEST_SRC ${PATHTEST_SRC} getopt_win32.c )
ENDIF( MSVC )
##
# msvn tuning
include(../CMake_msvc.txt)
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
# ******************************************************************************
# Library
# exiv2 library
ADD_LIBRARY( exiv2 ${STATIC_FLAG} ${LIBEXIV2_SRC} )
SET_TARGET_PROPERTIES( exiv2 PROPERTIES VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
DEFINE_SYMBOL EXV_BUILDING_LIB
)
SET_TARGET_PROPERTIES( exiv2 PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
DEFINE_SYMBOL EXV_BUILDING_LIB
)
TARGET_LINK_LIBRARIES( exiv2 ${EXPAT_LIBRARIES} )
# IF( MINGW OR UNIX )
if( EXIV2_ENABLE_LIBXMP )
TARGET_LINK_LIBRARIES( exiv2 ${XMPLIB} )
ENDIF( EXIV2_ENABLE_LIBXMP )
if( EXIV2_ENABLE_LIBXMP )
ADD_DEPENDENCIES( exiv2 xmp )
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH}/$(ConfigurationName))
TARGET_LINK_LIBRARIES( exiv2 xmp )
ENDIF()
IF( EXIV2_ENABLE_PNG )
IF( ZLIB_FOUND )
# IF ( MINGW OR UNIX )
TARGET_LINK_LIBRARIES( exiv2 ${ZLIB_LIBRARIES} )
# ELSE ( MINGW OR UNIX )
# TARGET_LINK_LIBRARIES( exiv2 zlibd )
# ENDIF( MINGW OR UNIX )
ENDIF( ZLIB_FOUND )
ENDIF( EXIV2_ENABLE_PNG )
IF( EXIV2_ENABLE_PNG )
IF( ZLIB_FOUND )
IF( MSVC )
if ( EXIV2_ENABLE_SHARED )
TARGET_LINK_LIBRARIES( exiv2 optimized ${ZLIB_LIBRARIES} debug ${ZLIB_LIBRARIES}d )
else()
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../zlib-1.2.7/$(ConfigurationName))
TARGET_LINK_LIBRARIES( exiv2 optimized zlibstatic.lib debug zlibstaticd.lib )
endif()
ELSE()
TARGET_LINK_LIBRARIES( exiv2 ${ZLIB_LIBRARIES} )
ENDIF()
ENDIF()
ENDIF()
IF( EXIV2_ENABLE_NLS )
TARGET_LINK_LIBRARIES( exiv2 ${LIBINTL_LIBRARIES} )
ENDIF( EXIV2_ENABLE_NLS )
IF( EXIV2_ENABLE_NLS )
TARGET_LINK_LIBRARIES( exiv2 ${LIBINTL_LIBRARIES} )
ENDIF( EXIV2_ENABLE_NLS )
IF( ICONV_FOUND )
TARGET_LINK_LIBRARIES( exiv2 ${ICONV_LIBRARIES} )
ENDIF( ICONV_FOUND )
# ENDIF( MINGW OR UNIX )
IF( ICONV_FOUND )
TARGET_LINK_LIBRARIES( exiv2 ${ICONV_LIBRARIES} )
ENDIF( ICONV_FOUND )
##
# copy zlib and expat dlls to output directory if necessary
IF ( MSVC AND EXIV2_ENABLE_SHARED )
ADD_CUSTOM_COMMAND(
TARGET exiv2
POST_BUILD
COMMAND copy /y $(SolutionDir)\\..\\expat-2.1.0\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
ADD_CUSTOM_COMMAND(
TARGET exiv2
POST_BUILD
COMMAND copy /y $(SolutionDir)\\..\\zlib-1.2.7\\$(ConfigurationName)\\*.dll $(SolutionDir)\\bin\\${P_DIR}\\${T_DIR}\\$(ConfigurationName)
)
ENDIF()
INSTALL( TARGETS exiv2 ${INSTALL_TARGET_STANDARD_ARGS} )
# ******************************************************************************
# Binary
# exiv2 application
ADD_EXECUTABLE( exiv2bin ${EXIV2_SRC} )
SET_TARGET_PROPERTIES( exiv2bin PROPERTIES OUTPUT_NAME exiv2 )
TARGET_LINK_LIBRARIES( exiv2bin exiv2 )
INSTALL( TARGETS exiv2bin ${INSTALL_TARGET_STANDARD_ARGS} )
# ******************************************************************************
# Binary
# metacopy sample application
ADD_EXECUTABLE( metacopy ${MC_SRC} )
TARGET_LINK_LIBRARIES( metacopy exiv2 )
INSTALL( TARGETS metacopy ${INSTALL_TARGET_STANDARD_ARGS} )
# ******************************************************************************
# Binary
# taglist sample application
ADD_EXECUTABLE( taglist ${TAGLIST_SRC} )
TARGET_LINK_LIBRARIES( taglist exiv2 )
INSTALL( TARGETS taglist ${INSTALL_TARGET_STANDARD_ARGS} )
# ******************************************************************************
# path-test sample application
ADD_EXECUTABLE( pathtest ${PATHTEST_SRC} )
SET_TARGET_PROPERTIES( pathtest PROPERTIES OUTPUT_NAME path-test )
TARGET_LINK_LIBRARIES( pathtest exiv2 )
INSTALL( TARGETS pathtest ${INSTALL_TARGET_STANDARD_ARGS} )
# ******************************************************************************
# Headers
INSTALL( FILES ${LIBEXIV2_HDR} DESTINATION include/exiv2 )
@ -222,3 +268,6 @@ INSTALL( FILES ${LIBEXIV2_HDR} DESTINATION include/exiv2 )
# ******************************************************************************
# Man page
INSTALL( FILES exiv2.1 DESTINATION man/man1 )
# That's all Folks!
##

View File

@ -79,7 +79,7 @@ void write(const std::string& filename, const Exiv2::Internal::CiffHeader* pHead
throw Exiv2::Error(9, io.path(), Exiv2::strError());
}
Exiv2::IoCloser closer(io);
long ret = io.write(&blob[0], blob.size());
long ret = io.write(&blob[0], (long) blob.size());
if (static_cast<size_t>(ret) != blob.size()) throw Exiv2::Error(21);
io.close();
}

View File

@ -1,14 +1,20 @@
# CMake build system for exiv2 library and executables
# Copyright 2008 by Patrick Spendrin <ps_ml at gmx dot de>
# Copyright 2010-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
#
# Copyright 2012- Robin Mills <robin@clanmills.com>
# Copyright 2010-2012 Gilles Caulier <caulier dot gilles at gmail dot com>
# Copyright 2008 Patrick Spendrin <ps_ml at gmx dot de>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(../CMake_msvc.txt)
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
IF( EXIV2_ENABLE_XMP AND EXIV2_ENABLE_LIBXMP )
ADD_LIBRARY( xmp STATIC ${XMPSRC} )
GET_TARGET_PROPERTY( XMPLIB xmp LOCATION )
SET( XMPLIB ${XMPLIB} PARENT_SCOPE )
INSTALL(TARGETS xmp ${INSTALL_TARGET_STANDARD_ARGS} )
# SET( XMPLIB ${XMPLIB} PARENT_SCOPE )
# INSTALL(TARGETS xmp ${INSTALL_TARGET_STANDARD_ARGS} )
ENDIF( EXIV2_ENABLE_XMP AND EXIV2_ENABLE_LIBXMP )
# That's all Folks!
##