Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 40 lines (37 sloc) 1.339 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

#
# Function converts a list of cmake cache varibles to a string of
# cmake code which set each cmake cache variable. The output in cache
# is suitable to be writen to a file for "-C file" command line
# argument for cmake.
#
function( VariableListToCache var_list cache )
  foreach( var IN LISTS ${var_list} )
    if( NOT ${var} STREQUAL "" ) # if variable has been set
      get_property( type CACHE ${var} PROPERTY TYPE )
      get_property( advanced CACHE ${var} PROPERTY ADVANCED )
      get_property( helpstring CACHE ${var} PROPERTY HELPSTRING )
      if ( NOT "${type}" )

        set( type STRING )
      endif()
      set( _cache "${_cache}
set( ${var} \"${${var}}\" CACHE \"${type}\" \"${helpstring}\" FORCE )
if( ${advanced} )
  mark_as_advanced( ${var} )
endif()" )
    endif()
  endforeach()
  set( ${cache} "${_cache}" PARENT_SCOPE)
endfunction( )

#
# Function which converts a list a cmake cache variable into a list of
# "-Dvar:type=value;" suitable for command line initialization.
#
function( VariableListToArgs var_list args )
  foreach( var IN LISTS ${var_list} )
    if( NOT ${var} STREQUAL "" ) # if variable has been set
      get_property( type CACHE ${var} PROPERTY TYPE )
      list( APPEND _args "-D${var}:${type}=${${var}}" )
    endif()
  endforeach()
  set( ${args} "${_args}" PARENT_SCOPE)
endfunction( )
Something went wrong with that request. Please try again.