Project

General

Profile

Bug #1164 » CMakeLists.txt

Quick and dirty modification of the flags - Nicolas THOMASSON, 02 Mar 2016 13:35

 
1
# CMake build system for exiv2 library and executables
2
# Copyright 2012-     Robin Mills      <robin@clanmills.com>
3
# Copyright 2010-2012 Gilles Caulier   <caulier dot gilles at gmail dot com>
4
# Copyright 2008      Patrick Spendrin <ps_ml at gmx dot de>
5

    
6
# Redistribution and use is allowed according to the terms of the BSD license.
7
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
8

    
9
##
10
# Running cmake in a tree in which we have run ./configure ; make
11
# creates include/exiv2/exv_conf.h which conflicts with cmake's own exv_conf.h
12
# This causes incorrect compilation and linking errors.
13
#
14
# It's OK to delete this as it will be recreated on demand by <exiv2-dir>/Makefile
15
if( EXISTS "${CMAKE_SOURCE_DIR}/include/exiv2/exv_conf.h"  )
16
    file(REMOVE "${CMAKE_SOURCE_DIR}/include/exiv2/exv_conf.h")
17
endif()
18
##
19

    
20
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
21
PROJECT( exiv2 )
22

    
23
if( POLICY CMP0042 )
24
    cmake_policy(SET CMP0042 NEW) # enable MACOSX_RPATH support
25
else()
26
    SET(CMAKE_MACOSX_RPATH 1)
27
endif()
28
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
29

    
30

    
31
SET( PACKAGE_COPYRIGHT      "Andreas Huggel" )
32
SET( PACKAGE_BUGREPORT      "ahuggel@gmx.net" )
33
SET( PACKAGE                "exiv2" )
34
SET( PACKAGE_NAME           "exiv2" )
35
SET( PACKAGE_STRING         "exiv2 0.25" )
36
SET( PACKAGE_TARNAME        "exiv2" )
37
SET( PACKAGE_VERSION        "0.25" )
38
SET( PACKAGE_URL            "http://www.exiv2.org" )
39
SET( GENERIC_LIB_VERSION    "14.0.0" )
40
SET( GENERIC_LIB_SOVERSION  "14" )
41

    
42
# options and their default values
43
OPTION( EXIV2_ENABLE_SHARED        "Build exiv2 as a shared library (dll)"                 ON  )
44
OPTION( EXIV2_ENABLE_XMP           "Build with XMP metadata support"                       ON  )
45
OPTION( EXIV2_ENABLE_LIBXMP        "Build a static convenience Library for XMP"            ON  )
46
OPTION( EXIV2_ENABLE_VIDEO         "Build with video support"                              OFF )
47
OPTION( EXIV2_ENABLE_PNG           "Build with png support (requires libz)"                ON  )
48
OPTION( EXIV2_ENABLE_NLS           "Build native language support (requires gettext)"      ON  )
49
OPTION( EXIV2_ENABLE_PRINTUCS2     "Build with Printucs2"                                  ON  )
50
OPTION( EXIV2_ENABLE_LENSDATA      "Build including lens data"                             ON  )
51
OPTION( EXIV2_ENABLE_COMMERCIAL    "Build with the EXV_COMMERCIAL_VERSION symbol set"      OFF )
52
OPTION( EXIV2_ENABLE_BUILD_SAMPLES "Build the unit tests"                                  ON  )
53
OPTION( EXIV2_ENABLE_BUILD_PO      "Build translations files"                              OFF )
54
OPTION( EXIV2_ENABLE_VIDEO         "Build video support into library"                      OFF )
55
OPTION( EXIV2_ENABLE_WEBREADY      "Build webready support into library"                   OFF )
56
OPTION( EXIV2_ENABLE_CURL          "USE Libcurl for HttpIo"                                ON  )
57
OPTION( EXIV2_ENABLE_SSH           "USE Libssh for SshIo"                                  ON  )
58

    
59
IF( MINGW OR UNIX )
60
    IF ( CMAKE_CXX_COMPILER STREQUAL "g++" OR CMAKE_C_COMPILER STREQUAL "gcc" )
61
        ADD_DEFINITIONS(-Wall
62
                    -Wcast-align
63
                    -Wpointer-arith
64
                    -Wformat-security
65
                    -Wmissing-format-attribute
66
                    -Woverloaded-virtual
67
                    -W
68
		    -fnon-call-exceptions
69
                   )
70
    ENDIF()
