diff --git a/CMakeLists.txt b/CMakeLists.txt index 44745f95..59ac9eec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,26 +49,8 @@ ENDIF() OPTION( EXIV2_ENABLE_TOOLS "Build exiv2 executable" ON ) include(config/findDependencies.cmake) +include(config/compilerFlags.cmake) -if( MINGW OR UNIX ) - if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) - ADD_DEFINITIONS(-Wall - -Wcast-align - -Wpointer-arith - -Wformat-security - -Wmissing-format-attribute - -Woverloaded-virtual - -W - ) - ENDIF() - - 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 ) - ENDIF() - -ENDIF( MINGW OR UNIX ) IF( EXIV2_ENABLE_COMMERCIAL ) SET (EXIV2_ENABLE_LENSDATA OFF) @@ -76,7 +58,6 @@ IF( EXIV2_ENABLE_COMMERCIAL ) ENDIF() if( MSVC ) - ADD_DEFINITIONS(-DPSAPI_VERSION=1) # to be compatible with <= WinVista (#905) set(CMAKE_DEBUG_POSTFIX "d") endif( MSVC ) diff --git a/config/compilerFlags.cmake b/config/compilerFlags.cmake new file mode 100644 index 00000000..03ae4bef --- /dev/null +++ b/config/compilerFlags.cmake @@ -0,0 +1,18 @@ +if ( MINGW OR UNIX ) # MINGW, Linux, APPLE, CYGWIN + if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) + set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall + -Wcast-align + -Wpointer-arith + -Wformat-security + -Wmissing-format-attribute + -Woverloaded-virtual + -W + ) + endif() + + if ( CYGWIN OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)) + set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=gnu++98 ) # to support snprintf + else() + set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++98 ) + endif() +endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 066cfe7b..1cdf6455 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -218,6 +218,8 @@ if (EXIV2_ENABLE_WEBREADY AND EXIV2_ENABLE_SSH) 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()