Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 4e3a9e3

Browse files
committed
Separated crooked list-initialization technique from source argument parsing to utility macro.
1 parent 4e71924 commit 4e3a9e3

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

cmake/Platform/Utilities/CMakeArgumentsUtils.cmake

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@
1111
function(parse_sources_arguments _return_var _reserved_options _reserved_single_values
1212
_reserved_multi_values _cmake_args)
1313

14-
# Prepare arguments for further inspection - Somewhat croocked logic due to CMake's limitations
15-
# If an argument is an empty string, populate it with a theoritcally impossible value.
16-
# just to have some value in it
17-
if ("${_reserved_options}" STREQUAL "")
18-
set(_reserved_options "+-*/")
19-
endif ()
20-
if ("${_reserved_single_values}" STREQUAL "")
21-
set(_reserved_single_values "+-*/")
22-
endif ()
23-
if ("${_reserved_multi_values}" STREQUAL "")
24-
set(_reserved_multi_values "+-*/")
25-
endif ()
14+
# Initialize argument-lists for further inspection
15+
initialize_list(_reserved_options)
16+
initialize_list(_reserved_single_values)
17+
initialize_list(_reserved_multi_values)
2618

2719
set(sources "") # Clear list because cmake preserves scope in nested functions
2820

cmake/Platform/Utilities/ListUtils.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
# Must not be negative or greater than 'list_length'-1.
66
#=============================================================================#
77
macro(list_replace _list _index _new_element)
8+
89
list(REMOVE_AT ${_list} ${_index})
10+
911
list(INSERT ${_list} ${_index} "${_new_element}")
12+
13+
endmacro()
14+
15+
#=============================================================================#
16+
# Checks whether the given list is empty. If it is - Initializes it with a theoretically
17+
# impossible to reproduce value, so if it's used to check whether an item is in it
18+
# the answer will be false.
19+
# _list - List to initialize.
20+
#=============================================================================#
21+
macro(initialize_list _list)
22+
23+
if ("${${_list}}" STREQUAL "")
24+
set(${_list} "+-*/")
25+
endif ()
26+
1027
endmacro()

0 commit comments

Comments
 (0)