Project

General

Profile

Feature #1269 ยป msvc.diff

Enable using dynamic runtime with static lib for windows - Ben Touchette, 10 Jan 2017 19:04

View differences:

exiv2-0.26/CMakeLists.txt 2016-12-16 16:58:03.000000000 -0500
51 51
OPTION( EXIV2_ENABLE_VIDEO         "Build video support into library"                      OFF )
52 52
OPTION( EXIV2_ENABLE_WEBREADY      "Build webready support into library"                   OFF )
53 53
IF (WIN32)
54
    OPTION( EXIV2_ENABLE_DYNAMIC_RUNTIME  "Use dynamic runtime (used for static libs)"     OFF )
54 55
    OPTION( EXIV2_ENABLE_WIN_UNICODE   "Use Unicode paths (wstring) on Windows"            OFF )
55 56
    OPTION( EXIV2_ENABLE_CURL          "USE Libcurl for HttpIo"                            OFF )
56 57
    OPTION( EXIV2_ENABLE_SSH           "USE Libssh for SshIo"                              OFF )
57 58
ELSE()
58 59
    OPTION( EXIV2_ENABLE_CURL          "USE Libcurl for HttpIo"                            ON  )
59 60
    OPTION( EXIV2_ENABLE_SSH           "USE Libssh for SshIo"                              ON  )
60

  
61
    SET ( EXIV2_ENABLE_DYNAMIC_RUNTIME OFF )
61 62
ENDIF()
62 63

  
63 64
# set include path for FindXXX.cmake files
......
110 111
if( MSVC )
111 112
    # cmake_policy(SET CMP0008)
112 113
    ADD_DEFINITIONS(-DPSAPI_VERSION=1) # to be compatible with <= WinVista (#905)
114
    set(CMAKE_DEBUG_POSTFIX "d")
113 115
endif( MSVC )
114 116

  
115 117
IF( EXIV2_ENABLE_XMP )
exiv2-0.26/CMake_msvc.txt 2016-12-16 16:58:03.000000000 -0500
4 4

  
5 5
##
6 6
# msvc tuning macros
7
macro(msvc_runtime_set_static_ignores bDynamic)
7
macro(msvc_runtime_set_static_ignores bDynamic bDynamicRuntime)
8 8
  if(MSVC)
9 9
    # don't link msvcrt for .exe which use shared libraries (use default libcmt)
10
	if ( ${bDynamic} STREQUAL "OFF" )
10
	if ( ${bDynamic} STREQUAL "OFF" AND ${bDynamicRuntime} STREQUAL "OFF")
11 11
		set(CMAKE_EXE_LINKER_FLAGS_DEBUG          "/NODEFAULTLIB:MSVCRTD")
12 12
		set(CMAKE_EXE_LINKER_FLAGS_RELEASE        "/NODEFAULTLIB:MSVCRT")
13 13
		set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL     "/NODEFAULTLIB:MSVCRT")
......
17 17
endmacro()
18 18

  
19 19
# http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake
20
macro(msvc_runtime_configure bDynamic)
20
macro(msvc_runtime_configure bDynamic bDynamicRuntime)
21 21
  if(MSVC)
22 22
    set(variables
23 23
      CMAKE_C_FLAGS_DEBUG
......
29 29
      CMAKE_CXX_FLAGS_RELEASE
30 30
      CMAKE_CXX_FLAGS_RELWITHDEBINFO
31 31
    )
32
    if( ${bDynamic} STREQUAL "ON" )
32
    if( ${bDynamic} STREQUAL "ON" OR ${bDynamicRuntime} STREQUAL "ON")
33 33
      message(STATUS  "MSVC -> forcing use of dynamically-linked runtime." )
34 34
      foreach(variable ${variables})
35 35
        if(${variable} MATCHES "/MT")
......
55 55
        endif()
56 56
      endforeach()
57 57
    endforeach()
58
    msvc_runtime_set_static_ignores(${bDynamic})
58
    msvc_runtime_set_static_ignores(${bDynamic} ${bDynamicRuntime})
59 59
  endif()
60 60
endmacro()
61 61

  
exiv2-0.26/config/CMakeChecks.txt 2016-12-16 16:58:03.000000000 -0500
111 111
IF( EXIV2_ENABLE_WIN_UNICODE )
112 112
	IF (WIN32)
113 113
    	SET ( UNICODE_PATH 1 )
114
    	SET ( EXV_UNICODE_PATH 1 )
114 115
    ENDIF()
115 116
ENDIF()
116 117

  
......
337 338
OptionOutput( "USE Libssh for SshIo:               " EXIV2_ENABLE_SSH                )
338 339
endif ( EXIV2_ENABLE_WEBREADY )
339 340
IF (WIN32)
341
OptionOutput( "Dynamic runtime override:           " EXIV2_ENABLE_DYNAMIC_RUNTIME    )
340 342
OptionOutput( "Unicode paths (wstring):            " EXIV2_ENABLE_WIN_UNICODE        )
341 343
ENDIF()
342 344
MESSAGE( STATUS "------------------------------------------------------------------" )
exiv2-0.26/samples/CMakeLists.txt 2016-12-23 10:18:34.000000000 -0500
42 42
##
43 43
# msvn tuning
44 44
include(../CMake_msvc.txt)
45
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
45
msvc_runtime_configure(${EXIV2_ENABLE_SHARED} ${EXIV2_ENABLE_DYNAMIC_RUNTIME})
46 46

  
47 47
FOREACH(entry ${SAMPLES})
48 48
    STRING( REPLACE ".cpp" "" target ${entry})
exiv2-0.26/src/CMakeLists.txt 2016-12-16 16:57:57.000000000 -0500
231 231
# msvn tuning
232 232
IF( MSVC )
233 233
    include(../CMake_msvc.txt)
234
    msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
234
    msvc_runtime_configure(${EXIV2_ENABLE_SHARED} ${EXIV2_ENABLE_DYNAMIC_RUNTIME})
235 235
ENDIF( MSVC )
236 236

  
237 237
# ******************************************************************************
......
309 309
INSTALL( TARGETS exiv2lib ${INSTALL_TARGET_STANDARD_ARGS} )
310 310

  
311 311
include(../CMake_msvc.txt)
312
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
312
msvc_runtime_configure(${EXIV2_ENABLE_SHARED} ${EXIV2_ENABLE_DYNAMIC_RUNTIME})
313 313

  
314 314
# ******************************************************************************
315 315
# exiv2 application
exiv2-0.26/xmpsdk/CMakeLists.txt 2016-12-16 16:58:03.000000000 -0500
7 7
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
8 8

  
9 9
include(../CMake_msvc.txt)
10
msvc_runtime_configure(${EXIV2_ENABLE_SHARED})
10
msvc_runtime_configure(${EXIV2_ENABLE_SHARED} ${EXIV2_ENABLE_DYNAMIC_RUNTIME})
11 11

  
12 12
if( POLICY CMP0026 )
13 13
    cmake_policy(SET CMP0026 OLD) # Something to do with location
    (1-1/1)