cmake_minimum_required(VERSION 3.4) #FindOpenSSL will introduce IMPORTED targets project (libshout) #Need to use our 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 (SHOUT_THREADSAFE "Thread safe" ON) option (SHOUT_TLS "TLS" OFF) set (LIBSHOUT_MAJOR 2) set (LIBSHOUT_MINOR 4) set (LIBSHOUT_MICRO 1) set (PACKAGE "libshout") set (PACKAGE_BUGREPORT "Bognor") #The address where bug reports for this package should be sent. set (PACKAGE_NAME "libshout") #The full name of this package. set (PACKAGE_VERSION "${LIBSHOUT_MAJOR}.${LIBSHOUT_MINOR}.${LIBSHOUT_MICRO}") #The version of this package. set (PACKAGE_STRING "libshout-2.4.1") #The full name and version of this package. set (PACKAGE_TARNAME "libshout") #The one symbol short name of this package. set (PACKAGE_URL "http://bugger.bognor.com") #The home page of this package. find_package (ogg CONFIG REQUIRED) set (HAVE_OGG 1) find_package (vorbis CONFIG REQUIRED) find_package (Speex) if (SPEEX_FOUND) set (HAVE_SPEEX 1) endif() find_package (Theora) if (THEORA_FOUND) set (HAVE_THEORA 1) endif() find_package (Threads REQUIRED) #Use the FindThreads module in ${CMAKE_SOURCE_DIR}/cmake/Modules set (HAVE_PTHREAD 1) set (HAVE_PTHREAD_SPIN_LOCK 1) if (SHOUT_TLS) find_package (openssl REQUIRED) 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() check_include_file ("dlfcn.h" HAVE_DLFCN_H) check_symbol_exists ("endhostent" "netdb.h" HAVE_ENDHOSTENT) check_symbol_exists ("ftime" "sys/timedb.h" HAVE_FTIME) check_include_file ("inttypes.h" HAVE_INTTYPES_H) check_include_file ("memory.h" HAVE_MEMORY_H) check_symbol_exists ("gettimeofday" "sys/time.h" HAVE_GETTIMEOFDAY) check_symbol_exists ("nanosleep" "time.h" HAVE_NANOSLEEP) check_symbol_exists ("sethostent" "netdb.h" HAVE_SETHOSTENT) check_include_file ("stdint.h" HAVE_STDINT_H) check_include_file ("stdlib.h" HAVE_STDLIB_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_struct_has_member ("struct sockaddr_storage" "ss_family" "sys/socket.h" HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY LANGUAGE C) 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_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 () check_type_size ("int" SIZEOF_INT) check_type_size ("long" SIZEOF_LONG) check_type_size ("long long" SIZEOF_LONG_LONG) check_type_size ("short" SIZEOF_SHORT) configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/include/shout/shout.h.in ${CMAKE_CURRENT_BINARY_DIR}/shout/shout.h ) configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h ) add_library (libshout "") target_sources (libshout PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/shout/shout.h ${CMAKE_CURRENT_BINARY_DIR}/config.h src/codec_opus.c src/codec_vorbis.c src/format_mp3.c src/format_ogg.c src/format_ogg.h src/format_webm.c src/proto_http.c src/proto_icy.c src/proto_roaraudio.c src/proto_xaudiocast.c src/queue.c src/shout.c src/shout_private.h src/util.c src/util.h src/common/avl/avl.c src/common/avl/avl.h src/common/httpp/encoding.c src/common/httpp/encoding.h src/common/httpp/httpp.c src/common/httpp/httpp.h src/common/net/resolver.c src/common/net/resolver.h src/common/net/sock.c src/common/net/sock.h src/common/thread/thread.c src/common/thread/thread.h src/common/timing/timing.c src/common/timing/timing.h ) #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 (libshout PRIVATE WIN32_LEAN_AND_MEAN) endif() if (HAVE_SPEEX) target_sources (libshout PRIVATE src/codec_speex.c) endif() if (HAVE_THEORA) target_sources (libshout PRIVATE src/codec_theora.c) endif() if (SHOUT_TLS) target_sources (libshout PRIVATE src/tls.c) target_link_libraries (libshout PRIVATE ${OPENSSL_LIBRARIES}) target_include_directories (libshout PRIVATE ${OPENSSL_INCLUDE_DIR}) endif() target_link_libraries (libshout PRIVATE ogg vorbis Threads::Threads) target_include_directories (libshout PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/common) target_compile_definitions (libshout PRIVATE HAVE_CONFIG_H) if (MSVC) target_compile_definitions (libshout PRIVATE _CRT_SECURE_NO_WARNINGS) endif (MSVC) install (TARGETS libshout EXPORT libshout-config RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib INCLUDES DESTINATION include) install (EXPORT libshout-config DESTINATION cmake) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/shout/shout.h DESTINATION include/shout)