cmake_minimum_required(VERSION 3.2) project (icecast) #Need to use of own FindThreads module to rely on a pthreads implementation for WIN32 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/") include (CheckSymbolExists) include (CheckIncludeFile) include (CheckStructHasMember) include (CMakePushCheckState) include (CheckTypeSize) option (USE_YP "Use YP (requires CURL)" OFF) #Include YP support - requires Curl set (PACKAGE "icecast") set (PACKAGE_BUGREPORT "Bognor") #The address where bug reports for this package should be sent. set (PACKAGE_NAME "icecast") #The full name of this package. set (PACKAGE_VERSION "2.4.3") #The version of this package. set (PACKAGE_STRING "icecast-2.4.3") #The full name and version of this package. set (PACKAGE_TARNAME "icecast") #The one symbol short name of this package. set (PACKAGE_URL "http://bugger.bognor.com") #The home page of this package. find_package (iconv CONFIG REQUIRED) find_package (libxml CONFIG REQUIRED) find_package (libxslt CONFIG REQUIRED) find_package (ogg CONFIG REQUIRED) set (HAVE_OGG 1) find_package (vorbis CONFIG REQUIRED) find_package (Threads REQUIRED) #Use the FindThreads module in ${CMAKE_SOURCE_DIR}/cmake/Modules set (HAVE_PTHREAD 1) #check_symbol_exists ("pthread_spin_lock" "${PTHREAD_PATH}/pthread.h" HAVE_PTHREAD_SPIN_LOCK) set (HAVE_PTHREAD_SPIN_LOCK 1) find_package (Curl CONFIG) #Curl is complicated - CONFIG takes care of things, all kinds of things... if (CURL_FOUND) set (HAVE_CURL 1) #check_symbol_exists ("curl_global_init" "${CURL_PATH}/curl.h" HAVE_CURL_GLOBAL_INIT) set (HAVE_CURL_GLOBAL_INIT 1) set (HAVE_AUTH_URL TRUE) endif() find_package (OpenSSL) if (OPENSSL_FOUND) set (HAVE_OPENSSL 1) endif() if (WIN32) set (HAVE_GETADDRINFO TRUE) set (HAVE_GETNAMEINFO TRUE) set (HAVE_INET_ATON FALSE) set (HAVE_INET_PTON FALSE) else () cmake_push_check_state () set (CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=201112L) check_symbol_exists ("getaddrinfo" "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) check_symbol_exists ("getnameinfo" "sys/socket.h;netdb.h" HAVE_GETNAMEINFO) cmake_pop_check_state () check_symbol_exists ("inet_aton" "sys/socket.h;netinet/in.h;arpa/inet.h" HAVE_INET_ATON) check_symbol_exists ("inet_pton" "arpa/inet.h" HAVE_INET_PTON) endif (WIN32) check_symbol_exists ("chroot" "unistd.h" HAVE_CHROOT) check_symbol_exists ("endhostent" "netdb.h" HAVE_ENDHOSTENT) check_symbol_exists ("ftime" "sys/timedb.h" HAVE_FTIME) check_include_file ("grp.h" HAVE_GRP_H) check_include_file ("inttypes.h" HAVE_INTTYPES_H) check_symbol_exists ("localtime_r" "time.h" HAVE_LOCALTIME_R) check_include_file ("memory.h" HAVE_MEMORY_H) check_symbol_exists ("nanosleep" "time.h" HAVE_NANOSLEEP) check_symbol_exists ("gettimeofday" "sys/time.h" HAVE_GETTIMEOFDAY) check_symbol_exists ("poll" "poll.h" HAVE_POLL) check_include_file ("pwd.h" HAVE_PWD_H) check_symbol_exists ("sethostent" "netdb.h" HAVE_SETHOSTENT) check_symbol_exists ("setuid" "sys/types.h;unistd.h" HAVE_SETUID) check_include_file ("stdint.h" HAVE_STDINT_H) check_include_file ("strings.h" HAVE_STRINGS_H) check_include_file ("string.h" HAVE_STRING_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/timeb.h" HAVE_SYS_TIMEB_H) check_struct_has_member ("struct sockaddr_storage" "ss_family" "sys/socket.h" HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY LANGUAGE C) check_include_file ("sys/types.h" HAVE_SYS_TYPES_H) check_include_file ("sys/uio.h" HAVE_SYS_UIO_H) check_include_file ("unistd.h" HAVE_UNISTD_H) check_include_file ("winsock2.h" HAVE_WINSOCK2_H) check_symbol_exists ("writev" "sys/uio.h" HAVE_WRITEV) cmake_push_check_state () set (CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") check_type_size ("socklen_t" "SOCKLEN_T") #Defines HAVE_SOCKLEN_T if socklen_t exists cmake_pop_check_state () cmake_push_check_state () set (CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) check_symbol_exists ("strcasestr" "string.h" HAVE_STRCASESTR) cmake_pop_check_state () #Introspective checks on things that may have come from packages installed above #These are not quite on terms with the cmake philosophy, so we have commented #some of them out. find_path (XSLT_UTILS_PATH xsltutils.h PATH_SUFFIXES libxslt) if (XSLT_UTILS_PATH) #check_symbol_exists ("xsltSaveResultToString" "${XSLT_UTILS_PATH}/xsltutils.h" HAVE_XSLTSAVERESULTTOSTRING) set (HAVE_XSLTSAVERESULTTOSTRING 1) endif() find_path (KATE_PATH "kate.h" PATH_SUFFIXES kate) if (KATE_PATH) set (HAVE_KATE 1) endif() find_path (SPEEX_PATH "speex.h" PATH_SUFFIXES speex) if (SPEEX_PATH) set (HAVE_SPEEX 1) endif() find_path (THEORA_PATH "theora.h" PATH_SUFFIXES theora) if (THEORA_PATH) set (HAVE_THEORA 1) endif() configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h) add_executable (icecast "") target_sources (icecast PRIVATE admin.h admin.c auth.h auth.c auth_htpasswd.h auth_htpasswd.c cfgfile.h cfgfile.c client.h client.c connection.h connection.c event.h event.c format.h format.c format_ebml.h format_ebml.c format_flac.h format_flac.c format_kate.h format_kate.c format_midi.h format_midi.c format_mp3.h format_mp3.c format_ogg.h format_ogg.c format_opus.h format_opus.c format_skeleton.h format_skeleton.c format_vorbis.h format_vorbis.c fserve.h fserve.c global.h global.c logging.h logging.c md5.h md5.c refbuf.h refbuf.c sighandler.h sighandler.c slave.h slave.c source.h source.c stats.h stats.c util.h util.c xslt.h xslt.c compat.h main.c avl/avl.h avl/avl.c httpp/httpp.h httpp/httpp.c log/log.h log/log.c net/resolver.h net/resolver.c net/sock.h net/sock.c thread/thread.h thread/thread.c ) #The source files will explicitly include winsock2.h, so prevent windows.h #from including winsock.h, or there will be conflicts between winsock.h and #winsock2.h. if (WIN32) target_compile_definitions (icecast PRIVATE WIN32_LEAN_AND_MEAN) endif() if (HAVE_AUTH_URL) target_sources (icecast PRIVATE auth_url.h auth_url.c) endif(HAVE_AUTH_URL) if (USE_YP) target_sources (icecast PRIVATE yp.c yp.h) endif(USE_YP) if (HAVE_SPEEX) target_sources (icecast PRIVATE format_speex.c format_speex.h) endif() if (HAVE_THEORA) target_sources (icecast PRIVATE format_theora.c format_theora.h) endif() target_link_libraries (icecast PRIVATE libxml2::libxml2 libxslt::libxslt vorbis Threads::Threads) if (CURL_FOUND) target_link_libraries (icecast PRIVATE CURL::libcurl) endif() if (OpenSSL_FOUND) target_include_directories (icecast PRIVATE ${OPENSSL_INCLUDE_DIR}) target_link_libraries (icecast PRIVATE ${OPENSSL_LIBRARIES}) endif() target_include_directories (icecast PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions (icecast PRIVATE HAVE_CONFIG_H) target_compile_definitions (icecast PRIVATE _GNU_SOURCE) #necessary for strcasestr() if (MSVC) target_compile_definitions (icecast PRIVATE _CRT_SECURE_NO_WARNINGS) endif (MSVC) install (TARGETS icecast RUNTIME DESTINATION bin)