Trim same amount from strings before comparing

If you specified options in an environment variable containing a blank
at the end, then this would not compare equal to the other candidate,
which was stripped, causing the first added argument to drop out! This
is usually the flag for C++11 compliance, causing binary incompatibility
This commit is contained in:
Roland Kaufmann 2013-03-05 11:43:06 +01:00
parent 0ac31dd871
commit f3b76ac8e3

View File

@ -43,16 +43,18 @@ function (add_options langs builds)
# remove it first
string (REPLACE "${_opt}" "" _without "${${_var}}")
string (STRIP "${_without}" _without)
# we need to strip this one as well, so they are comparable
string (STRIP "${${_var}}" _stripped)
# if it wasn't there, then add it at the end
if ("${_without}" STREQUAL "${${_var}}")
if ("${_without}" STREQUAL "${_stripped}")
# don't add any extra spaces if no options yet are set
if (NOT ${${_var}} STREQUAL "")
set (${_var} "${${_var}} ${_opt}")
else (NOT ${${_var}} STREQUAL "")
if (NOT ${_stripped} STREQUAL "")
set (${_var} "${_stripped} ${_opt}")
else (NOT ${_stripped} STREQUAL "")
set (${_var} "${_opt}")
endif (NOT ${${_var}} STREQUAL "")
endif (NOT ${_stripped} STREQUAL "")
set (${_var} "${${_var}}" PARENT_SCOPE)
endif ("${_without}" STREQUAL "${${_var}}")
endif ("${_without}" STREQUAL "${_stripped}")
endforeach (_opt)
endforeach (build)
endforeach (lang)