Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More cmake cleanup #28

Merged
merged 18 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
CMAKE_MINIMUM_REQUIRED( VERSION 3.1.0 )
PROJECT( exiv2 )

if( POLICY CMP0042 )
cmake_policy(SET CMP0042 NEW) # enable MACOSX_RPATH support
else()
SET(CMAKE_MACOSX_RPATH 1)
endif()
set(CMAKE_MACOSX_RPATH 1)

SET( PACKAGE_COPYRIGHT "Andreas Huggel" )
SET( PACKAGE_BUGREPORT "http://github.com/exiv2/exiv2" )
Expand Down Expand Up @@ -51,8 +47,8 @@ ENDIF()

include(config/findDependencies.cmake)

IF( MINGW OR UNIX )
IF ( CMAKE_CXX_COMPILER STREQUAL "g++" OR CMAKE_C_COMPILER STREQUAL "gcc" )
if( MINGW OR UNIX )
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
ADD_DEFINITIONS(-Wall
-Wcast-align
-Wpointer-arith
Expand All @@ -63,15 +59,7 @@ IF( MINGW OR UNIX )
)
ENDIF()

execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE COMPILER_VERSION)
string(REGEX MATCHALL "[A-Z|a-z\+]+" GCC_COMPILER_COMPONENTS ${COMPILER_VERSION})
list(GET GCC_COMPILER_COMPONENTS 0 COMPILER)

execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)

IF ( CYGWIN OR ( ${GCC_MAJOR} GREATER 5 ))
IF ( CYGWIN OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0))
ADD_DEFINITIONS( -std=gnu++98 ) # to support snprintf
ELSE()
ADD_DEFINITIONS( -std=c++98 )
Expand All @@ -84,21 +72,13 @@ IF( EXIV2_ENABLE_COMMERCIAL )
SET (EXIV2_ENABLE_NLS OFF)
ENDIF()

# binary as first, since it workarounds old VS solution compatibility problems
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/ ${CMAKE_SOURCE_DIR}/include/ ${CMAKE_SOURCE_DIR}/include/exiv2/)

if( MSVC )
# cmake_policy(SET CMP0008)
ADD_DEFINITIONS(-DPSAPI_VERSION=1) # to be compatible with <= WinVista (#905)
set(CMAKE_DEBUG_POSTFIX "d")
endif( MSVC )

IF( EXIV2_ENABLE_XMP )
SET( HAVE_XMP_TOOLKIT ON )
SET( XMPLIB "do" )
IF (NOT MINGW)
set(THREADS_PREFER_PTHREAD_FLAG ON)
ENDIF()
ENDIF( EXIV2_ENABLE_XMP )

include( config/generateConfigFile.cmake )
Expand Down Expand Up @@ -138,5 +118,3 @@ IF( MINGW OR UNIX OR APPLE)
ENDIF()

INCLUDE( config/printSummary.cmake )
# That's all Folks!
##
5 changes: 4 additions & 1 deletion WORK-IN-PROGRESS
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ For sure, Adobe's code is being built with MacOSX10.8.sdk and -std=c++11
-o CMakeFiles/XMPCoreStatic.dir/Users/rmills/gnu/github/exiv2/xmpsdk/Adobe/XMP-Toolkit-SDK-CC201607/XMPCore/source/XMPMeta-GetSet.cpp.o
-c /Users/rmills/gnu/github/exiv2/xmpsdk/Adobe/XMP-Toolkit-SDK-CC201607/XMPCore/source/XMPMeta-GetSet.cpp


Compiler options used to build DumpFile sample Application
-----------------------------------------------------------

Expand Down Expand Up @@ -352,3 +351,7 @@ Linker Options used to link DumpFile
/Users/rmills/gnu/github/exiv2/xmpsdk/Adobe/XMP-Toolkit-SDK-CC201607/samples/build/cmake/DumpFile/build_x64/XMP_Samples_64.build/Release/DumpFile.build/Objects-normal/x86_64/DumpFile_dependency_info.dat
-o /Users/rmills/gnu/github/exiv2/xmpsdk/Adobe/XMP-Toolkit-SDK-CC201607/samples/target/macintosh/intel_64/Release/DumpFile

Features to Add to the CMake code
-----------------------------------------------------------------------------------
* Auto usage of ccache on Linux and Mac.
* Remove the trick to compile the documentation using the configure script. Native documentation generation on CMake.
2 changes: 0 additions & 2 deletions config/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ if( EXIV2_ENABLE_WEBREADY )
set( ENABLE_WEBREADY 1 )
if( EXIV2_ENABLE_CURL )
find_package( CURL REQUIRED)
include_directories( ${CURL_INCLUDE_DIR} )
endif()

if( EXIV2_ENABLE_SSH )
find_package( SSH REQUIRED)
include_directories( ${SSH_INCLUDE_DIR} )
endif( EXIV2_ENABLE_SSH )
endif( EXIV2_ENABLE_WEBREADY )

Expand Down
3 changes: 2 additions & 1 deletion config/printSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ macro( OptionOutput _outputstring )
message( STATUS "${_outputstring}${_var}" )
endmacro( OptionOutput _outputstring )

message(STATUS Compiler: ${COMPILER} " Major:" ${GCC_MAJOR})
message( STATUS "Compiler info: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) ; version: ${CMAKE_CXX_COMPILER_VERSION}")

