File: attribute_support.cmake

package info (click to toggle)
igraph 0.10.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,176 kB
  • sloc: ansic: 121,500; cpp: 21,699; xml: 2,734; python: 411; makefile: 147; javascript: 20; sh: 9
file content (27 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (8)
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

# Detect if certain attributes are supported by the compiler
# The result will be used to set macros in include/igraph_config.h

# GCC-style enum value deprecation

include(CheckCSourceCompiles)
include(CMakePushCheckState)

# Only check with Clang and GCC as we assume that the -Werror option is supported
# For other compilers, assume that the attribute is unsupported.
if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
  cmake_push_check_state()
  # Require compiling with no warning:
  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
  check_c_source_compiles(
    "enum { A __attribute__ ((deprecated)) = 0 }; int main(void) { return 0; }"
    COMPILER_HAS_DEPRECATED_ENUMVAL_ATTR
  )
  cmake_pop_check_state()
else()
  set(COMPILER_HAS_DEPRECATED_ENUMVAL_ATTR FALSE)
endif()

if(COMPILER_HAS_DEPRECATED_ENUMVAL_ATTR)
  set(IGRAPH_DEPRECATED_ENUMVAL "__attribute__ ((deprecated))")
endif()