cmake_minimum_required(VERSION 2.8.10) project(micro_http) OPTION (BAUTH_SUPPORT "Enable Basic Authentication" ON) OPTION (DAUTH_SUPPORT "Enable Digest Authentication" ON) OPTION (HTTPS_SUPPORT "Enable HTTPS" OFF) OPTION (MESSAGES "Enables messages" ON) OPTION (HAVE_POSTPROCESSOR "Enable POST" ON) if (WIN32) OPTION (MHD_USE_W32_THREADS "Use WIN32 threads" ON) OPTION (MHD_USE_POSIX_THREADS "Use POSIX threads" OFF) else (WIN32) OPTION (MHD_USE_W32_THREADS "Use WIN32 threads" OFF) OPTION (MHD_USE_POSIX_THREADS "Use POSIX threads" ON) endif (WIN32) INCLUDE (CheckIncludeFile) INCLUDE (CheckIncludeFiles) INCLUDE (CheckSymbolExists) INCLUDE (CheckStructHasMember) ###BEGIN configure parameters### if (WIN32) check_symbol_exists("gmtime_s" "time.h" HAVE_W32_GMTIME_S) else (WIN32) check_symbol_exists("gmtime_s" "time.h" HAVE_C11_GMTIME_S) endif (WIN32) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") message(STATUS "Not checking for pthread_setname_np because it only has one parameter on Mac.") endif() if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") check_symbol_exists("pthread_setname_np" "pthread.h" HAVE_PTHREAD_SETNAME_NP) endif() check_symbol_exists("accept4" "sys/types.h" HAVE_ACCEPT4) check_symbol_exists("clock_gettime" "time.h" HAVE_CLOCK_GETTIME) check_symbol_exists("gmtime_r" "time.h" HAVE_GMTIME_R) check_symbol_exists("SOCK_NONBLOCK" "sys/types.h;sys/socket.h" HAVE_SOCK_NONBLOCK) check_symbol_exists("tsearch" "search.h" HAVE_TSEARCH) check_symbol_exists("sendfile64" "sys/sendfile.h" HAVE_SENDFILE64) check_symbol_exists("_lseeki64" "io.h" HAVE___LSEEKI64) check_symbol_exists("lseek64" "unistd.h" HAVE_LSEEK64) check_symbol_exists("snprintf" "stdio.h" HAVE_SNPRINTF) check_symbol_exists("random" "stdlib.h" HAVE_RANDOM) check_symbol_exists("rand" "stdlib.h" HAVE_RAND) check_symbol_exists("pipe2" "unistd.h" HAVE_PIPE2_FUNC) check_symbol_exists("gethrtime" "sys/time.h" HAVE_GETHRTIME) check_symbol_exists("clock_get_time" "mach/clock.h" HAVE_CLOCK_GET_TIME) check_symbol_exists("poll" "poll.h" HAVE_POLL) check_symbol_exists("pthread_setname_np" "pthread.h" HAVE_PTHREAD_SETNAME_NP_GNU) check_include_file("fcntl.h" HAVE_FCNTL_H) check_include_file("gcrypt.h" HAVE_GCRYPT_H) check_include_file("inttypes.h" HAVE_INTTYPES_H) check_include_file("limits.h" HAVE_LIMITS_H) check_include_file("memory.h" HAVE_MEMORY_H) check_include_file("netdb.h" HAVE_NETDB_H) check_include_file("netinet/in.h" HAVE_NETINET_IN_H) check_include_file("netinet/tcp.h" HAVE_NETINET_TCP_H) check_include_file("poll.h" HAVE_POLL_H) check_include_file("pthread.h" HAVE_PTHREAD_H) check_include_file("search.h" HAVE_SEARCH_H) if (UNIX) check_struct_has_member("struct sockaddr_in" "sin_len" "sys/types.h netinet/in.h sys/socket.h" HAVE_SOCKADDR_IN_SIN_LEN) endif (UNIX) check_include_file("string.h" HAVE_STRING_H) check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) check_include_file("sys/msg.h" HAVE_SYS_MSG_H) check_include_file("sys/select.h" HAVE_SYS_SELECT_H) check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H) check_include_file("sys/stat.h" HAVE_SYS_STAT_H) check_include_file("sys/time.h" HAVE_SYS_TIME_H) check_include_file("sys/types.h" HAVE_SYS_TYPES_H) check_include_file("time.h" HAVE_TIME_H) check_include_file("unistd.h" HAVE_TUNISTD_H) check_include_file("winsock2.h" HAVE_WINSOCK2_H) check_include_file("ws2tcpip.h" HAVE_WS2TCPIP_H) check_include_file ("endian.h" HAVE_ENDIAN_H) check_include_file ("sys/param.h" HAVE_SYS_PARAM_H) check_include_file ("machine/endian.h" HAVE_MACHINE_ENDIAN_H) check_include_file ("sys/endian.h" HAVE_SYS_ENDIAN_H) check_include_file ("sys/byteorder.h" HAVE_SYS_BYTEORDER_H) check_include_file ("sys/machine.h" HAVE_SYS_MACHINE_H) check_include_file ("machine/param.h" HAVE_MACHINE_PARAM_H) check_include_file ("sys/isa_defs.h" HAVE_SYS_ISA_DEFS_H) check_include_file ("unistd.h" HAVE_UNISTD_H) check_include_file ("stdbool.h" HAVE_STDBOOL_H) check_include_file ("pthread_np.h" HAVE_PTHREAD_NP_H) check_include_file ("stddef.h" HAVE_STDDEF_H) check_include_file ("sys/ioctl.h" HAVE_SYS_IOCTL_H) check_include_file ("arpa/inet.h" HAVE_ARPA_INET_H) check_include_file ("netinet/ip.h" HAVE_NETINET_IP_H) check_include_files("assert.h;limits.h;signal.h;stdlib.h;ctype.h;locale.h;stdarg.h;string.h;errno.h; math.h;stddef.h;time.h;float.h;setjmp.h;stdio.h" STDC_HEADERS) ###END configure parameters### add_definitions(-DTCP_FASTOPEN) add_definitions(-DBUILDING_MHD_LIB) add_definitions(-D_MHD_bool=int) if (WIN32) add_definitions (-D_CRT_SECURE_NO_WARNINGS) add_definitions(-DWINDOWS=1) add_definitions(-DWIN32) add_definitions(-D_MHD_ITC_SOCKETPAIR) if (BUILD_SHARED_LIBS) add_definitions(-DMHD_W32DLL) else (BUILD_SHARED_LIBS) add_definitions(-DMHD_W32LIB) endif (BUILD_SHARED_LIBS) endif (WIN32) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/MHD_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/MHD_config.h) include_directories(src/microhttpd) include_directories(src/include) include_directories (${CMAKE_CURRENT_BINARY_DIR}) set (PUBLIC_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/include/microhttpd.h ) set (HEADER_FILES ${PUBLIC_HEADER_FILES} ${CMAKE_CURRENT_BINARY_DIR}/MHD_config.h ${CMAKE_CURRENT_SOURCE_DIR}/src/include/platform.h ${CMAKE_CURRENT_SOURCE_DIR}/src/include/autoinit_funcs.h ${CMAKE_CURRENT_SOURCE_DIR}/src/include/mhd_options.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/connection.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/internal.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/memorypool.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_mono_clock.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_limits.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_byteorder.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/sysfdsetsize.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_str.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_threads.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_locks.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_sockets.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_itc.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_itc_types.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_compat.h ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/response.h ) set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/connection.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/reason_phrase.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/daemon.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/internal.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/memorypool.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_mono_clock.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/sysfdsetsize.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_str.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_threads.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_sockets.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_itc.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/response.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/mhd_compat.c ) if (BAUTH_SUPPORT) set (SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/basicauth.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/base64.c ) set (HEADER_FILES ${HEADER_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/base64.h) endif (BAUTH_SUPPORT) if (DAUTH_SUPPORT) set (SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/digestauth.c ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/md5.c ) set (HEADER_FILES ${HEADER_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/md5.h) endif (DAUTH_SUPPORT) if (HTTPS_SUPPORT) set (SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/connection_https.c) set (HEADER_FILES ${HEADER_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/connection_https.h) endif (HTTPS_SUPPORT) if (NOT HAVE_TSEARCH) set (SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/tsearch.c) set (HEADER_FILES ${HEADER_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/src/microhttpd/tsearch.h) endif (NOT HAVE_TSEARCH) add_library(microhttpd ${SOURCE_FILES} ${HEADER_FILES} ) install (TARGETS microhttpd RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) install (FILES ${PUBLIC_HEADER_FILES} DESTINATION include)