message( STATUS "------------------------------------------------------------------" )
message( STATUS "${PACKAGE_STRING} configure results <${PACKAGE_URL}>" )
OptionOutput( "Building PNG support: " EXIV2_ENABLE_PNG AND ZLIB_FOUND )
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/exiv2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#include "exiv2/types.hpp"
#include "exiv2/value.hpp"
#include "exiv2/version.hpp"
#include "exiv2/xmp.hpp"
#include "exiv2/xmp_exiv2.hpp"
#include "exiv2/xmpsidecar.hpp"

#endif // #ifndef EXIV2_HPP_
1 change: 0 additions & 1 deletion include/exiv2/webpimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
// included header files
#include "exif.hpp"
#include "image.hpp"
#include "tags_int.hpp"

// *****************************************************************************
// namespace extensions
Expand Down
87 changes: 47 additions & 40 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if ( NOT MSVC )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()

include_directories("${CMAKE_SOURCE_DIR}/include" "${CMAKE_SOURCE_DIR}/src")

SET( SAMPLES addmoddel.cpp
convert-test.cpp
easyaccess-test.cpp
Expand Down Expand Up @@ -44,51 +42,60 @@ SET( SAMPLES addmoddel.cpp
include(../CMake_msvc.txt)
msvc_runtime_configure(${EXIV2_ENABLE_SHARED} ${EXIV2_ENABLE_DYNAMIC_RUNTIME})

FOREACH(entry ${SAMPLES})
STRING( REPLACE ".cpp" "" target ${entry})
ADD_EXECUTABLE( ${target} ${target}.cpp )
ADD_TEST( ${target}_test ${target} )
TARGET_LINK_LIBRARIES( ${target} PRIVATE exiv2lib ${CMAKE_THREAD_LIBS_INIT})
INSTALL( TARGETS ${target} RUNTIME DESTINATION bin)
ENDFOREACH(entry ${SAMPLES})
foreach(entry ${SAMPLES})
string( REPLACE ".cpp" "" target ${entry})
add_executable( ${target} ${target}.cpp )
add_test( ${target}_test ${target} )
target_link_libraries( ${target} PRIVATE exiv2lib)
install( TARGETS ${target} RUNTIME DESTINATION bin)
endforeach()

###################################
# metacopy/path-test sample applications require utils.cpp support
IF( MSVC )
SET( PATHTEST_SRC ${PATHTEST_SRC} ../src/getopt_win32.c )
SET( MC_SRC ${MC_SRC} ../src/getopt_win32.c )
ENDIF( MSVC )

SET( MC_SRC ${MC_SRC} metacopy.cpp ../src/utils.cpp )
ADD_EXECUTABLE( metacopy ${MC_SRC} )
TARGET_LINK_LIBRARIES( metacopy PRIVATE exiv2lib ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
INSTALL( TARGETS metacopy RUNTIME DESTINATION bin)

SET ( PATHTEST_SRC ${PATHTEST_SRC} path-test.cpp ../src/utils.cpp )
ADD_EXECUTABLE ( pathtest ${PATHTEST_SRC} )
SET_TARGET_PROPERTIES( pathtest PROPERTIES OUTPUT_NAME path-test )
TARGET_LINK_LIBRARIES( pathtest PRIVATE exiv2lib ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
INSTALL ( TARGETS pathtest RUNTIME DESTINATION bin)

SET( EXIV2JSON_SRC exiv2json.cpp Jzon.cpp )
ADD_EXECUTABLE( exiv2json ${EXIV2JSON_SRC} )
SET_TARGET_PROPERTIES( exiv2json PROPERTIES OUTPUT_NAME exiv2json )
TARGET_LINK_LIBRARIES( exiv2json PRIVATE exiv2lib ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
INSTALL( TARGETS exiv2json RUNTIME DESTINATION bin)

add_executable( metacopy metacopy.cpp ../src/utils.cpp)
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)
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)

install( TARGETS metacopy pathtest exiv2json RUNTIME DESTINATION bin)

if (MSVC)
target_sources(pathtest PRIVATE ../src/getopt_win32.c)
target_sources(metacopy PRIVATE ../src/getopt_win32.c)
endif()

if( EXIV2_ENABLE_LIBXMP )
SET( GEOTAG_SRC geotag.cpp )
ADD_EXECUTABLE( geotag ${GEOTAG_SRC} )
SET_TARGET_PROPERTIES( geotag PROPERTIES OUTPUT_NAME geotag )
TARGET_LINK_LIBRARIES( geotag PRIVATE exiv2lib ${ZLIB_LIBRARIES})
INSTALL( TARGETS geotag RUNTIME DESTINATION bin)
add_executable( geotag geotag.cpp)
target_link_libraries( geotag PRIVATE exiv2lib ${ZLIB_LIBRARIES})
install( TARGETS geotag RUNTIME DESTINATION bin)
endif()

# ******************************************************************************
# Man page
INSTALL( FILES exiv2samples.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
# connection test application
add_executable(conntest conntest.cpp)
target_link_libraries(conntest PRIVATE exiv2lib)

# That's all Folks!
##
# ******************************************************************************
# exifprint application
# ADD_EXECUTABLE( exifprint exifprint.cpp )
# TARGET_LINK_LIBRARIES( exifprint exiv2lib )

# ******************************************************************************
# remotetest application
add_executable(remotetest remotetest.cpp)
target_link_libraries(remotetest exiv2lib)

# ******************************************************************************
# Man page
INSTALL( FILES exiv2samples.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
Loading