From 89d0c7124bc7330e90712f9b1fa9824a0fa8303a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 17 Jul 2020 06:39:53 -0700 Subject: [PATCH] Fix compatibility with CMake 3.4 (#1779) --- CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8dd862c..977090f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,15 +24,23 @@ function(join result_var) set(${result_var} "${result}" PARENT_SCOPE) endfunction() +include(CMakeParseArguments) + # Sets a cache variable with a docstring joined from multiple arguments: # set( ... CACHE ...) # This allows splitting a long docstring for readability. function(set_verbose) - cmake_parse_arguments(SET_VERBOSE "" "" "CACHE" ${ARGN}) - list(GET SET_VERBOSE_CACHE 0 type) - list(REMOVE_AT SET_VERBOSE_CACHE 0) - join(doc ${SET_VERBOSE_CACHE}) - set(${SET_VERBOSE_UNPARSED_ARGUMENTS} CACHE ${type} ${doc}) + # cmake_parse_arguments is broken in CMake 3.4 (cannot parse CACHE) so use + # list instead. + list(GET ARGN 0 var) + list(REMOVE_AT ARGN 0) + list(GET ARGN 0 val) + list(REMOVE_AT ARGN 0) + list(REMOVE_AT ARGN 0) + list(GET ARGN 0 type) + list(REMOVE_AT ARGN 0) + join(doc ${ARGN}) + set(${var} ${val} CACHE ${type} ${doc}) endfunction() # Set the default CMAKE_BUILD_TYPE to Release.