File: RDMA_Sparse.cmake

package info (click to toggle)
rdma-core 61.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,124 kB
  • sloc: ansic: 176,798; python: 15,496; sh: 2,742; perl: 1,465; makefile: 73
file content (35 lines) | stat: -rw-r--r-- 1,228 bytes parent folder | download | duplicates (3)
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
# COPYRIGHT (c) 2017 Obsidian Research Corporation.
# Licensed under BSD (MIT variant) or GPLv2. See COPYING.

function(RDMA_CheckSparse)
  # Sparse defines __CHECKER__, but only for the 'sparse pass', which has no
  # way to fail the compiler.
  CHECK_C_SOURCE_COMPILES("
#if __CHECKER__
#warning \"SPARSE DETECTED\"
#endif
int main(int argc,const char *argv[]) {return 0;}
"
    HAVE_NO_SPARSE
    FAIL_REGEX "SPARSE DETECTED")

  if (HAVE_NO_SPARSE)
    set(HAVE_SPARSE FALSE PARENT_SCOPE)
  else()
    set(HAVE_SPARSE TRUE PARENT_SCOPE)

    # Replace various glibc headers with our own versions that have embedded sparse annotations.
    execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${BUILDLIB}/gen-sparse.py"
      "--out" "${BUILD_INCLUDE}/"
      "--src" "${PROJECT_SOURCE_DIR}/"
      "--cc" "${CMAKE_C_COMPILER}"
      RESULT_VARIABLE retcode)
    if(NOT "${retcode}" STREQUAL "0")
      message(FATAL_ERROR "glibc header file patching for sparse failed. Review include/*.rej and fix the rejects, then do "
	"${BUILDLIB}/gen-sparse.py --out ${BUILD_INCLUDE}/ --src ${PROJECT_SOURCE_DIR}/ --save")
    endif()

    # Enable endian analysis in sparse
    add_definitions("-D__CHECK_ENDIAN__")
  endif()
endfunction()