mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
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:
parent
c199df7bc7
commit
fa135bdcd9
@ -52,6 +52,7 @@ include(CheckStructHasMember)
|
|||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
include(CheckPrototypeDefinition)
|
include(CheckPrototypeDefinition)
|
||||||
include(CheckFunctionKeywords)
|
include(CheckFunctionKeywords)
|
||||||
|
include(CheckConstExists)
|
||||||
include(AddCompilerFlags)
|
include(AddCompilerFlags)
|
||||||
include(VersionViaGit)
|
include(VersionViaGit)
|
||||||
|
|
||||||
@ -412,10 +413,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH)
|
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_CONST_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_CONST_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_CONST_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(RANDOM_UUID sys/sysctl.h EVENT__HAVE_DECL_RANDOM_UUID)
|
||||||
CHECK_SYMBOL_EXISTS(F_SETFD fcntl.h EVENT__HAVE_SETFD)
|
CHECK_SYMBOL_EXISTS(F_SETFD fcntl.h EVENT__HAVE_SETFD)
|
||||||
|
|
||||||
CHECK_TYPE_SIZE(fd_mask EVENT__HAVE_FD_MASK)
|
CHECK_TYPE_SIZE(fd_mask EVENT__HAVE_FD_MASK)
|
||||||
|
23
cmake/CheckConstExists.cmake
Normal file
23
cmake/CheckConstExists.cmake
Normal 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)
|
@ -67,13 +67,16 @@
|
|||||||
#cmakedefine EVENT__HAVE_CLOCK_GETTIME
|
#cmakedefine EVENT__HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `CTL_KERN'. */
|
/* 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'. */
|
/* 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'. */
|
/* 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 */
|
/* Define if /dev/poll is available */
|
||||||
#cmakedefine EVENT__HAVE_DEVPOLL
|
#cmakedefine EVENT__HAVE_DEVPOLL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user