Edit

kc3-lang/libevent/cmake/CheckConstExists.cmake

Branch :

  • Show log

    Commit

  • Author : Azat Khuzhin
    Date : 2017-03-08 17:58:26
    Hash : a0bfe2c4
    Message : Merge branch 'cmake-configure-fixes-v2' Fixes in cmake, to make it more like configure and support some cross-compiling. * cmake-configure-fixes-v2: cmake: fix extracting of the version from git (check for number of matches) Detect arch4random_addrandom() existence Use off_t instead of ev_off_t for sendfile() (fixes android build) cmake: detect _GNU_SOURCE not by __GNU_LIBRARY__ only (fallback to _GNU_SOURCE) Check for WNOWAIT in waitpid() in runtime (not in cmake/configure) cmake: add <pthread.h> into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t) cmake: fix values for #cmakedefine cmake: drop duplicates from event-config template cmake: add value for the #cmakedefine macros (like autoconf) cmake: Fix checking of enum values from sysctl.h (cherry picked from commit 5aade2d30b6c5eff226cbf7b63fda5a01987ba4f)

  • cmake/CheckConstExists.cmake
  • include(CheckCSourceCompiles)
    
    macro(check_const_exists CONST FILES 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()
    endmacro(check_const_exists)