71
ENDIF( MINGW OR UNIX )
72

    
73
        ADD_DEFINITIONS(-Wall
74
                    -Wcast-align
75
                    -Wpointer-arith
76
                    -Wformat-security
77
                    -Wmissing-format-attribute
78
                    -Woverloaded-virtual
79
                    -W
80
		    -fnon-call-exceptions
81
                   )
82
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/ ${CMAKE_SOURCE_DIR}/include/  ${CMAKE_SOURCE_DIR}/include/exiv2/)
83

    
84
if( MSVC )
85

    
86
    # cmake_policy(SET CMP0008)
87

    
88
    include(CMake_msvc.txt)
89
    msvc_runtime_report()
90
    msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
91
    msvc_runtime_report()
92

    
93
    ADD_DEFINITIONS(-DPSAPI_VERSION=1) # to be compatible with <= WinVista (#905)
94

    
95
    set(E expat-2.1.0)
96
    set(Z zlib-1.2.7)
97
    set(C curl-7.39.0)
98
    set(C libssh-0.5.5)
99

    
100
    if( NOT IS_DIRECTORY ./../${E} )
101
        set(OUT_OF_SOURCE 1)
102
    endif()
103

    
104
    # link dependent libraries
105
    FIND_PACKAGE(EXPAT QUIET)
106
    if ( NOT EXPAT_LIBRARY  )
107
        set(EXPAT_LIBRARY      ${CMAKE_SOURCE_DIR}/../${E}/$(ConfigurationName)/expat)
108
        set(EXPAT_INCLUDE_DIR  ${CMAKE_SOURCE_DIR}/../${E}/lib)
109
        include_directories( ${EXPAT_INCLUDE_DIR} msvc64\\include src\\include)
110
    endif()
111

    
112
    FIND_PACKAGE(CURL)
113
    if ( NOT CURL_FOUND )
114
        set(CURL_LIBRARY       ${CMAKE_SOURCE_DIR}/../${C}/$(ConfigurationName)/curl)
115
        set(CURL_INCLUDE_DIR   ${CMAKE_SOURCE_DIR}/../${C})
116
        include_directories( ${CURL_INCLUDE_DIR})
117
    endif()
118

    
119
    # FIND_PACKAGE(SSH)
120
    if ( NOT SSH_FOUND )
121
        set(SSH_LIBRARY       ${CMAKE_SOURCE_DIR}/../${C}/$(ConfigurationName)/ssh)
122
        set(SSH_INCLUDE_DIR   ${CMAKE_SOURCE_DIR}/../${C})
123
        include_directories( ${SSH_INCLUDE_DIR})
124
    endif()
125

    
126
    FIND_PACKAGE(ZLIB QUIET)
127
    if ( NOT ZLIB_FOUND )
128
        set(ZLIB_LIBRARY       ${CMAKE_SOURCE_DIR}/../${Z}/$(ConfigurationName)/zlib)
129
        set(ZLIB_INCLUDE_DIR   ${CMAKE_SOURCE_DIR}/../${Z})
130
    endif()
131
    include_directories(${ZLIB_INCLUDE_DIR})
132

    
133
    if ( EXIV2_ENABLE_SHARED )
134
        add_library(${E} SHARED IMPORTED)
135
        add_library(${Z} SHARED IMPORTED)
136
    endif()
137

    
138
    ##
139
    # Set the output directory
140
    # x64/Win32
141
    if( CMAKE_SIZEOF_VOID_P MATCHES 8 )
142
        SET( P_DIR x64)
143
    else()
144
        set( P_DIR Win32 )
145
    endif()
146

    
147
    # DLL/static build
148
    if( EXIV2_ENABLE_SHARED )
149
        set( T_DIR Dynamic )
150
    else()
151
        set( T_DIR Static)
152
    endif()
153

    
154
    set(B_DIR ${PROJECT_BINARY_DIR}/bin/${P_DIR}/${T_DIR})
155
    set(CMAKE_CURRENT_BINARY_DIR ${B_DIR})
156
    set(EXECUTABLE_OUTPUT_PATH   ${B_DIR})
157
    set(LIBRARY_OUTPUT_PATH      ${B_DIR})
158
endif( MSVC )
159

    
160
IF( EXIV2_ENABLE_XMP )
161
    SET( HAVE_XMP_TOOLKIT ON )
162
    SET( XMPLIB "do" )
