File: CheckConstExists.cmake

package info (click to toggle)
libevent 2.1.12-stable-10
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 5,304 kB
  • sloc: ansic: 56,580; sh: 4,525; python: 1,356; makefile: 217
file content (25 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (22)
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
include(CheckCSourceCompiles)

macro(check_const_exists CONST FILES VARIABLE)
  if (NOT DEFINED ${VARIABLE})
    set(check_const_exists_source "")
    foreach(file ${FILES})
      set(check_const_exists_source
          "${check_const_exists_source}
          #include <${file}>")
    endforeach()
    set(check_const_exists_source
        "${check_const_exists_source}
        int main() { (void)${CONST}; return 0; }")

    check_c_source_compiles("${check_const_exists_source}" ${VARIABLE})

    if (${${VARIABLE}})
      set(${VARIABLE} 1 CACHE INTERNAL "Have const ${CONST}")
      message(STATUS "Looking for ${CONST} - found")
    else()
      set(${VARIABLE} 0 CACHE INTERNAL "Have const ${CONST}")
      message(STATUS "Looking for ${CONST} - not found")
    endif()
  endif()
endmacro(check_const_exists)