diff --git a/.cmake/AddDarwinSystemLibs.cmake b/.cmake/AddDarwinSystemLibs.cmake new file mode 100644 index 000000000..8efbdab0c --- /dev/null +++ b/.cmake/AddDarwinSystemLibs.cmake @@ -0,0 +1,9 @@ +if (APPLE) + find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) + find_library(SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration) + list( + APPEND + DEFAULT_OS_SYSTEM_LIBS + ${CORE_FOUNDATION_LIBRARY} + ${SYSTEM_CONFIGURATION_LIBRARY}) +endif() \ No newline at end of file diff --git a/.cmake/CheckDependencies.cmake b/.cmake/CheckDependencies.cmake index 73bd65fd5..e34a8da9c 100644 --- a/.cmake/CheckDependencies.cmake +++ b/.cmake/CheckDependencies.cmake @@ -5,7 +5,7 @@ function(ensure_library_exists libname) find_library( __TEMP_ENSURE_LIBRARY NAMES ${libname} - PATHS ${CURRENT_LINK_DIR}) + PATHS ${CURRENT_LINK_DIR} ${VENDOR_LINK_DIRECTORIES}) if(NOT __TEMP_ENSURE_LIBRARY) #message(STATUS "[check-dependencies] ${libname} not found") else() diff --git a/.cmake/ConfigureBsdPaths.cmake b/.cmake/ConfigureBsdPaths.cmake index 82f44d28d..d536530ad 100644 --- a/.cmake/ConfigureBsdPaths.cmake +++ b/.cmake/ConfigureBsdPaths.cmake @@ -8,10 +8,13 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE BSD_PATH_PREFIX) endif() - message(STATUS "resolved BSD_PATH_PREFIX to: '${BSD_PATH_PREFIX}'") - link_directories ("${BSD_PATH_PREFIX}/lib") - link_directories ("${BSD_PATH_PREFIX}/opt/openssl/lib") - link_directories ("${BSD_PATH_PREFIX}/opt/ncurses/lib") + message(STATUS "[configure-bsd-paths] resolved BSD_PATH_PREFIX to: '${BSD_PATH_PREFIX}'") + list( + APPEND + VENDOR_LINK_DIRECTORIES + "${BSD_PATH_PREFIX}/lib" + "${BSD_PATH_PREFIX}/opt/openssl/lib" + "${BSD_PATH_PREFIX}/opt/ncurses/lib") include_directories("${BSD_PATH_PREFIX}/include") include_directories("${BSD_PATH_PREFIX}/opt/openssl/include") include_directories("${BSD_PATH_PREFIX}/opt/ncurses/include") diff --git a/.cmake/ConfigureStaticLinking.cmake b/.cmake/ConfigureStaticLinking.cmake index 0e79233a9..050affa7a 100644 --- a/.cmake/ConfigureStaticLinking.cmake +++ b/.cmake/ConfigureStaticLinking.cmake @@ -5,8 +5,8 @@ if (${LINK_STATICALLY} MATCHES "true") set(BOOST_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost-bin/include") set(BOOST_LIBRARYDIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost-bin/lib") set(Boost_NO_SYSTEM_PATHS ON) - #set(Boost_USE_STATIC_LIBS ON) set(Boost_NO_BOOST_CMAKE ON) + set(Boost_USE_STATIC_LIBS ON) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/include") link_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/lib") @@ -22,6 +22,16 @@ if (${LINK_STATICALLY} MATCHES "true") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/include") link_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/lib") + + list( + APPEND + VENDOR_LINK_DIRECTORIES + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/lib" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/lib" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/lib" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/lib" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/lib") + else() message(STATUS "[static linking] static linking NOT enabled!") endif() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 445a92642..29cf38e6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,13 +17,16 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake) include(CMakeToolsHelpers OPTIONAL) include(CheckDependencies) include(CheckAtomic) -include(ConfigureCurses) include(ConfigureRpath) -include(ConfigureTaglib) +include(AddDarwinSystemLibs) include(ConfigureBsdPaths) +include(ConfigureCurses) +include(ConfigureTaglib) include(ConfigureCompilerFlags) include(ConfigureStaticLinking) +message(STATUS "[vendor-link-directories] ${VENDOR_LINK_DIRECTORIES}") + # our include directories include_directories( "${musikcube_SOURCE_DIR}/src" @@ -35,27 +38,26 @@ include_directories( # our library directories link_directories("${musikcube_SOURCE_DIR}/bin/plugins") -find_package(Boost 1.55.0 REQUIRED filesystem thread) +find_package(Boost 1.55.0 REQUIRED system filesystem thread) include_directories(${Boost_INCLUDE_DIRS}) message(STATUS "[boost] libs: " ${Boost_LIBRARIES}) message(STATUS "[boost] includes: " ${Boost_INCLUDE_DIRS}) -ensure_library_exists(curl) -ensure_library_exists(pthread) -ensure_library_exists(ssl) -ensure_library_exists(crypto) -ensure_library_exists(z) -find_library(LIBCURL NAMES libcurl.a) -find_library(LIBPTHREAD NAMES libpthread.a) -find_library(LIBSSL NAMES libssl.a) -find_library(LIBCRYPTO NAMES libcrypto.a) -find_library(LIBZ NAMES libz.a) +find_library(LIBCURL NAMES libcurl.a PATHS ${VENDOR_LINK_DIRECTORIES}) +find_library(LIBSSL NAMES libssl.a PATHS ${VENDOR_LINK_DIRECTORIES}) +find_library(LIBCRYPTO NAMES libcrypto.a PATHS ${VENDOR_LINK_DIRECTORIES}) +find_library(LIBZ NAMES libz.a PATHS ${VENDOR_LINK_DIRECTORIES}) -set(COMMON_LINK_LIBS ${Boost_LIBRARIES} ${LIBCURL} ${LIBPTHREAD} ${LIBSSL} ${LIBCRYPTO} ${LIBZ}) +set(musikcube_LINK_LIBS ${DEFAULT_OS_SYSTEM_LIBS} ${Boost_LIBRARIES} ${LIBCURL} ${LIBSSL} ${LIBCRYPTO} ${LIBZ}) if (CMAKE_SYSTEM_NAME MATCHES "Linux") find_library(LIBDL NAMES dl) - set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS} ${LIBDL}) + set (musikcube_LINK_LIBS ${musikcube_LINK_LIBS} ${LIBDL}) +endif() + +if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + find_library(LIBPTHREAD NAMES libpthread.a) + set (musikcube_LINK_LIBS ${musikcube_LINK_LIBS} ${LIBPTHREAD}) endif() if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) @@ -65,7 +67,7 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) endif() endif() -message(STATUS "[build] musikcube_LINK_LIBS: ${musikcube_LINK_LIBS}") +message(STATUS "[build] musikcube_LINK_LIBS: " ${musikcube_LINK_LIBS}) add_subdirectory(src/musikcore) #add_subdirectory(src/core_c_demo) @@ -73,7 +75,7 @@ add_subdirectory(src/musikcube) add_subdirectory(src/musikcubed) add_subdirectory(src/plugins/taglib_plugin) add_subdirectory(src/plugins/nullout) -add_subdirectory(src/plugins/server) +#add_subdirectory(src/plugins/server) add_subdirectory(src/plugins/httpdatastream) add_subdirectory(src/plugins/stockencoders) add_subdirectory(src/plugins/supereqdsp) diff --git a/script/bootstrap-static-vendors.sh b/script/bootstrap-static-vendors.sh index 1b6fa774e..5518919a1 100755 --- a/script/bootstrap-static-vendors.sh +++ b/script/bootstrap-static-vendors.sh @@ -4,6 +4,11 @@ rm -rf vendor mkdir vendor cd vendor +PLATFORM=$(uname) +if [[ "$PLATFORM" == 'Darwin' ]]; then + export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/homebrew/opt/openssl/lib/pkgconfig/" +fi + export CFLAGS="-fPIC" export CXXFLAGS="-fPIC" @@ -11,11 +16,12 @@ export CXXFLAGS="-fPIC" # boost # -wget https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.bz2 -tar xvfj boost_1_78_0.tar.bz2 -cd boost_1_78_0/ +wget https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_76_0.tar.bz2 +tar xvfj boost_1_76_0.tar.bz2 +cd boost_1_76_0/ ./bootstrap.sh -./b2 -d+2 cxxflags="-fPIC" --prefix=../boost-bin/ install +./b2 headers +./b2 -d -j8 -sNO_LZMA=1 -sNO_ZSTD=1 threading=multi link=shared,static cxxflags="-fPIC -std=c++14 -stdlib=libc++" --prefix=../boost-bin/ install || exit $? cd .. # @@ -190,7 +196,7 @@ cd ffmpeg-5.0 --enable-encoder=wmav2 \ --disable-pthreads \ --build-suffix=-musikcube || exit $? -make || exit $? +make -j8 || exit $? make install cd .. @@ -202,7 +208,7 @@ wget https://phoenixnap.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.ta tar xvfz lame-3.100.tar.gz cd lame-3.100/ ./configure --enable-shared --enable-static --prefix=`pwd`/output -make +make -j8 || exit $? make install mv output ../lame-bin cd .. @@ -215,7 +221,7 @@ wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.75.tar.gz tar xvfz libmicrohttpd-0.9.75.tar.gz cd libmicrohttpd-0.9.75 ./configure --enable-shared --enable-static --with-pic --enable-https=no --disable-curl --prefix=`pwd`/output -make +make -j8 || exit $? make install mv output ../libmicrohttpd-bin cd .. @@ -228,7 +234,7 @@ wget https://zlib.net/zlib-1.2.11.tar.gz tar xvfz zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure --prefix=`pwd`/output -make +make -j8 || exit $? make install mv output ../zlib-bin cd .. @@ -265,10 +271,12 @@ cd curl-7.81.0 --disable-imap \ --disable-mqtt \ --disable-dict \ + --disable-ldap \ --without-brotli \ --without-libidn2 \ + --without-nghttp2 \ --prefix=`pwd`/output -make +make -j8 || exit $? make install mv output ../curl-bin cd .. \ No newline at end of file diff --git a/script/stage-static-vendor-libraries.sh b/script/stage-static-vendor-libraries.sh index 30f549758..753da2e67 100755 --- a/script/stage-static-vendor-libraries.sh +++ b/script/stage-static-vendor-libraries.sh @@ -1,5 +1,11 @@ #!/bin/bash +PLATFORM=$(uname) +if [[ "$PLATFORM" == 'Darwin' ]]; then + echo "[stage-static-vendor-libraries] no-op on darwin. not required." + exit 0 +fi + mkdir -p bin/plugins/ cp vendor/boost-bin/lib/libboost_filesystem.so.1.78.0 ./bin/ cp vendor/boost-bin/lib/libboost_thread.so.1.78.0 ./bin/ diff --git a/src/musikcore/CMakeLists.txt b/src/musikcore/CMakeLists.txt index 7c7e3667f..2dd13b23e 100644 --- a/src/musikcore/CMakeLists.txt +++ b/src/musikcore/CMakeLists.txt @@ -80,14 +80,9 @@ include_directories( ) add_definitions(-DMCSDK_DEFINE_EXPORTS) - add_library(musikcore SHARED ${CORE_SOURCES}) - -set_target_properties(musikcore PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${musikcube_SOURCE_DIR}/bin) - -target_link_libraries(musikcore) -target_link_libraries(musikcore ${Boost_LIBRARIES} ${musikcube_LINK_LIBS}) +set_target_properties(musikcore PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${musikcube_SOURCE_DIR}/bin) +target_link_libraries(musikcore ${musikcube_LINK_LIBS}) if (ENABLE_PCH MATCHES "true") message(STATUS "[musikcore] enabling precompiled headers") diff --git a/src/musikcube/CMakeLists.txt b/src/musikcube/CMakeLists.txt index 62e6cdacd..317cdd22b 100644 --- a/src/musikcube/CMakeLists.txt +++ b/src/musikcube/CMakeLists.txt @@ -84,12 +84,12 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin") find_library( NCURSESWLIB NAMES libncursesw.a ncursesw - PATHS "/usr/local/opt/ncurses/lib/") + PATHS ${VENDOR_LINK_DIRECTORIES}) find_library( PANELWLIB NAMES libpanelw.a panelw - PATHS "/usr/local/opt/ncurses/lib/") + PATHS ${VENDOR_LINK_DIRECTORIES}) message(STATUS "[musikcube] using libncursesw at " ${NCURSESWLIB}) message(STATUS "[musikcube] using libpanelw at " ${PANELWLIB}) diff --git a/src/plugins/coreaudioout/CMakeLists.txt b/src/plugins/coreaudioout/CMakeLists.txt index 53f47d88c..44f860350 100644 --- a/src/plugins/coreaudioout/CMakeLists.txt +++ b/src/plugins/coreaudioout/CMakeLists.txt @@ -3,15 +3,15 @@ set (coreaudioout_SOURCES CoreAudioOut.cpp ) -IF(APPLE) - FIND_LIBRARY(CORE_FOUNDATION_LIBRARY CoreFoundation) - FIND_LIBRARY(CORE_AUDIO_LIBRARY CoreAudio) - FIND_LIBRARY(AUDIO_TOOLBOX_LIBRARY AudioToolbox) - MARK_AS_ADVANCED (CORE_FOUNDATION_LIBRARY +if (APPLE) + find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) + find_library(CORE_AUDIO_LIBRARY CoreAudio) + find_library(AUDIO_TOOLBOX_LIBRARY AudioToolbox) + mark_as_advanced(CORE_FOUNDATION_LIBRARY CORE_AUDIO_LIBRARY AUDIO_TOOLBOX_LIBRARY) - SET(FRAMEWORK_LIBS ${CORE_FOUNDATION_LIBRARY} ${CORE_AUDIO_LIBRARY} ${AUDIO_TOOLBOX_LIBRARY}) -ENDIF (APPLE) + set(FRAMEWORK_LIBS ${CORE_FOUNDATION_LIBRARY} ${CORE_AUDIO_LIBRARY} ${AUDIO_TOOLBOX_LIBRARY}) -add_library(coreaudioout SHARED ${coreaudioout_SOURCES}) -target_link_libraries(coreaudioout ${FRAMEWORK_LIBS}) + add_library(coreaudioout SHARED ${coreaudioout_SOURCES}) + target_link_libraries(coreaudioout ${FRAMEWORK_LIBS}) +endif (APPLE) diff --git a/src/plugins/ffmpegdecoder/CMakeLists.txt b/src/plugins/ffmpegdecoder/CMakeLists.txt index f660b8489..824322edd 100644 --- a/src/plugins/ffmpegdecoder/CMakeLists.txt +++ b/src/plugins/ffmpegdecoder/CMakeLists.txt @@ -6,11 +6,11 @@ set (ffmpegdecoder_SOURCES add_library(ffmpegdecoder SHARED ${ffmpegdecoder_SOURCES}) if (${LINK_STATICALLY} MATCHES "true") - ensure_library_exists(avcodec-musikcube) - ensure_library_exists(avutil-musikcube) - ensure_library_exists(avformat-musikcube) - ensure_library_exists(swresample-musikcube) - target_link_libraries(ffmpegdecoder avcodec-musikcube avutil-musikcube avformat-musikcube swresample-musikcube) + find_library(AVCODEC NAMES libavcodec-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + find_library(AVUTIL NAMES libavutil-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + find_library(AVFORMAT NAMES libavformat-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + find_library(SWRESAMPLE NAMES libswresample-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + target_link_libraries(ffmpegdecoder ${AVCODEC} ${AVUTIL} ${AVFORMAT} ${SWRESAMPLE}) else() # fedora (and probably other RPM-based distros) put ffmpeg includes here... include_directories("/usr/include/ffmpeg") @@ -21,5 +21,3 @@ else() ensure_library_exists(swresample) target_link_libraries(ffmpegdecoder avcodec avutil avformat swresample) endif() - -#target_link_libraries(ffmpegdecoder ${musikcube_LINK_LIBS}) diff --git a/src/plugins/httpdatastream/CMakeLists.txt b/src/plugins/httpdatastream/CMakeLists.txt index bad06db88..9a9a6b786 100644 --- a/src/plugins/httpdatastream/CMakeLists.txt +++ b/src/plugins/httpdatastream/CMakeLists.txt @@ -6,4 +6,4 @@ set (httpdatastream_SOURCES ) add_library(httpdatastream SHARED ${httpdatastream_SOURCES}) -target_link_libraries(httpdatastream) +target_link_libraries(httpdatastream ${musikcube_LINK_LIBS}) diff --git a/src/plugins/stockencoders/CMakeLists.txt b/src/plugins/stockencoders/CMakeLists.txt index f32567d8f..9bd49523b 100644 --- a/src/plugins/stockencoders/CMakeLists.txt +++ b/src/plugins/stockencoders/CMakeLists.txt @@ -9,11 +9,11 @@ add_library(stockencoders SHARED ${stockencoders_SOURCES}) ensure_library_exists(mp3lame) if (${LINK_STATICALLY} MATCHES "true") - ensure_library_exists(avcodec-musikcube) - ensure_library_exists(avutil-musikcube) - ensure_library_exists(avformat-musikcube) - ensure_library_exists(swresample-musikcube) - target_link_libraries(stockencoders avcodec-musikcube avutil-musikcube avformat-musikcube swresample-musikcube) + find_library(AVCODEC NAMES libavcodec-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + find_library(AVUTIL NAMES libavutil-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + find_library(AVFORMAT NAMES libavformat-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + find_library(SWRESAMPLE NAMES libswresample-musikcube.a PATHS ${VENDOR_LINK_DIRECTORIES}) + target_link_libraries(stockencoders ${AVCODEC} ${AVUTIL} ${AVFORMAT} ${SWRESAMPLE}) else() # fedora (and probably other RPM-based distros) put ffmpeg includes here... include_directories("/usr/include/ffmpeg")