From 60d436c96960fa314e2d12d017440253ce280d51 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Tue, 5 Sep 2017 21:36:56 +0100 Subject: [PATCH] Many changes to CMakeLists.txt and cmakeBuild.cmd to support unicode, static linking, passing shared library build flags. --- CMakeLists.txt | 25 ++-- config/compilerFlags.cmake | 4 +- config/printSummary.cmake | 9 +- contrib/cmake/msvc/ReadMe.txt | 102 +++++++++----- contrib/cmake/msvc/cmakeBuild.cmd | 42 ++++-- contrib/cmake/msvc/cmakeDefaults.cmd | 4 +- po/CMakeLists.txt | 48 +++---- samples/CMakeLists.txt | 105 ++++++++------ src/CMakeLists.txt | 200 ++++++--------------------- xmpsdk/CMakeLists.txt | 40 +----- 10 files changed, 252 insertions(+), 327 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b14d1962..1bcdcb3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,4 @@ -# CMake build system for exiv2 library and executables -# Copyright 2015- Daniel Kaneider -# Copyright 2010-2012 Gilles Caulier -# Copyright 2008 Patrick Spendrin - -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# CMakeLists.txt for exiv2 library cmake_minimum_required( VERSION 3.1.0 ) project( exiv2 ) @@ -30,7 +24,6 @@ set( GENERIC_LIB_VERSION "26.0.0" ) set( GENERIC_LIB_SOVERSION "26" ) # 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" ON ) option( EXIV2_ENABLE_PNG "Build with png support (requires libz)" ON ) @@ -38,8 +31,6 @@ option( EXIV2_ENABLE_NLS "Build native language support (requires gett 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" ON ) -option( EXIV2_ENABLE_BUILD_PO "Build translations files" OFF ) option( EXIV2_ENABLE_VIDEO "Build video support into library" OFF ) option( EXIV2_ENABLE_WEBREADY "Build webready support into library" OFF ) option( EXIV2_ENABLE_DYNAMIC_RUNTIME "Use dynamic runtime (used for static libs)" OFF ) @@ -51,7 +42,9 @@ else() option( EXIV2_ENABLE_CURL "USE Libcurl for HttpIo" ON ) option( EXIV2_ENABLE_SSH "USE Libssh for SshIo" ON ) endif() -option( EXIV2_ENABLE_TOOLS "Build exiv2 executable" ON ) +option( EXIV2_BUILD_SAMPLES "Build sample applications" ON ) +option( EXIV2_BUILD_PO "Build translations files" OFF ) +option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON ) include(config/findDependencies.cmake) include(config/compilerFlags.cmake) @@ -62,7 +55,12 @@ if( EXIV2_ENABLE_COMMERCIAL ) endif() if( MSVC ) - set(CMAKE_DEBUG_POSTFIX "d") + if ( EXIV2_ENABLE_WIN_UNICODE ) + set(CMAKE_DEBUG_POSTFIX "du") + set(CMAKE_RELEASE_POSTFIX "u") + else() + set(CMAKE_DEBUG_POSTFIX "d") + endif() endif() if( EXIV2_ENABLE_XMP ) @@ -106,3 +104,6 @@ if( MINGW OR UNIX OR APPLE) endif() include( config/printSummary.cmake ) + +# That's all Folks! +## diff --git a/config/compilerFlags.cmake b/config/compilerFlags.cmake index a459da65..656ade47 100644 --- a/config/compilerFlags.cmake +++ b/config/compilerFlags.cmake @@ -23,7 +23,7 @@ if(MSVC) CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO ) - if ( ${EXIV2_ENABLE_SHARED} OR ${EXIV2_ENABLE_DYNAMIC_RUNTIME}) + if ( ${BUILD_SHARED_LIBS} OR ${EXIV2_ENABLE_DYNAMIC_RUNTIME} ) message(STATUS "MSVC -> forcing use of dynamically-linked runtime." ) foreach(variable ${variables}) if(${variable} MATCHES "/MT") @@ -51,7 +51,7 @@ if(MSVC) endforeach() # don't link msvcrt for .exe which use shared libraries (use default libcmt) - if ( NOT ${EXIV2_ENABLE_SHARED} AND NOT ${EXIV2_ENABLE_DYNAMIC_RUNTIME}) + if ( NOT ${BUILD_SHARED_LIBS} AND NOT ${EXIV2_ENABLE_DYNAMIC_RUNTIME}) set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:MSVCRTD") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:MSVCRT") set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/NODEFAULTLIB:MSVCRT") diff --git a/config/printSummary.cmake b/config/printSummary.cmake index e5b1cc1e..cb82ec89 100644 --- a/config/printSummary.cmake +++ b/config/printSummary.cmake @@ -18,19 +18,16 @@ message( STATUS "Compiler info: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) message( STATUS "------------------------------------------------------------------" ) message( STATUS "${PACKAGE_STRING} configure results <${PACKAGE_URL}>" ) +OptionOutput( "Building shared library: " BUILD_SHARED_LIBS ) OptionOutput( "Building PNG support: " EXIV2_ENABLE_PNG AND ZLIB_FOUND ) -OptionOutput( "Building shared library: " EXIV2_ENABLE_SHARED ) OptionOutput( "XMP metadata support: " EXIV2_ENABLE_XMP ) OptionOutput( "Building static libxmp: " EXIV2_ENABLE_LIBXMP ) OptionOutput( "Native language support: " EXIV2_ENABLE_NLS ) OptionOutput( "Conversion of Windows XP tags: " EXIV2_ENABLE_PRINTUCS2 ) OptionOutput( "Nikon lens database: " EXIV2_ENABLE_LENSDATA ) OptionOutput( "Commercial build: " EXIV2_ENABLE_COMMERCIAL ) -OptionOutput( "Build the unit tests: " EXIV2_ENABLE_BUILD_SAMPLES ) -OptionOutput( "Building translations files: " EXIV2_ENABLE_BUILD_PO ) OptionOutput( "Building video support: " EXIV2_ENABLE_VIDEO ) OptionOutput( "Building webready support: " EXIV2_ENABLE_WEBREADY ) - if ( EXIV2_ENABLE_WEBREADY ) OptionOutput( "USE Libcurl for HttpIo: " EXIV2_ENABLE_CURL ) OptionOutput( "USE Libssh for SshIo: " EXIV2_ENABLE_SSH ) @@ -40,5 +37,9 @@ if (WIN32) OptionOutput( "Dynamic runtime override: " EXIV2_ENABLE_DYNAMIC_RUNTIME) OptionOutput( "Unicode paths (wstring): " EXIV2_ENABLE_WIN_UNICODE ) endif() +OptionOutput( "Building exiv2 command: " EXIV2_BUILD_EXIV2_COMMAND ) +OptionOutput( "Building samples: " EXIV2_BUILD_SAMPLES ) +OptionOutput( "Building PO files: " EXIV2_BUILD_PO ) + message( STATUS "------------------------------------------------------------------" ) diff --git a/contrib/cmake/msvc/ReadMe.txt b/contrib/cmake/msvc/ReadMe.txt index 6cb601c9..4c8ce5fa 100755 --- a/contrib/cmake/msvc/ReadMe.txt +++ b/contrib/cmake/msvc/ReadMe.txt @@ -1,4 +1,4 @@ - @@@Marco@@@@@b ;mm /##Gilles###\ + @@@Luis@@@@@b ;mm /##Gilles###\ j@@@#Robin", Brad /@@@Thomas@@@@Q @@@# \ ## @@@b |@@@b @@@# .;;;;, ,;;;, ,;;;; ,;;;p .;;; 7@@ ]Alan @@ -9,7 +9,7 @@ @@@# ,@@##@@m @@@b @@@p @@C #@@#C @@@# ,/ s@@# @@@@ @@@b Volker @Tuan@ ]@@@Abhinav@@\ /@@@\ \@@@Q @@@Q %@@@# /@@@@Mahesh@@# - /@@Raphael@@@@@\ /@@@@@\ C++ Metadata Library /@Sridhar@@@v0.26\ + /@@Raphael@@@@@\ /@@@@@\ C++ Metadata Library /@Sridhar@@@v0.26.1\ exiv2/contrib/cmake/msvc/ReadMe.txt ----------------------------------- @@ -39,7 +39,7 @@ How to use this cd \contrib\cmake\cmake cmd.exe vcvars 2015 64 - cmakeBuild --help # display syntax and options + cmakeBuild --help # display syntax and options cmakeBuild --rebuild .... exit @@ -65,7 +65,42 @@ How to use this When you are building happily, you may prefer: cmakeBuild --silent -3 What gets built? +3 Options + C:\Users\rmills\gnu\github\clanmills\exiv2\contrib\cmake\msvc>cmakeBuild --help + Options: --help | --webready | --rebuild | --video | --static | --unicode | --nls + --silent | --verbose | --pause | --dryrun | --test | --trace + --exiv2 C:\Users\rmills\gnu\github\clanmills\exiv2 | --work work | --config Release | --generator generator + --zlib zlib-1.2.8 | --expat expat-2.1.0 | --curl curl-7.45.0 | --libssh libssh-0.7.2 + --bash c:\cygwin64\bin\bash.exe + + Option switches. + --help Print help message and quit + --webready Build and Link the webready feature + --rebuild Delete "relics" from a previous build such as CMakeBuild.txt + --video Build and link video support + --static Build and link static libraries and programs + --nosamples Do not build sample applications + --unicode Build UNICODE path support + --nls Build with Natural Language Support + --silent Run script with minimal "chatter" + --verbose Run script with maximum "chatter" + --trace Show commands begin executed by the script + --dryrun Don't build anything. Report and quit + --test Execute the test suite after the build + + Option/values (See section 9 below) + --zlib zlib-1.2.8 + --expath expat-2.1.0 + --curl curl-7.44.0 + --libssh libssh-0.7.2 + + Other build key/value pairs: + --config Release | Debug + --generator The script default is almost always correct and is passed as -G "Generator" to CMake + --work The "work" directory in which the build will be performed (see 4 below) + --bash Path to bash.exe to be used when --test is specified. + +4 What gets built? The build is performed in work The output is generated in dist dist\..mumble..\bin contains *.exe and *.dll files @@ -79,7 +114,7 @@ How to use this dll = shared library dll/static Release = configuration Release/Debug/RelWithDebInfo/MinSizeRel -4 Building manually with CMake +5 Building manually with CMake The cmake option -G Generator should be chosen for the version of Visual Studio installed. cmake --help for more information @@ -124,7 +159,7 @@ How to use this cmake --build . --config Release cmake --build . --config Release --target install -5 About webready support libraries (openssl, libssh and curl) +6 About webready support libraries (openssl, libssh and curl) a) openssl You cannot build openssl with CMake. However we have prebuilt binaries which @@ -165,37 +200,37 @@ How to use this The fixes are included in svn://dev.exiv2.org/svn/team/libraries/libssh-0.7.2.tar.gz A 'vanilla' version of libssh will may require those fixes to be applied. -6 Build options - You can inspect CMake options by running grep OPTION on CMakeLists.txt in +7 Build options + You can inspect CMake options by running grep options on CMakeLists.txt in C:\cygwin64\home\rmills\gnu\exiv2\build>cd ..\trunk - C:\cygwin64\home\rmills\gnu\exiv2\trunk>grep OPTION CMakeLists.txt - 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" ON ) - OPTION( EXIV2_ENABLE_VIDEO "Build with video support" OFF ) - 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" ON ) - OPTION( EXIV2_ENABLE_BUILD_PO "Build translations files" OFF ) - OPTION( EXIV2_ENABLE_VIDEO "Build video support into library" OFF ) - OPTION( EXIV2_ENABLE_WEBREADY "Build webready support into library" OFF ) - OPTION( EXIV2_ENABLE_WIN_UNICODE "Use Unicode paths (wstring) on Windows" OFF ) - OPTION( EXIV2_ENABLE_CURL "USE Libcurl for HttpIo" OFF ) - OPTION( EXIV2_ENABLE_SSH "USE Libssh for SshIo" OFF ) - - C:\cygwin64\home\rmills\gnu\exiv2\trunk> - -7 Running the test suite + C:\cygwin64\home\rmills\gnu\github\exiv2\exiv2>grep option CMakeLists.txt + # options and their default values + option( EXIV2_ENABLE_XMP "Build with XMP metadata support" ON ) + 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_VIDEO "Build video support into library" OFF ) + option( EXIV2_ENABLE_WEBREADY "Build webready support into library" OFF ) + option( EXIV2_ENABLE_DYNAMIC_RUNTIME "Use dynamic runtime (used for static libs)" OFF ) + option( EXIV2_ENABLE_WIN_UNICODE "Use Unicode paths (wstring) on Windows" OFF ) + option( EXIV2_ENABLE_CURL "USE Libcurl for HttpIo" OFF ) + option( EXIV2_ENABLE_SSH "USE Libssh for SshIo" OFF ) + option( EXIV2_ENABLE_SSH "USE Libssh for SshIo" ON ) + option( EXIV2_BUILD_SAMPLES "Build sample applications" ON ) + option( EXIV2_BUILD_PO "Build translations files" OFF ) + option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON ) + +8 Running the test suite http://dev.exiv2.org/projects/exiv2/wiki/How_do_I_run_the_test_suite_for_Exiv2 You can run the test-suite directly from cmakeBuild.cmd with the argument --test You need cygwin's bash.exe to run the test suite. -8 Building with different versions of the support libraries +9 Building with different versions of the support libraries You can change the standard libraries. For example, to build with curl-7.39.0 1) set _CURL_=curl-7.39.0 2) add curl-7.39.0.tar.gz in your build directory @@ -204,14 +239,15 @@ How to use this 1) set _OPENSSL_=openssl-1.0.1j 2) add openssl-1.0.1j-vs2015.zip into your build directory -9 Rebuilding with VS 2005/8/10/12/13/15 32/64 +9 Rebuilding with VS 2005/8/10/12/13/15/17 32/64 The script cmakeBuildAll.cmd is provided for convenience: cmakeBuildAll.cmd --test > rebuildAll.txt To view progress, open another shell: tail -f rebuildAll.txt cmakeBuildAll.cmd takes about a hour if you don't specify --webready - 12 build+test cycles of about 5 minutes each. - With webready, 12 build+test cycles of 12 minutes = 2.5 hours + 14 build+test cycles of about 5 minutes each. Just over 1 hour. + With webready, 14 build+test cycles of 12 minutes = 3 hours Robin Mills robin@clanmills.com +Updated: 2017-09-05 diff --git a/contrib/cmake/msvc/cmakeBuild.cmd b/contrib/cmake/msvc/cmakeBuild.cmd index c44ca0d7..2b8fd4ff 100755 --- a/contrib/cmake/msvc/cmakeBuild.cmd +++ b/contrib/cmake/msvc/cmakeBuild.cmd @@ -17,16 +17,18 @@ if /I "%1" == "--zlib" set "_ZLIB_=%2"& shift if /I "%1" == "--help" call:Help && goto end if /I "%1" == "--dryrun" set "_DRYRUN_=1" -if /I "%1" == "--nosamples" set "_NOSAMPLES_=1" +if /I "%1" == "--samples" set "_SAMPLES_=1" if /I "%1" == "--pause" set "_PAUSE_=1" if /I "%1" == "--rebuild" set "_REBUILD_=1" if /I "%1" == "--silent" set "_SILENT_=1" if /I "%1" == "--static" set "_MODE_=static" -if /I "%1" == "--test" set "_TEST_=1" +if /I "%1" == "--test" (set "_TEST_=1" & set _SAMPLES_=1) if /I "%1" == "--trace" set ("_VERBOSE_=1 && echo on)" if /I "%1" == "--verbose" set "_VERBOSE_=1" if /I "%1" == "--video" set "_VIDEO_=1" if /I "%1" == "--webready" set "_WEBREADY_=1" +if /I "%1" == "--unicode" set "_UNICODE_=ON" +if /I "%1" == "--nls" set "_NLS_=ON" shift if not (%1) EQU () goto GETOPTS @@ -34,8 +36,8 @@ goto main :help call cmakeDefaults >NUL 2>NUL -echo Options: --help ^| --webready ^| --rebuild ^| --video ^| --static -echo. --silent ^| --verbose ^| --pause ^| --dryrun ^| --test ^| --trace +echo Options: --help ^| --webready ^| --rebuild ^| --video ^| --static ^| --unicode ^| --nls +echo. --silent ^| --verbose ^| --pause ^| --dryrun ^| --test ^| --samples ^| --trace echo. --exiv2 %_EXIV2_% ^| --work %_WORK_% ^| --config %_CONFIG_% ^| --generator generator echo. --zlib %_ZLIB_% ^| --expat %_EXPAT_% ^| --curl %_CURL_% ^| --libssh %_LIBSSH_% echo. --bash %_BASH_% @@ -56,7 +58,9 @@ echo.incpath = %_INCPATH_% echo.libpath = %_LIBPATH_% echo.libssh = %_LIBSSH_% echo.mode = %_MODE_% +echo.nls = %_NLS_% echo.openssl = %_OPENSSL_% +echo.unicode = %_UNICODE_% echo.work = %_WORK_% echo.test = %_TEST_% echo.video = %_VIDEO_% @@ -91,6 +95,7 @@ IF NOT EXIST "%VSINSTALLDIR%" ( GOTO error_end ) +if /I "%VSINSTALLDIR%" == "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\" set "_VS_=2017" && set "_VC_=15" if /I "%VSINSTALLDIR%" == "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\" set "_VS_=2015" && set "_VC_=14" if /I "%VSINSTALLDIR%" == "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\" set "_VS_=2013" && set "_VC_=12" if /I "%VSINSTALLDIR%" == "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\" set "_VS_=2012" && set "_VC_=11" @@ -287,12 +292,12 @@ pushd "%EXIV_B%" set ENABLE_SHARED=OFF set ENABLE_DYNAMIC=OFF ) - set BUILD_SAMPLES=ON - if DEFINED _NOSAMPLES_ set BUILD_SAMPLES=OFF + set BUILD_SAMPLES=OFF + if DEFINED _SAMPLES_ set BUILD_SAMPLES=ON - call:run cmake -G "%_GENERATOR_%" -DCMAKE_BUILD_TYPE=%_CONFIG_% %_LINK_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_% -DCMAKE_LIBRARY_PATH=%_LIBPATH_% -DCMAKE_INCLUDE_PATH=%_INCPATH_% ^ - -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_BUILD_SAMPLES=%BUILD_SAMPLES% ^ - -DEXIV2_ENABLE_WIN_UNICODE=OFF -DEXIV2_ENABLE_SHARED=%ENABLE_SHARED% ^ + call:run cmake -G "%_GENERATOR_%" -DCMAKE_BUILD_TYPE=%_CONFIG_% %_LINK_% -DCMAKE_INSTALL_PREFIX=%_INSTALL_% -DCMAKE_LIBRARY_PATH=%_LIBPATH_% -DCMAKE_INCLUDE_PATH=%_INCPATH_% ^ + -DEXIV2_ENABLE_NLS=%_NLS_% -DEXIV2_ENABLE_BUILD_SAMPLES=%BUILD_SAMPLES% ^ + -DEXIV2_ENABLE_WIN_UNICODE=%_UNICODE_% -DBUILD_SHARED_LIBS=%ENABLE_SHARED% ^ -DEXIV2_ENABLE_DYNAMIC_RUNTIME=%ENABLE_DYNAMIC% ^ %ENABLE_WEBREADY% %ENABLE_CURL% %ENABLE_LIBSSH% %ENABLE_VIDEO% ^ "%_EXIV2_%" @@ -327,12 +332,12 @@ if defined _TEST_ ( rem ----------------------------------------- rem Exit -rem end syntax: goto end +rem end syntax: GOTO end :end endlocal exit /b 0 -rem end with an error syntax: call:error_end +rem end with an error syntax: GOTO error_end :error_end endlocal exit /b 1 @@ -389,7 +394,20 @@ pushd "%LOB_B%" echo "*** warning: build errors in %LOB% ***" ) - call:run cmake --build . --config %_CONFIG_% --target install + rem --static expat fails to install on VS 2010+ + set buildLibInstallExpatStatic=0 + if /I "%_TARGET_%" == "--target expat" if /I "%_MODE_%" == "static" set buildLibInstallExpatStatic=1 + + if /I "%buildLibInstallExpatStatic%" == "1" ( + rem msvc\expat-2.1.0\lib\expat*.h => msvc\dist\2005\x64\static\Release\include + call:run copy/y "%_BUILDDIR_%\%LOB%\lib\expat*.h" "%_ONCPATH_%" + + rem msvc\work\expat-2.1.0\release\*.lib => msvc\dist\2005\x64\static\Release\lib + call:run copy/y "%_WORK_%\%LOB%\%_CONFIG_%\*.lib" "%_INSTALL_%\lib" + ) else ( + call:run cmake --build . --config %_CONFIG_% --target install + ) + IF errorlevel 1 ( echo "*** warning: install errors in %LOB% ***" ) diff --git a/contrib/cmake/msvc/cmakeDefaults.cmd b/contrib/cmake/msvc/cmakeDefaults.cmd index 8dd5aa55..ec3a9225 100755 --- a/contrib/cmake/msvc/cmakeDefaults.cmd +++ b/contrib/cmake/msvc/cmakeDefaults.cmd @@ -13,7 +13,9 @@ if NOT DEFINED _ZLIB_ SET _ZLIB_=zlib-1.2.8 if NOT DEFINED _EXPAT_ SET _EXPAT_=expat-2.1.0 if NOT DEFINED _BASH_ SET _BASH_=c:\cygwin64\bin\bash.exe if NOT DEFINED _MODE_ SET _MODE_=dll -if NOT DEFINED COPYCMD SET COPYCMD=/Y +if NOT DEFINED _UNICODE_ SET _UNICODE_=OFF +if NOT DEFINED _NLS_ SET _NLS_=OFF +if NOT DEFINED COPYCMD SET COPYCMD=/Y rem ---------- check that EXIV2 exists echo checking that %_EXIV2_% exists diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index a15da0f8..be6b8c39 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,29 +1,25 @@ -# CMake build system for exiv2 library and executables -# Copyright 2008 by Patrick Spendrin -# Copyright 2010-2012 by Gilles Caulier -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# CMakeLists.txt for i18n files -# automatically include all po files in the directory -FILE(GLOB PO_FILES *.po) - -UPDATE_TRANSLATIONS(exiv2 ${PO_FILES}) - -ADD_TRANSLATIONS(exiv2 ${PO_FILES}) +# include all po files in the directory +file(GLOB PO_FILES *.po) +update_translations(exiv2 ${PO_FILES}) +add_translations(exiv2 ${PO_FILES}) +## +# execute xgettext on every file add_custom_target( pot-update - COMMAND xgettext -d ${PACKAGE_NAME} - -s - -D ${CMAKE_CURRENT_SOURCE_DIR}/.. - -o ${PACKAGE_NAME}.pot - -p ${CMAKE_CURRENT_SOURCE_DIR}/ - --from-code=UTF-8 - --files-from=POTFILES.in - -j - --keyword=_ - --package-name=${PACKAGE_NAME} - --package-version=${PACKAGE_VERSION} - --copyright-holder=${PACKAGE_COPYRIGHT} - --msgid-bugs-address=${PACKAGE_BUGREPORT} - ) + COMMAND xgettext -d ${PACKAGE_NAME} + -s -D ${CMAKE_CURRENT_SOURCE_DIR}/.. + -o ${PACKAGE_NAME}.pot + -p ${CMAKE_CURRENT_SOURCE_DIR}/ + --from-code=UTF-8 --files-from=POTFILES.in + -j + --keyword=_ + --package-name=${PACKAGE_NAME} + --package-version=${PACKAGE_VERSION} + --copyright-holder=${PACKAGE_COPYRIGHT} + --msgid-bugs-address=${PACKAGE_BUGREPORT} +) + +# That's all Folks! +## diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 78119323..d7462a3a 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -1,41 +1,41 @@ -# CMake build system for exiv2 library and executables -# Copyright 2010-2012 Gilles Caulier -# Copyright 2008 Patrick Spendrin -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -set( SAMPLES addmoddel.cpp - convert-test.cpp - easyaccess-test.cpp - exifcomment.cpp - exifdata-test.cpp - exifdata.cpp - exifprint.cpp - exifvalue.cpp - ini-test.cpp - iotest.cpp - iptceasy.cpp - iptcprint.cpp - iptctest.cpp - key-test.cpp - largeiptc-test.cpp - mmap-test.cpp - prevtest.cpp - stringto-test.cpp - taglist.cpp - tiff-test.cpp - werror-test.cpp - write-test.cpp - write2-test.cpp - xmpparse.cpp - xmpparser-test.cpp - xmpprint.cpp - xmpsample.cpp - ) +# CMakeLists.txt for exiv2 library sample applications +set( SAMPLES + addmoddel.cpp + convert-test.cpp + easyaccess-test.cpp + exifcomment.cpp + exifdata-test.cpp + exifdata.cpp + exifprint.cpp + exifvalue.cpp + ini-test.cpp + iotest.cpp + iptceasy.cpp + iptcprint.cpp + iptctest.cpp + key-test.cpp + largeiptc-test.cpp + mmap-test.cpp + prevtest.cpp + stringto-test.cpp + taglist.cpp + tiff-test.cpp + werror-test.cpp + write-test.cpp + write2-test.cpp + xmpparse.cpp + xmpparser-test.cpp + xmpprint.cpp + xmpsample.cpp +) + +## +# build samples AND add them to the APPLICATIONS list foreach(entry ${SAMPLES}) string( REPLACE ".cpp" "" target ${entry}) add_executable( ${target} ${target}.cpp ) + list(APPEND APPLICATIONS ${target}) add_test( ${target}_test ${target} ) target_link_libraries( ${target} PRIVATE exiv2lib) install( TARGETS ${target} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -44,20 +44,23 @@ endforeach() ################################### add_executable( metacopy metacopy.cpp ../src/utils.cpp) +list(APPEND APPLICATIONS metacopy) target_link_libraries( metacopy PRIVATE exiv2lib) target_include_directories(metacopy PRIVATE ${CMAKE_SOURCE_DIR}/src) # To find utils.hpp -add_executable ( pathtest path-test.cpp ../src/utils.cpp) -set_target_properties( pathtest PROPERTIES OUTPUT_NAME path-test ) -target_link_libraries( pathtest PRIVATE exiv2lib) +add_executable( pathtest path-test.cpp ../src/utils.cpp) +list(APPEND APPLICATIONS pathtest) +set_target_properties( pathtest PROPERTIES OUTPUT_NAME path-test ) +target_link_libraries( pathtest PRIVATE exiv2lib) target_include_directories(pathtest PRIVATE ${CMAKE_SOURCE_DIR}/src) # To find utils.hpp if(NOT EXV_HAVE_TIMEGM ) target_sources(pathtest PRIVATE ../src/localtime.c) endif() -add_executable( exiv2json exiv2json.cpp Jzon.cpp) -target_link_libraries( exiv2json PRIVATE exiv2lib) +add_executable( exiv2json exiv2json.cpp Jzon.cpp) +list(APPEND APPLICATIONS exiv2json) +target_link_libraries( exiv2json PRIVATE exiv2lib) install( TARGETS metacopy pathtest exiv2json RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -66,9 +69,10 @@ if (MSVC) target_sources(metacopy PRIVATE ../src/getopt_win32.c) endif() -if( EXIV2_ENABLE_XMP ) +if( EXPAT_FOUND ) add_executable( geotag geotag.cpp) - target_link_libraries( geotag PRIVATE exiv2lib ${ZLIB_LIBRARIES}) + list(APPEND APPLICATIONS geotag) + target_link_libraries( geotag PRIVATE exiv2lib ${EXPAT_LIBRARIES}) install( TARGETS geotag RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -76,17 +80,26 @@ endif() # connection test application add_executable(conntest conntest.cpp) target_link_libraries(conntest PRIVATE exiv2lib) - -# ****************************************************************************** -# exifprint application -# ADD_EXECUTABLE( exifprint exifprint.cpp ) -# target_link_libraries( exifprint exiv2lib ) +list(APPEND APPLICATIONS conntest) # ****************************************************************************** # remotetest application add_executable(remotetest remotetest.cpp) target_link_libraries(remotetest exiv2lib) +list(APPEND APPLICATIONS remotetest) + +# ****************************************************************************** +# set compiler -DEXV_HAVE_DLL when linking exiv2 dll +foreach(application ${APPLICATIONS}) + if ( BUILD_SHARED_LIBS ) + target_compile_definitions(${application} PRIVATE EXV_HAVE_DLL ) + endif() +endforeach() + # ****************************************************************************** # Man page install( FILES exiv2samples.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 ) + +# That's all Folks! +## diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c5d7247..9984a891 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,145 +1,19 @@ -# CMake build system for exiv2 library and executables -# Copyright 2015- Daniel Kaneider -# Copyright 2010-2012 Gilles Caulier -# Copyright 2008 Patrick Spendrin - -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -# Private headers which are only needed for the library itself -set( LIBEXIV2_PRIVATE_HDR canonmn_int.hpp - casiomn_int.hpp - cr2image_int.hpp - crwimage_int.hpp - fujimn_int.hpp - makernote_int.hpp - minoltamn_int.hpp - nikonmn_int.hpp - olympusmn_int.hpp - orfimage_int.hpp - panasonicmn_int.hpp - pentaxmn_int.hpp - pngchunk_int.hpp - rcsid_int.hpp - rw2image_int.hpp - samsungmn_int.hpp - sigmamn_int.hpp - sonymn_int.hpp - tags_int.hpp - tiffcomposite_int.hpp - tifffwd_int.hpp - tiffimage_int.hpp - tiffvisitor_int.hpp - ) - -# Add standalone C++ header files to this list -set( LIBEXIV2_HDR ../include/exiv2/asfvideo.hpp - ../include/exiv2/basicio.hpp - ../include/exiv2/bmpimage.hpp - ../include/exiv2/config.h - ../include/exiv2/convert.hpp - ../include/exiv2/cr2image.hpp - ../include/exiv2/crwimage.hpp - ../include/exiv2/datasets.hpp - ../include/exiv2/easyaccess.hpp - ../include/exiv2/epsimage.hpp - ../include/exiv2/error.hpp - ../include/exiv2/exif.hpp - ../include/exiv2/exiv2.hpp - ../include/exiv2/futils.hpp - ../include/exiv2/gifimage.hpp - ../include/exiv2/http.hpp - ../include/exiv2/image.hpp - ../include/exiv2/ini.hpp - ../include/exiv2/iptc.hpp - ../include/exiv2/jp2image.hpp - ../include/exiv2/jpgimage.hpp - ../include/exiv2/matroskavideo.hpp - ../include/exiv2/metadatum.hpp - ../include/exiv2/mrwimage.hpp - ../include/exiv2/orfimage.hpp - ../include/exiv2/pgfimage.hpp - ../include/exiv2/preview.hpp - ../include/exiv2/properties.hpp - ../include/exiv2/psdimage.hpp - ../include/exiv2/quicktimevideo.hpp - ../include/exiv2/rafimage.hpp - ../include/exiv2/riffvideo.hpp - ../include/exiv2/rwlock.hpp - ../include/exiv2/rw2image.hpp - ../include/exiv2/tags.hpp - ../include/exiv2/tgaimage.hpp - ../include/exiv2/tiffimage.hpp - ../include/exiv2/types.hpp - ../include/exiv2/utilsvideo.hpp - ../include/exiv2/value.hpp - ../include/exiv2/version.hpp - ../include/exiv2/webpimage.hpp - ../include/exiv2/xmp_exiv2.hpp - ../include/exiv2/xmpsidecar.hpp - ../include/exiv2/utilsvideo.hpp - ${CMAKE_BINARY_DIR}/exv_conf.h - ) - -# Add library C++ source files to this list -set( LIBEXIV2_SRC asfvideo.cpp - basicio.cpp - bmpimage.cpp - canonmn.cpp - casiomn.cpp - convert.cpp - cr2image.cpp - crwedit.cpp - crwimage.cpp - datasets.cpp - easyaccess.cpp - epsimage.cpp - error.cpp - exif.cpp - futils.cpp - fujimn.cpp - gifimage.cpp - http.cpp - image.cpp - ini.cpp - iptc.cpp - jp2image.cpp - jpgimage.cpp - makernote.cpp - matroskavideo.cpp - metadatum.cpp - minoltamn.cpp - mrwimage.cpp - nikonmn.cpp - olympusmn.cpp - orfimage.cpp - panasonicmn.cpp - pentaxmn.cpp - pgfimage.cpp - preview.cpp - properties.cpp - psdimage.cpp - quicktimevideo.cpp - rafimage.cpp - riffvideo.cpp - rw2image.cpp - samsungmn.cpp - sigmamn.cpp - sonymn.cpp - tags.cpp - tgaimage.cpp - tiffcomposite.cpp - tiffimage.cpp - tiffvisitor.cpp - types.cpp - utilsvideo.cpp - value.cpp - version.cpp - webpimage.cpp - xmp.cpp - xmpsidecar.cpp - utilsvideo.cpp - ) +# CMakeLists.txt for exiv2 library and command-line program + +# list of public C++ include files +file(GLOB LIBEXIV2_HDR ../include/exiv2/*.hpp) +list(APPEND LIBEXIV2_HDR ${CMAKE_BINARY_DIR}/exv_conf.h) + +# list of internal include files only required to build the library +file(GLOB LIBEXIV2_PRIVATE_HDR *_int.hpp) + +# list of library C++ source files +file(GLOB LIBEXIV2_SRC *.cpp) +# remove files which are not part of the library +file(GLOB LIBEXIV2_SRC_NOT actions.cpp exiv2.cpp *test.cpp crwparse.cpp mrwthumb.cpp xmpdump.cpp) +foreach(entry ${LIBEXIV2_SRC_NOT}) + list(REMOVE_ITEM LIBEXIV2_SRC ${entry}) +endforeach() if( EXIV2_ENABLE_WEBREADY ) if( EXIV2_ENABLE_CURL) @@ -166,20 +40,24 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) # exiv2lib library if( EXIV2_ENABLE_XMP AND NOT EXIV2_ENABLE_LIBXMP ) - add_library( exiv2lib ${STATIC_FLAG} ${LIBEXIV2_SRC} ${LIBEXIV2_HDR} ${LIBEXIV2_PRIVATE_HDR} $) - target_link_libraries(exiv2lib PUBLIC ${EXPAT_LIBRARIES}) + add_library( exiv2lib ${LIBEXIV2_SRC} ${LIBEXIV2_HDR} ${LIBEXIV2_PRIVATE_HDR} $) else() - add_library( exiv2lib ${STATIC_FLAG} ${LIBEXIV2_SRC} ${LIBEXIV2_HDR} ${LIBEXIV2_PRIVATE_HDR}) + add_library( exiv2lib ${LIBEXIV2_SRC} ${LIBEXIV2_HDR} ${LIBEXIV2_PRIVATE_HDR}) +endif() +if ( BUILD_SHARED_LIBS ) + target_link_libraries(exiv2lib PUBLIC ${EXPAT_LIBRARIES}) endif() set_target_properties( exiv2lib PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} - DEFINE_SYMBOL EXV_BUILDING_LIB OUTPUT_NAME exiv2 ) -target_compile_definitions(exiv2lib PRIVATE EXV_LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}" ) +target_compile_definitions(exiv2lib PRIVATE EXV_LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}" EXV_BUILDING_LIB ) +if ( BUILD_SHARED_LIBS ) + target_compile_definitions(exiv2lib PRIVATE EXV_HAVE_DLL ) +endif() if ( UNIX AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" ) set (FREEBSD 1) @@ -206,11 +84,10 @@ endif() if ( MSVC ) 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() + if( EXIV2_ENABLE_PNG ) 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} ) @@ -218,7 +95,7 @@ if ( MSVC ) else() # TODO: Check if this is really needed. if ( UNIX AND NOT FREEBSD ) - target_link_libraries( exiv2lib PRIVATE dl) + target_link_libraries( exiv2lib PRIVATE dl) # -ldl = dynamic loader used by src/version.cpp endif() target_link_libraries( exiv2lib PRIVATE Threads::Threads) target_link_libraries( exiv2lib PUBLIC ${CURL_LIBRARIES} ${SSH_LIBRARIES}) @@ -256,18 +133,22 @@ install(FILES ${LIBEXIV2_HDR} # ****************************************************************************** # exiv2 application -set( EXIV2_SRC exiv2.cpp - exiv2app.hpp - actions.cpp - actions.hpp - utils.cpp - utils.hpp +set( EXIV2_SRC + exiv2.cpp + exiv2app.hpp + actions.cpp + actions.hpp + utils.cpp + utils.hpp ) -if(EXIV2_ENABLE_TOOLS) +if(EXIV2_BUILD_EXIV2_COMMAND) add_executable( exiv2 ${EXIV2_SRC} ) target_compile_definitions(exiv2 PRIVATE EXV_LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}" ) target_link_libraries( exiv2 PRIVATE exiv2lib ) + if ( BUILD_SHARED_LIBS ) + target_compile_definitions(exiv2 PRIVATE EXV_HAVE_DLL ) + endif() install(TARGETS exiv2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -288,3 +169,6 @@ endif() # ****************************************************************************** # Man page install( FILES exiv2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 ) + +# That's all Folks! +## diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt index 68a8eab3..48258bfe 100644 --- a/xmpsdk/CMakeLists.txt +++ b/xmpsdk/CMakeLists.txt @@ -1,36 +1,7 @@ -# CMake build system for exiv2 library and executables -# Copyright 2010-2012 Gilles Caulier -# Copyright 2008 Patrick Spendrin +# CMakeLists.txt exiv2/xmpsdk -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -set(XMPSRC src/ExpatAdapter.cpp - src/MD5.cpp - src/ParseRDF.cpp - src/UnicodeConversions.cpp - src/WXMPIterator.cpp - src/WXMPMeta.cpp - src/WXMPUtils.cpp - src/XML_Node.cpp - src/XMPCore_Impl.cpp - src/XMPIterator.cpp - src/XMPMeta-GetSet.cpp - src/XMPMeta-Parse.cpp - src/XMPMeta-Serialize.cpp - src/XMPMeta.cpp - src/XMPUtils-FileInfo.cpp - src/XMPUtils.cpp - include/MD5.h - include/TXMPIterator.hpp - include/TXMPMeta.hpp - include/TXMPUtils.hpp - include/XMP_Const.h - include/XMP_Environment.h - include/XMP.incl_cpp - include/XMPSDK.hpp - include/XMP_Version.h -) +# list files to be use to build XMPsdk +file(GLOB XMPSRC src/*.cpp include/*.h include/*.hpp) foreach(_currentfile ${XMPSRC}) if(UNIX AND NOT CYGWIN) @@ -38,7 +9,7 @@ foreach(_currentfile ${XMPSRC}) endif() endforeach() -# We generate a CMake OBJECT LIBRARY (a bunch of object files) +# CMake OBJECT LIBRARY (collection of object files) add_library( xmp_object OBJECT ${XMPSRC} ) target_include_directories(xmp_object PRIVATE ${EXPAT_INCLUDE_DIR}) @@ -67,3 +38,6 @@ if( EXIV2_ENABLE_LIBXMP ) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif() + +# That's all Folks! +##