cmake: Fix checking of enum values from sysctl.h

CheckSymbolExists do not do this, so add new CheckConstExists that will
use CheckCSourceCompiles() to check this.

v2: use set() instead of string(APPEND)
This commit is contained in:
Azat Khuzhin 2017-01-30 03:17:41 +03:00
parent c199df7bc7
commit fa135bdcd9
3 changed files with 34 additions and 7 deletions

View File

@ -52,6 +52,7 @@ include(CheckStructHasMember)
include(CheckCSourceCompiles)
include(CheckPrototypeDefinition)
include(CheckFunctionKeywords)
include(CheckConstExists)
include(AddCompilerFlags)
include(VersionViaGit)
@ -412,10 +413,10 @@ else()
endif()
CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH)
CHECK_SYMBOL_EXISTS(CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN)
CHECK_SYMBOL_EXISTS(KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND)
CHECK_SYMBOL_EXISTS(KERN_RANDOM sys/sysctl.h EVENT__HAVE_DECL_KERN_RANDOM)
CHECK_SYMBOL_EXISTS(RANDOM_UUID sys/sysctl.h EVENT__HAVE_DECL_RANDOM_UUID)
CHECK_CONST_EXISTS(CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN)
CHECK_CONST_EXISTS(KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND)
CHECK_CONST_EXISTS(KERN_RANDOM sys/sysctl.h EVENT__HAVE_DECL_KERN_RANDOM)
CHECK_CONST_EXISTS(RANDOM_UUID sys/sysctl.h EVENT__HAVE_DECL_RANDOM_UUID)
CHECK_SYMBOL_EXISTS(F_SETFD fcntl.h EVENT__HAVE_SETFD)
CHECK_TYPE_SIZE(fd_mask EVENT__HAVE_FD_MASK)

View File

@ -0,0 +1,23 @@
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)

View File

@ -67,13 +67,16 @@
#cmakedefine EVENT__HAVE_CLOCK_GETTIME
/* Define to 1 if you have the declaration of `CTL_KERN'. */
#cmakedefine EVENT__HAVE_DECL_CTL_KERN
#define EVENT__HAVE_DECL_CTL_KERN @EVENT__HAVE_DECL_CTL_KERN@
/* Define to 1 if you have the declaration of `KERN_ARND'. */
#cmakedefine EVENT__HAVE_DECL_KERN_ARND
#define EVENT__HAVE_DECL_KERN_ARND @EVENT__HAVE_DECL_KERN_ARND@
/* Define to 1 if you have the declaration of `KERN_RANDOM'. */
#cmakedefine EVENT__HAVE_DECL_KERN_RANDOM
#define EVENT__HAVE_DECL_KERN_RANDOM @EVENT__HAVE_DECL_KERN_RANDOM@
/* Define to 1 if you have the declaration of `RANDOM_UUID'. */
#define EVENT__HAVE_DECL_RANDOM_UUID @EVENT__HAVE_DECL_RANDOM_UUID@
/* Define if /dev/poll is available */
#cmakedefine EVENT__HAVE_DEVPOLL