Skip to content

Commit

Permalink
Teach mark_as_superbuild how to handle variables with double-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Jun 21, 2016
1 parent 0dfd762 commit d453e32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ExternalProjectDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ function(_sb_cmakevar_to_cmakearg cmake_varname_and_type cmake_arg_var has_cfg_i
endif()
endif()

if(NOT _has_cfg_intdir)
string(REPLACE "\"" "\\\"" _var_value "${_var_value}")
endif()

set(${cmake_arg_var} -D${_varname}:${_vartype}=${_var_value} PARENT_SCOPE)
set(${has_cfg_intdir_var} ${_has_cfg_intdir} PARENT_SCOPE)

Expand Down
8 changes: 8 additions & 0 deletions Tests/MarkAsSuperBuild-Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ if(${PROJECT_NAME}_SUPERBUILD)
set(FOO_VAR "FooVar")
mark_as_superbuild(FOO_VAR)

set(FOO_VAR_WITH_QUOTES "This is \"FooVar\" with quotes")
mark_as_superbuild(FOO_VAR_WITH_QUOTES)

set(FOO_VAR_FOR_CMAKE_ARGS_WITH_QUOTES "This is \"FooVar\" with quotes for \"${CMAKE_CFG_INTDIR}\"")
mark_as_superbuild(FOO_VAR_FOR_CMAKE_ARGS_WITH_QUOTES)

set(FOO_LIST Item1 Item2)
mark_as_superbuild(FOO_LIST)

Expand Down Expand Up @@ -103,6 +109,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../ArtichokeTestUtility.cmake)

check_variable(FOO_OPTION "ON")
check_variable(FOO_VAR "FooVar")
check_variable(FOO_VAR_WITH_QUOTES "This is \"FooVar\" with quotes")
check_variable(FOO_VAR_FOR_CMAKE_ARGS_WITH_QUOTES "This is \"FooVar\" with quotes for \"${EXPECTED_CMAKE_CFG_INTDIR}\"")
check_variable(FOO_LIST "Item1;Item2")
check_variable(FOO_LIST_FOR_CMAKE_ARGS "Item1;${EXPECTED_CMAKE_CFG_INTDIR}")
check_variable(FOO_LIST_FOR_CMAKE_ARGS_WITH_CMAKE_CMD_IGNORED "Item1;${EXPECTED_CMAKE_CFG_INTDIR}")
Expand Down

0 comments on commit d453e32

Please sign in to comment.