From ff9e85cd1587afdbf380d9b6e3b5a84cc6ad47f0 Mon Sep 17 00:00:00 2001 From: Charly Mourglia Date: Sun, 7 Jul 2019 12:52:30 +0200 Subject: [PATCH] Pure C projects had errors in detect_vs_runtime() CMAKE_CXX_FLAGS* are empty when creating a project with project(MY_PROJECT C) as a header. This is causing issues when trying to string(REPLACE) with an empty string. --- conan.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/conan.cmake b/conan.cmake index bc379db6..0a9c66ec 100644 --- a/conan.cmake +++ b/conan.cmake @@ -298,14 +298,16 @@ function(conan_cmake_detect_vs_runtime result) string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) foreach(variable ${variables}) - string(REPLACE " " ";" flags ${${variable}}) - foreach (flag ${flags}) - if(${flag} STREQUAL "/MD" OR ${flag} STREQUAL "/MDd" OR ${flag} STREQUAL "/MT" OR ${flag} STREQUAL "/MTd") - string(SUBSTRING ${flag} 1 -1 runtime) - set(${result} ${runtime} PARENT_SCOPE) - return() - endif() - endforeach() + if(NOT "${${variable}}" STREQUAL "") + string(REPLACE " " ";" flags ${${variable}}) + foreach (flag ${flags}) + if(${flag} STREQUAL "/MD" OR ${flag} STREQUAL "/MDd" OR ${flag} STREQUAL "/MT" OR ${flag} STREQUAL "/MTd") + string(SUBSTRING ${flag} 1 -1 runtime) + set(${result} ${runtime} PARENT_SCOPE) + return() + endif() + endforeach() + endif() endforeach() if(${build_type} STREQUAL "DEBUG") set(${result} "MDd" PARENT_SCOPE)