more cleanups of CMakeLists.txt

This commit is contained in:
fduncanh
2021-11-24 21:35:55 -05:00
parent f412d208ca
commit e355394556
3 changed files with 55 additions and 85 deletions

View File

@@ -19,50 +19,18 @@ if( UNIX AND NOT APPLE )
add_definitions( -DSUPPRESS_AVAHI_COMPAT_WARNING )
endif()
if( UNIX AND NOT APPLE )
find_package(PkgConfig REQUIRED)
pkg_check_modules(PLIST libplist>=2.0)
if(NOT PLIST_FOUND)
pkg_check_modules(PLIST REQUIRED libplist-2.0)
endif()
endif()
add_subdirectory( lib/llhttp )
add_subdirectory( lib/playfair )
add_subdirectory( lib )
add_subdirectory( renderers )
add_executable( uxplay uxplay.cpp )
if( UNIX AND NOT APPLE )
include_directories( uxplay ${GST_INCLUDE_DIRS} )
else()
include_directories( uxplay
/Library/FrameWorks/GStreamer.framework/Headers/
/usr/local/include
/usr/local/include/glib-2.0
/usr/local/lib/glib-2.0/include
/opt/local/include
/opt/local/include/glib-2.0
/opt/local/lib/glib-2.0/include
)
endif()
include_directories( uxplay ${GST_INCLUDE_DIRS} )
target_link_libraries( uxplay
renderers
airplay
)
if ( UNIX AND NOT APPLE )
target_link_directories( uxplay PUBLIC
${GST_LIBRARY_DIRS}
${PLIST_LIBRARY_DIRS}
)
target_link_libraries( uxplay ${PLIST_LIBRARIES} )
endif()
install( TARGETS uxplay RUNTIME DESTINATION bin )
install( FILES uxplay.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
install( FILES README.md README.txt README.html LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR} )

View File

