Skip to content

Commit

Permalink
Many changes to CMakeLists.txt and cmakeBuild.cmd to support unicode,…
Browse files Browse the repository at this point in the history
… static linking, passing shared library build flags.
  • Loading branch information
clanmills committed Sep 5, 2017
1 parent 68effb1 commit 60d436c
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 327 deletions.
25 changes: 13 additions & 12 deletions CMakeLists.txt
@@ -1,10 +1,4 @@
# CMake build system for exiv2 library and executables
# Copyright 2015- Daniel Kaneider <danielkaneider@users.sf.net>
# 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.
# CMakeLists.txt for exiv2 library

cmake_minimum_required( VERSION 3.1.0 )
project( exiv2 )
Expand All @@ -30,16 +24,13 @@ 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 )
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_DYNAMIC_RUNTIME "Use dynamic runtime (used for static libs)" OFF )
Expand All @@ -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)
Expand All @@ -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 )
Expand Down Expand Up @@ -106,3 +104,6 @@ if( MINGW OR UNIX OR APPLE)
endif()

include( config/printSummary.cmake )

# That's all Folks!
##
4 changes: 2 additions & 2 deletions config/compilerFlags.cmake
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
9 changes: 5 additions & 4 deletions config/printSummary.cmake
Expand Up @@ -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 )
Expand All @@ -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 "------------------------------------------------------------------" )
102 changes: 69 additions & 33 deletions 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
Expand All @@ -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
-----------------------------------
Expand Down Expand Up @@ -39,7 +39,7 @@ How to use this
cd <exiv2dir>\contrib\cmake\cmake
cmd.exe
vcvars 2015 64
cmakeBuild --help # display syntax and options
cmakeBuild --help # display syntax and options
cmakeBuild --rebuild
....
exit
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <exiv2dir>
7 Build options
You can inspect CMake options by running grep options on CMakeLists.txt in <exiv2dir>
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
Expand All @@ -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

0 comments on commit 60d436c

Please sign in to comment.