replace runtime for RelWithDebInfo & MinSizeRel configurations
@@ -458,18 +458,18 @@ endmacro()
macro(conan_set_vs_runtime)
if(CONAN_LINK_RUNTIME)
- if(DEFINED CMAKE_CXX_FLAGS_RELEASE)
- string(REPLACE "/MD" ${CONAN_LINK_RUNTIME} CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
+ foreach(flag CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL)
+ if(DEFINED ${flag})
+ string(REPLACE "/MD" ${CONAN_LINK_RUNTIME} ${flag} "${${flag}}")
endif()
- if(DEFINED CMAKE_CXX_FLAGS_DEBUG)
- string(REPLACE "/MDd" ${CONAN_LINK_RUNTIME} CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
- endif()
- if(DEFINED CMAKE_C_FLAGS_RELEASE)
- string(REPLACE "/MD" ${CONAN_LINK_RUNTIME} CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
- endif()
- if(DEFINED CMAKE_C_FLAGS_DEBUG)
- string(REPLACE "/MDd" ${CONAN_LINK_RUNTIME} CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+ endforeach()
+ foreach(flag CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG)
+ if(DEFINED ${flag})
+ string(REPLACE "/MDd" ${CONAN_LINK_RUNTIME} ${flag} "${${flag}}")
endif()
+ endforeach()
endif()
endmacro()
@@ -524,18 +524,18 @@ macro(conan_set_vs_runtime)
# debug, forcing MXd for debug builds. It will generate MSVCRT warnings if the dependencies
# are installed with "conan install" and the wrong build time.
if(CONAN_LINK_RUNTIME MATCHES "MT")
- if(DEFINED CMAKE_CXX_FLAGS_RELEASE)
- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
+ foreach(flag CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL)
+ if(DEFINED ${flag})
+ string(REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
- if(DEFINED CMAKE_CXX_FLAGS_DEBUG)
- string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
- endif()
- if(DEFINED CMAKE_C_FLAGS_RELEASE)
- string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
- endif()
- if(DEFINED CMAKE_C_FLAGS_DEBUG)
- string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+ endforeach()
+ foreach(flag CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG)
+ if(DEFINED ${flag})
+ string(REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
+ endforeach()
endif()
endmacro()