@@ -13,7 +13,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -march=native -DSTANDALONE -D__STDC_C
if( APPLE )
set( ENV{PKG_CONFIG_PATH} "/usr/local/lib/pkgconfig" ) # standard location, and Brew
set( ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/opt/local/lib/pkgconfig/" ) # MacPorts
set( ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/openssl@1.1/lib/pkgconfig" ) # Brew openssl
set( ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/openssl@3/lib/pkgconfig" ) # Brew openssl
message( "PKG_CONFIG_PATH (Apple, lib) = " $ENV{PKG_CONFIG_PATH} )
find_program( PKG_CONFIG_EXECUTABLE pkg-config PATHS /Library/FrameWorks/GStreamer.framework/Commands )
message( "PKG_CONFIG_EXECUTABLE " ${PKG_CONFIG_EXECUTABLE} )
@@ -23,20 +23,32 @@ find_package(PkgConfig REQUIRED)
aux_source_directory(. play_src)
set(DIR_SRCS ${play_src})
add_library( airplay
STATIC
${DIR_SRCS}
)
target_link_libraries( airplay
pthread
playfair
llhttp )
add_library( airplay STATIC
${DIR_SRCS}
)
if ( APPLE )
target_link_libraries( airplay
pthread
playfair
llhttp )
else()
target_link_libraries( airplay PUBLIC
pthread
playfair
llhttp )
endif()
# libplist
if( UNIX AND NOT APPLE )
target_include_directories( airplay PUBLIC ${PLIST_INCLUDE_DIRS} )
link_directories( ${PLIST_LIBRARY_DIRS} )
target_link_libraries ( airplay ${PLIST_LBRARIES} )
pkg_search_module(PLIST libplist>=2.0)
if(NOT PLIST_FOUND)
pkg_search_module(PLIST REQUIRED libplist-2.0)
endif()
target_include_directories( airplay PRIVATE ${PLIST_INCLUDE_DIRS} )
find_library( LIBPLIST ${PLIST_LIBRARIES} PATH ${PLIST_LIBDIR} )
target_link_libraries ( airplay PUBLIC ${LIBPLIST} )
elseif( APPLE )
# use static linking
pkg_check_modules( PLIST REQUIRED libplist-2.0 )
@@ -46,14 +58,14 @@ elseif( APPLE )
/opt/local/include # MacPorts
)
message( STATUS "LIBPLIST " ${LIBPLIST} )
target_link_libraries ( airplay ${LIBPLIST} )
target_link_libraries ( airplay ${LIBPLIST} )
endif()
#libcrypto
if( UNIX AND NOT APPLE )
find_package(OpenSSL 1.1.1 REQUIRED)
target_compile_definitions( airplay PUBLIC OPENSSL_API_COMPAT=0x10101000L )
target_link_libraries( airplay OpenSSL::Crypto )
target_link_libraries( airplay PUBLIC OpenSSL::Crypto )
elseif( APPLE )
# use static linking
# can either compile Openssl 1.1.1 from source (install_dev to /usr/local) or use Macports or Brew
@@ -67,7 +79,7 @@ elseif( APPLE )
if( LIBCRYPTO MATCHES "/opt/local/lib/libcrypto.a" ) #MacPorts openssl
find_library( LIBZ libz.a) # needed by MacPorts openssl
message("(MacPorts) LIBZ= " ${LIBZ} )
target_link_libraries( airplay ${LIBZ} )
target_link_libraries( airplay ${LIBZ} )
endif()
target_include_directories( airplay PRIVATE
${OPENSSL_INCLUDE_DIRS}
@@ -76,10 +88,10 @@ endif()
#dns_sd
if ( UNIX AND NOT APPLE )
pkg_check_modules(AVAHI_DNSSD avahi-compat-libdns_sd)
pkg_search_module(AVAHI_DNSSD avahi-compat-libdns_sd)
if (AVAHI_DNSSD_FOUND)
target_include_directories( airplay PUBLIC ${AVAHI_DNSSD_INCLUDE_DIRS} )
target_link_libraries( airplay ${AVAHI_DNSSD_LIBRARIES} )
target_include_directories( airplay PRIVATE ${AVAHI_DNSSD_INCLUDE_DIRS} )
find_library( DNSSD ${AVAHI_DNSSD_LIBRARIES} PATH ${AVAHI_DNSSD_LIBDIR})
else() # UxPlay can also build if mDNSResponder or another implementation of dns_sd is present instead of Avahi
find_library( DNSSD dns_sd )
if( NOT DNSSD )
@@ -93,7 +105,7 @@ if ( UNIX AND NOT APPLE )
else()
message( STATUS "found dns_sd.h in " ${DNSSD_INCLUDE_DIR} )
endif()
target_include_directories( airplay PUBLIC ${DNSSD_INCLUDE_DIR} )
target_link_libraries(airplay dns_sd )
target_include_directories( airplay PRIVATE ${DNSSD_INCLUDE_DIR} )
endif()
target_link_libraries(airplay PUBLIC ${DNSSD} )
endif()

View File

@@ -15,44 +15,34 @@ pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4
gstreamer-sdp-1.0>=1.4
gstreamer-video-1.0>=1.4
gstreamer-app-1.0>=1.4
)
message( "GST_LIBRARIES" ${GST_LIBRARIES} )
# hack to fix cmake confusion due to links in path
if( GST_LIBRARY_DIRS MATCHES "/Library/FrameWorks/GStreamer.framework/lib" )
set( GST_LIBRARY_DIRS "/Library/FrameWorks/GStreamer.framework/Libraries")
endif()
message( "GST_LIBRARY_DIRS " ${GST_LIBRARY_DIRS} )
message( "GST_CFLAGS " ${GST_CFLAGS} )
message( "GST_LDFLAGS " ${GST_LDFLAGS} )
message( "GST_INCLUDE_DIRS " ${GST_INCLUDE_DIRS} )
)
add_library( renderers
STATIC
audio_renderer_gstreamer.c
video_renderer_gstreamer.c )
if( UNIX AND NOT APPLE )
include_directories ( renderers ${GST_INCLUDE_DIRS} )
target_link_libraries ( renderers PUBLIC airplay )
# hack to fix cmake confusion due to links in path with macOS FrameWorks
if( GST_LIBRARY_DIRS MATCHES "/Library/FrameWorks/GStreamer.framework/lib" )
set( GST_INCLUDE_DIRS "/Library/FrameWorks/GStreamer.framework/Headers")
message( "GST_INCLUDE_DIRS" ${GST_INCLUDE_DIRS} )
target_include_directories ( renderers PRIVATE ${GST_INCLUDE_DIRS} )
if( CMAKE_VERSION VERSION_LESS "3.13.5" )
message( FATAL_ERROR "This macOS build needs cmake >= 3.13.5" )
endif()
set( GST_LIBRARY_DIRS "/Library/FrameWorks/GStreamer.framework/Libraries")
message( "GST_LIBRARY_DIRS" ${GST_LIBRARY_DIRS} )
target_link_libraries( renderers PUBLIC ${GST_LIBRARIES} )
target_link_directories ( renderers PUBLIC ${GST_LIBRARY_DIRS} )
else()
include_directories (renderers
/Library/FrameWorks/GStreamer.framework/Headers
/usr/local/include
/usr/local/include/gstreamer-1.0
/usr/local/include/glib-2.0
/usr/local/lib/glib-2.0/include
/opt/local/include/gstreamer-1.0
/opt/local/include/glib-2.0
/opt/local/lib/glib-2.0/include
)
target_include_directories ( renderers PRIVATE ${GST_INCLUDE_DIRS} )
if( CMAKE_VERSION VERSION_LESS "3.12.4" )
target_link_directories ( renderers PUBLIC ${GST_LIBRARY_DIRS} )
else()
target_link_libraries( renderers PUBLIC ${GST_LINK_LIBRARIES} )
endif()
endif()
target_link_libraries ( renderers PUBLIC
${GST_LIBRARIES}
airplay
)
if( APPLE )
message( "APPLE ONLY: \"target_link_directories\" used here requires CMake >= 3.13 ")
target_link_directories ( renderers PUBLIC ${GST_LIBRARY_DIRS} )
endif()