From: Azat Khuzhin Date: Mon, 30 Jan 2017 00:17:41 +0000 (+0300) Subject: cmake: Fix checking of enum values from sysctl.h X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa135bdcd9f82a953ac6be55a5c874114bccbc42;p=libevent 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) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 24eaa404..ae6178b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/CheckConstExists.cmake b/cmake/CheckConstExists.cmake new file mode 100644 index 00000000..56b49882 --- /dev/null +++ b/cmake/CheckConstExists.cmake @@ -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) diff --git a/event-config.h.cmake b/event-config.h.cmake index 472ffe17..8431dfc8 100644 --- a/event-config.h.cmake +++ b/event-config.h.cmake @@ -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