Only try to read file if it exists
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
function(VarsFromFile filename)
|
function(VarsFromFile filename)
|
||||||
file(STRINGS ${filename} ConfigContents)
|
if (EXISTS ${filename})
|
||||||
foreach(NameAndValue ${ConfigContents})
|
file(STRINGS ${filename} ConfigContents)
|
||||||
# Strip leading spaces
|
foreach(NameAndValue ${ConfigContents})
|
||||||
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
|
# Strip leading spaces
|
||||||
# Find variable name
|
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
|
||||||
string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
|
# Find variable name
|
||||||
# Find the value
|
string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
|
||||||
string(REPLACE "${Name}=" "" Value ${NameAndValue})
|
# Find the value
|
||||||
# Set the variable
|
string(REPLACE "${Name}=" "" Value ${NameAndValue})
|
||||||
set(${Name} "${Value}" PARENT_SCOPE)
|
# Set the variable
|
||||||
endforeach()
|
set(${Name} "${Value}" PARENT_SCOPE)
|
||||||
|
endforeach()
|
||||||
|
endif ()
|
||||||
endfunction(VarsFromFile)
|
endfunction(VarsFromFile)
|
||||||
Reference in New Issue
Block a user