summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakePrintHelpers.cmake49
1 files changed, 33 insertions, 16 deletions
diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake
index 8c25a73..0af2d3f 100644
--- a/Modules/CMakePrintHelpers.cmake
+++ b/Modules/CMakePrintHelpers.cmake
@@ -56,17 +56,34 @@ endfunction()
function(cmake_print_properties)
set(options )
set(oneValueArgs )
- set(multiValueArgs TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES )
+ set(cpp_multiValueArgs PROPERTIES )
+ set(cppmode_multiValueArgs TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES )
- cmake_parse_arguments(CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ string(JOIN " " _mode_names ${cppmode_multiValueArgs})
+ set(_missing_mode_message
+ "Mode keyword missing in cmake_print_properties() call, there must be exactly one of ${_mode_names}")
- if(CPP_UNPARSED_ARGUMENTS)
- message(FATAL_ERROR "Unknown keywords given to cmake_print_properties(): \"${CPP_UNPARSED_ARGUMENTS}\"")
+ cmake_parse_arguments(
+ CPP "${options}" "${oneValueArgs}" "${cpp_multiValueArgs}" ${ARGN})
+
+ if(NOT CPP_PROPERTIES)
+ message(FATAL_ERROR
+ "Required argument PROPERTIES missing in cmake_print_properties() call")
return()
endif()
- if(NOT CPP_PROPERTIES)
- message(FATAL_ERROR "Required argument PROPERTIES missing in cmake_print_properties() call")
+ if(NOT CPP_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "${_missing_mode_message}")
+ return()
+ endif()
+
+ cmake_parse_arguments(
+ CPPMODE "${options}" "${oneValueArgs}" "${cppmode_multiValueArgs}"
+ ${CPP_UNPARSED_ARGUMENTS})
+
+ if(CPPMODE_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR
+ "Unknown keywords given to cmake_print_properties(): \"${CPPMODE_UNPARSED_ARGUMENTS}\"")
return()
endif()
@@ -74,32 +91,32 @@ function(cmake_print_properties)
set(items)
set(keyword)
- if(CPP_TARGETS)
- set(items ${CPP_TARGETS})
+ if(CPPMODE_TARGETS)
+ set(items ${CPPMODE_TARGETS})
set(mode ${mode} TARGETS)
set(keyword TARGET)
endif()
- if(CPP_SOURCES)
- set(items ${CPP_SOURCES})
+ if(CPPMODE_SOURCES)
+ set(items ${CPPMODE_SOURCES})
set(mode ${mode} SOURCES)
set(keyword SOURCE)
endif()
- if(CPP_TESTS)
- set(items ${CPP_TESTS})
+ if(CPPMODE_TESTS)
+ set(items ${CPPMODE_TESTS})
set(mode ${mode} TESTS)
set(keyword TEST)
endif()
- if(CPP_DIRECTORIES)
- set(items ${CPP_DIRECTORIES})
+ if(CPPMODE_DIRECTORIES)
+ set(items ${CPPMODE_DIRECTORIES})
set(mode ${mode} DIRECTORIES)
set(keyword DIRECTORY)
endif()
- if(CPP_CACHE_ENTRIES)
- set(items ${CPP_CACHE_ENTRIES})
+ if(CPPMODE_CACHE_ENTRIES)
+ set(items ${CPPMODE_CACHE_ENTRIES})
set(mode ${mode} CACHE_ENTRIES)
# This is a workaround for the fact that passing `CACHE` as an argument to
# set() causes a cache variable to be set.