diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e70c73..f4ed27af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ option( EXIV2_ENABLE_NLS "Build native language support (requires g option( EXIV2_ENABLE_PRINTUCS2 "Build with Printucs2" ON ) option( EXIV2_ENABLE_LENSDATA "Build including lens data" ON ) option( EXIV2_ENABLE_VIDEO "Build video support into library" OFF ) -option( EXIV2_ENABLE_DYNAMIC_RUNTIME "Use dynamic runtime (used for static libs)" OFF ) +option( EXIV2_ENABLE_DYNAMIC_RUNTIME "Use dynamic runtime (used for static libs)" ON ) option( EXIV2_ENABLE_WIN_UNICODE "Use Unicode paths (wstring) on Windows" OFF ) option( EXIV2_ENABLE_WEBREADY "Build webready support into library" OFF ) option( EXIV2_ENABLE_CURL "USE Libcurl for HttpIo (WEBREADY)" OFF ) diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake index 0dd1fc39..6519eff8 100644 --- a/cmake/compilerFlags.cmake +++ b/cmake/compilerFlags.cmake @@ -164,22 +164,15 @@ if(MSVC) CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO ) - 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") - string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}") - endif() - endforeach() - else() - message(STATUS "MSVC -> forcing use of statically-linked runtime." ) - foreach(variable ${variables}) - if(${variable} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") - endif() - set(${variable} "${${variable}} /DXML_STATIC /D_LIB") - endforeach() - endif() + + if (NOT BUILD_SHARED_LIBS AND NOT EXIV2_ENABLE_DYNAMIC_RUNTIME) + message(STATUS "MSVC -> forcing use of statically-linked runtime." ) + foreach(variable ${variables}) + if(${variable} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") + endif() + endforeach() + endif() # remove /Ob2 and /Ob1 - they cause linker issues set(obs /Ob2 /Ob1) @@ -191,14 +184,6 @@ if(MSVC) endforeach() endforeach() - # don't link msvcrt for .exe which use shared libraries (use default libcmt) - 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") - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:MSVCRT") - endif() - if ( EXIV2_EXTRA_WARNINGS ) string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif ()