File: CheckEnumValueExists.cmake

package info (click to toggle)
dpf-plugins 1.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 145,284 kB
  • sloc: cpp: 299,382; ansic: 61,509; objc: 2,715; makefile: 2,076; xml: 618; sh: 462; java: 211; python: 184
file content (26 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (2)
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
include_guard()

include(CheckCSourceCompiles)

macro(check_enum_value_exists enum_value include variable)
    if(NOT DEFINED ${variable})
        message(STATUS "Looking for enum value ${enum_value}")
        set(_CMAKE_REQUIRED_QUIET_tmp "${CMAKE_REQUIRED_QUIET}")
        set(CMAKE_REQUIRED_QUIET ON)
        check_c_source_compiles("
#include <${include}>
int main() {
  int tmp = ${enum_value};
  return 0;
}
"
                ${variable}
                )
        if(${variable})
            message(STATUS "Looking for enum value ${enum_value} - found")
        else()
            message(STATUS "Looking for enum value ${enum_value} - not found")
        endif()
        set(CMAKE_REQUIRED_QUIET "${_CMAKE_REQUIRED_QUIET_tmp}")
    endif()
endmacro()