X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=CMake%2F_Include.cmake;h=79533f2766b6d228bac54755619a3c5ddaa74598;hb=b9748819d603f9d5c1dc54730ef38b6ee6d63ca4;hp=a6b5463c1a1b201be45a823df8a0f5d1884e0cef;hpb=6a0eee5f5b6163f06fa660dde37e8fe5e580483e;p=m6w6%2Flibmemcached diff --git a/CMake/_Include.cmake b/CMake/_Include.cmake index a6b5463c..79533f27 100644 --- a/CMake/_Include.cmake +++ b/CMake/_Include.cmake @@ -1,112 +1,169 @@ +include(_Configure) +configure_init(${CMAKE_BINARY_DIR}/mem_config.h) -# globals if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) endif() + +include(CMakePushCheckState) include(GNUInstallDirs) include(CMakePackageConfigHelpers) -find_package(PkgConfig) -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) - -# locals -include(InstallPublicHeaders) -include(SafeString) -include(CheckDebug) -include(CheckDecl) -include(CheckDependency) -include(CheckHeader) -include(CheckCompiles) -include(CheckType) -include(CheckStdatomic) - -# configuration +macro(make_have_identifier NAME ID) + string(MAKE_C_IDENTIFIER ${NAME} _make_have_identifier) + string(TOUPPER ${_make_have_identifier} _make_have_identifier) + set(${ID} HAVE_${_make_have_identifier}) +endmacro() -## debug -check_debug() - -## memaslap -if(ENABLE_MEMASLAP) - check_stdatomic() - check_dependency(LIBEVENT event event.h) - check_decl(getline stdio.h) -endif() - -## dtrace -if(ENABLE_DTRACE) - find_package(DTrace) - if(DTRACE_EXECUTABLE) - set(HAVE_DTRACE 1) - else() - message(WARNING "The dtrace command is required to enable dtrace/systemtap support.") +include(CheckCCompilerFlag) +macro(check_flag FLAG HAVE) + configure_define(${HAVE}) + check_c_compiler_flag("${FLAG}" ${HAVE}) +endmacro() +include(CheckCXXCompilerFlag) +macro(check_cxx_flag FLAG HAVE) + configure_define(${HAVE}) + check_cxx_compiler_flag("${FLAG}" ${HAVE}) +endmacro() +include(CheckSymbolExists) +macro(check_symbol NAME HEADER) + make_have_identifier(${NAME} HAVE) + configure_define(${HAVE}) + cmake_push_check_state() + if(${ARGC} GREATER 1) + string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGV2}") endif() -endif() + check_symbol_exists(${NAME} ${HEADER} ${HAVE}) + cmake_pop_check_state() +endmacro() +include(CheckCXXSymbolExists) +macro(check_cxx_symbol NAME HEADER) + make_have_identifier(${NAME} HAVE) + configure_define(${HAVE}) + cmake_push_check_state() + if(${ARGC} GREATER 1) + string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGN}") + endif() + check_cxx_symbol_exists(${NAME} ${HEADER} ${HAVE}) + cmake_pop_check_state() +endmacro() +include(CheckIncludeFile) +macro(check_include HEADER) + make_have_identifier(${HEADER} HAVE) + configure_define(${HAVE}) + cmake_push_check_state() + if(${ARGC} GREATER 1) + string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGN}") + endif() + check_include_file(${HEADER} ${HAVE}) + cmake_pop_check_state() +endmacro() +include(CheckIncludeFileCXX) +macro(check_cxx_include HEADER) + make_have_identifier(${HEADER} HAVE) + configure_define(${HAVE}) + cmake_push_check_state() + if(${ARGC} GREATER 1) + string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGN}") + endif() + check_include_file_cxx(${HEADER} ${HAVE}) + cmake_pop_check_state() +endmacro() +include(CheckTypeSize) +macro(check_type TYPE) + make_have_identifier(${TYPE} HAVE) + configure_define(${HAVE}) + cmake_push_check_state() + if(${ARGC} GREATER 1) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES ${ARGN}) + endif() + check_type_size(${TYPE} ${HAVE}) + cmake_pop_check_state() +endmacro() +include(CheckCSourceCompiles) +macro(check_c_source SOURCE HAVE) + configure_define(${HAVE}) + check_c_source_compiles("${SOURCE}" ${HAVE}) +endmacro() +include(CheckCXXSourceCompiles) +macro(check_cxx_source SOURCE HAVE) + configure_define(${HAVE}) + check_cxx_source_compiles("${SOURCE}" ${HAVE}) +endmacro() -## uuid -if(BUILD_TESTING) - check_dependency(LIBUUID uuid uuid/uuid.h) -endif() +include(CheckBacktrace) +include(CheckByteswap) +include(CheckDependency) +include(CheckDtrace) +include(CheckPkgconf) +include(CheckDebug) +include(CheckThreads) +include(CheckVisibility) +include(InstallPublicHeaders) ## sasl +configure_define_01(LIBMEMCACHED_WITH_SASL_SUPPORT) if(ENABLE_SASL) - check_dependency(LIBSASL sasl2 sasl/sasl.h) - if(LIBSASL) + check_dependency(LIBSASL sasl2) + if(HAVE_LIBSASL) set(LIBMEMCACHED_WITH_SASL_SUPPORT 1) endif() endif() ## hashes -if(ENABLE_HASH_FNV64) - set(HAVE_FNV64_HASH 1) -endif() -if(ENABLE_HASH_MURMUR) - set(HAVE_MURMUR_HASH 1) -endif() -if(ENABLE_HASH_HSIEH) - set(HAVE_HSIEH_HASH 1) -endif() +configure_set(HAVE_FNV64_HASH ${ENABLE_HASH_FNV64}) +configure_set(HAVE_MURMUR_HASH ${ENABLE_HASH_MURMUR}) +configure_set(HAVE_HSIEH_HASH ${ENABLE_HASH_HSIEH}) -# system checks +check_include(alloca.h) +check_include(arpa/inet.h) +check_include(dlfcn.h) +check_include(getopt.h) +check_include(libgen.h) +check_include(netdb.h) +check_include(netinet/in.h) +check_include(poll.h) +check_include(strings.h) +check_include(sys/poll.h) +check_include(sys/socket.h) +check_include(sys/time.h) +check_include(sys/un.h) +check_include(unistd.h) -check_header(arpa/inet.h) -check_header(dlfcn.h) -check_header(errno.h) -check_header(execinfo.h) -check_header(fcntl.h) -check_header(io.h) -check_header(limits.h) -check_header(netdb.h) -check_header(poll.h) -check_header(stddef.h) -check_header(stdlib.h) -check_header(strings.h) -check_header(sys/socket.h) -check_header(sys/time.h) -check_header(sys/types.h) -check_header(sys/un.h) -check_header(sys/wait.h) -check_header(time.h) -check_header(umem.h) -check_header(unistd.h) -check_header(winsock2.h) -check_header(ws2tcpip.h) +check_type(in_port_t netinet/in.h) +check_type(pid_t sys/types.h) +check_type(ssize_t sys/types.h) +check_type("struct msghdr" sys/socket.h) -check_decl(fcntl fcntl.h) -check_decl(htonll arpa/inet.h) -check_decl(MSG_DONTWAIT sys/socket.h) -check_decl(MSG_MORE sys/socket.h) -check_decl(MSG_NOSIGNAL sys/socket.h) -check_decl(rcvtimeo sys/socket.h) -check_decl(sndtimeo sys/socket.h) -check_decl(setenv stdlib.h) -check_decl(strerror string.h) -check_decl(strerror_r string.h) -check_compiles(HAVE_STRERROR_R_CHAR_P "char x, y = *strerror_r(0,&x,1);" string.h) -check_decl(abi::__cxa_demangle cxxabi.h) -set(HAVE_GCC_ABI_DEMANGLE ${HAVE_ABI____CXA_DEMANGLE}) +check_cxx_symbol(abi::__cxa_demangle cxxabi.h) +check_symbol(fcntl fcntl.h) +check_symbol(gettimeofday sys/time.h) +check_symbol(htonll arpa/inet.h) +check_symbol(index strings.h) +check_symbol(MSG_DONTWAIT sys/socket.h) +check_symbol(MSG_MORE sys/socket.h) +check_symbol(MSG_NOSIGNAL sys/socket.h) +check_symbol(SO_RCVTIMEO sys/socket.h) +check_symbol(SO_SNDTIMEO sys/socket.h) +check_symbol(rand stdlib.h) +check_symbol(random stdlib.h) +check_symbol(realpath stdlib.h) +check_symbol(sendmsg sys/socket.h) +check_symbol(setenv stdlib.h) +check_symbol(strerror_r string.h) +check_c_source(" + #include + int main() { + char x; + return *strerror_r(0, &x, 1); + }" + HAVE_STRERROR_R_CHAR_P +) -check_type(in_port_t netinet/in.h) +if(WIN32) + check_include(io.h) + check_include(winsock2.h) + check_include(ws2tcpip.h) -check_header(cstdint) -check_header(cinttypes) + check_symbol(htonll winsock2.h) +endif()