163
ENDIF( EXIV2_ENABLE_XMP )
164

    
165
INCLUDE( config/CMakeChecks.txt )
166

    
167
SET( INSTALL_TARGET_STANDARD_ARGS
168
     RUNTIME DESTINATION bin
169
     LIBRARY DESTINATION lib
170
     ARCHIVE DESTINATION lib
171
)
172
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
173

    
174
##
175
# add sources from XMPSDK directory
176
# this needs to be done here to be visible to xmpsdk, src and sample sub directories
177
SET( XMPSRC ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ExpatAdapter.cpp
178
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/MD5.cpp
179
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ParseRDF.cpp
180
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/UnicodeConversions.cpp
181
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPIterator.cpp
182
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPMeta.cpp
183
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPUtils.cpp
184
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XML_Node.cpp
185
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPCore_Impl.cpp
186
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPIterator.cpp
187
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-GetSet.cpp
188
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Parse.cpp
189
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Serialize.cpp
190
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta.cpp
191
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils-FileInfo.cpp
192
            ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils.cpp
193
)
194

    
195
# the following lines need to be added to circumvent the error in xmpsdk\src\MD5.h
196
IF( ${EXV_HAVE_STDINT_H} )
197
    ADD_DEFINITIONS( -DEXV_HAVE_STDINT_H )
198
ENDIF( ${EXV_HAVE_STDINT_H} )
199

    
200
FIND_PACKAGE(Subversion QUIET)
201
SET(SVN_REVISION "0")
202
IF(SUBVERSION_FOUND)
203
    IF(EXISTS "${CMAKE_SOURCE_DIR}/.svn")
204
        Subversion_WC_INFO(${PROJECT_SOURCE_DIR} svnExiv2)
205
        SET(SVN_REVISION "${svnExiv2_WC_REVISION}")
206
    ENDIF()
207
ENDIF()
208
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/src/svn_version.h.in
209
                ${CMAKE_CURRENT_SOURCE_DIR}/src/svn_version.h @ONLY)
210
MESSAGE(STATUS  "SVN version:  ${SVN_REVISION}")
211

    
212
IF( NOT MSVC )
213
  # Issue #722: out of source builds compiled against standard include files such as /usr/local/lib/include/exiv2
214
  # do not use CREATE_SYMLINK or CMAKE_CAN_SYMLINK as they don't work on CYGWIN
215
  EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}           COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/src exiv2)
216

    
217
  IF( EXIV2_ENABLE_BUILD_SAMPLES )
218
    EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/samples COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/src exiv2)
219
  ENDIF( EXIV2_ENABLE_BUILD_SAMPLES )
220

    
221
  IF( EXIV2_ENABLE_BUILD_PO )
222
    EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/po      COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/src exiv2)
223
  ENDIF( EXIV2_ENABLE_BUILD_PO )
224
ENDIF()
225

    
226
ADD_SUBDIRECTORY( xmpsdk )
227
ADD_SUBDIRECTORY( src )
228

    
229
IF( EXIV2_ENABLE_BUILD_SAMPLES )
230
    ADD_SUBDIRECTORY( samples )
231
ENDIF( EXIV2_ENABLE_BUILD_SAMPLES )
232

    
233
IF( EXIV2_ENABLE_BUILD_PO )
234
    ADD_SUBDIRECTORY( po )
235
ENDIF( EXIV2_ENABLE_BUILD_PO )
236

    
237
##
238
# tests
239
ADD_CUSTOM_TARGET(tests  COMMAND make test   "EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin"  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test/" )
240
ADD_CUSTOM_TARGET(teste  COMMAND make teste  "EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin"  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test/" )
241
ADD_CUSTOM_TARGET(testv  COMMAND make testv  "EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin"  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test/" )
242
ADD_CUSTOM_TARGET(testvw COMMAND make testvw "EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin"  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test/" )
243
ADD_CUSTOM_TARGET(testx  COMMAND make testx  "EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin"  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test/" )
244

    
245
##
246
# http://dev.exiv2.org/boards/3/topics/1364
247
# effectively does a make doc on the root directory
248
# has to run 'make config' and './configure'
249
# and copy bin/taglist to <exiv2dir>/bin/taglist for use by 'make doc'
250
IF( MINGW OR UNIX OR APPLE)
251
  ADD_CUSTOM_TARGET(doc
252
    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/doc"
253
    COMMAND chmod +x ./cmake_doc.sh
254
    COMMAND ./cmake_doc.sh "${CMAKE_BINARY_DIR}"
255
  )
256
ENDIF()
257

    
258
##
259
# support for test suite TODO: fixup for MSVC and think a bit more before deploying this
260
# ENABLE_TESTING()
261
# INCLUDE(Dart)
262
# ADD_TEST(tests bash -c "cd ${CMAKE_SOURCE_DIR}/test/ ; make EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin" )
263

    
264
# That's all Folks!
265
##
(3-3/3)