Skip to content

Commit

Permalink
parse cmake environment variables version check
Browse files Browse the repository at this point in the history
  • Loading branch information
sakra committed Feb 27, 2021
1 parent 50144ce commit 8c8711b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions CMakeBBLM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,25 @@ foreach (_line IN LISTS _output)
endforeach()

# cmake environment variables
execute_process(
COMMAND ${CMAKE_COMMAND} --help-manual cmake-env-variables
OUTPUT_VARIABLE _output
OUTPUT_STRIP_TRAILING_WHITESPACE)
string (REPLACE "\n" ";" _output "${_output}")
set (_variable "")
foreach (_line IN LISTS _output)
if(_line MATCHES "^-+ *$")
if (_variable)
list (APPEND _variableList "${_variable}")
set (_variable "")
if (NOT CMAKE_VERSION VERSION_LESS "3.0.0")
execute_process(
COMMAND ${CMAKE_COMMAND} --help-manual cmake-env-variables
OUTPUT_VARIABLE _output
OUTPUT_STRIP_TRAILING_WHITESPACE)
string (REPLACE "\n" ";" _output "${_output}")
set (_variable "")
foreach (_line IN LISTS _output)
if(_line MATCHES "^-+ *$")
if (_variable)
list (APPEND _variableList "${_variable}")
set (_variable "")
endif()
elseif (_line MATCHES "^([A-Za-z0-9_<>-]+) *$")
set (_variable "${_line}")
endif()
elseif (_line MATCHES "^([A-Za-z0-9_<>-]+) *$")
set (_variable "${_line}")
endif()
endforeach()
endforeach()
endif()

# explicitly add variables missed by command parser
list(APPEND _variableList "CMAKE_ARGV(0..9)" "CMAKE_MATCH_(0..9)")
# add undocumented, but useful CMake variables
Expand Down

0 comments on commit 8c8711b

Please sign in to comment.