-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathAddCTSOption.cmake
58 lines (47 loc) · 2.22 KB
/
AddCTSOption.cmake
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
set(SYCL_CTS_DETAIL_AVAILABLE_OPTIONS "")
set(SYCL_CTS_DETAIL_OPTION_COMPILE_DEFINITIONS "")
#
# Adds a new CTS option with the given name, description and default value.
#
# The option is made available both as a CMake variable (either OFF or ON)
# and as a preprocessor definition with the same name (either 0 or 1).
#
# Important: The preprocessor macro is always set, regardless of its value.
# Use `#if <OPTION>` instead of `#ifdef <OPTION>`.
#
# Optional parameters:
# - WARN_IF_OFF <msg> Print a warning message if this option is set to OFF.
# - FORCE_ON <value> If <value> is ON the option will be overwritten as ON.
#
function(add_cts_option option_name option_description option_default)
cmake_parse_arguments(PARSE_ARGV 3 args "" "WARN_IF_OFF;FORCE_ON" "")
option(${option_name} ${option_description} ${option_default})
list(APPEND SYCL_CTS_DETAIL_AVAILABLE_OPTIONS ${option_name})
set(SYCL_CTS_DETAIL_AVAILABLE_OPTIONS ${SYCL_CTS_DETAIL_AVAILABLE_OPTIONS} PARENT_SCOPE)
set("${option_name}_DESCRIPTION" ${option_description} PARENT_SCOPE)
if(args_WARN_IF_OFF)
set("${option_name}_WARN_IF_OFF" ${args_WARN_IF_OFF} PARENT_SCOPE)
endif()
if (args_FORCE_ON)
set(${option_name} ON CACHE BOOL "" FORCE)
endif()
list(APPEND SYCL_CTS_DETAIL_OPTION_COMPILE_DEFINITIONS "${option_name}=$<BOOL:${${option_name}}>")
set(SYCL_CTS_DETAIL_OPTION_COMPILE_DEFINITIONS ${SYCL_CTS_DETAIL_OPTION_COMPILE_DEFINITIONS} PARENT_SCOPE)
endfunction()
function(print_cts_config_summary)
set(MSG_STR "\n")
string(APPEND MSG_STR "====================================\n")
string(APPEND MSG_STR " SYCL 2020 Conformance Test Suite\n")
string(APPEND MSG_STR " Configuration summary\n")
string(APPEND MSG_STR "====================================\n\n")
foreach(opt ${SYCL_CTS_DETAIL_AVAILABLE_OPTIONS})
string(APPEND MSG_STR " * ${opt}\n ${${opt}_DESCRIPTION}: ${${opt}}\n\n")
endforeach()
message(STATUS ${MSG_STR})
# Print warnings for disabled options
foreach(opt ${SYCL_CTS_DETAIL_AVAILABLE_OPTIONS})
if(NOT ${${opt}} AND ${opt}_WARN_IF_OFF)
message(WARNING ${${opt}_WARN_IF_OFF})
endif()
endforeach()
endfunction()