mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
More refactoring; moving away from "statically link" everything to
"bundle everything".
This commit is contained in:
parent
deed24b1c2
commit
86b0200b27
@ -8,14 +8,19 @@ 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 "[configure-bsd-paths] resolved BSD_PATH_PREFIX to: '${BSD_PATH_PREFIX}'")
|
||||
|
||||
list(
|
||||
APPEND
|
||||
VENDOR_INCLUDE_DIRECTORIES
|
||||
"${BSD_PATH_PREFIX}/include"
|
||||
"${BSD_PATH_PREFIX}/opt/openssl/include"
|
||||
"${BSD_PATH_PREFIX}/opt/ncurses/include")
|
||||
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")
|
||||
endif ()
|
@ -2,7 +2,7 @@
|
||||
if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
# in Linux/BSD distributions we can specify the magic "$ORIGIN" value for
|
||||
# the rpath for the dymamic linker to search the executable's directory
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/lib/")
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
# note: macOS does not use $ORIGIN, and uses @executable_path/ instead. we
|
||||
# add a custom post build step at the bottom of this file to add this value
|
||||
|
@ -1,18 +1,20 @@
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
message(STATUS "[static linking] enabling static linking...")
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
message(STATUS "[standalone-build] ENABLED!")
|
||||
|
||||
set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost-bin")
|
||||
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_NO_BOOST_CMAKE ON)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/include")
|
||||
list(
|
||||
APPEND
|
||||
VENDOR_INCLUDE_DIRECTORIES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/include")
|
||||
|
||||
list(
|
||||
APPEND
|
||||
@ -22,7 +24,6 @@ if (${LINK_STATICALLY} MATCHES "true")
|
||||
"${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!")
|
||||
message(STATUS "[standalone-build] *NOT* enabled!")
|
||||
endif()
|
@ -21,7 +21,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
endif()
|
||||
|
||||
# copy boost and ffmpeg libraries (which can't be statically linked) to bin/
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
message(STATUS "[post-build] copying boost and ffmpeg libs...")
|
||||
add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/stage-static-vendor-libraries.sh")
|
||||
endif()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
#cmake -DGENERATE_DEB=1 -DDEB_ARCHITECTURE=i386|amd64|armhf -DDEB_PLATFORM=ubuntu -DDEB_DISTRO=eoan -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
|
||||
#cmake -DCMAKE_BUILD_TYPE=Release -DLINK_STATICALLY=true .
|
||||
#cmake -DCMAKE_BUILD_TYPE=Release - -DBUILD_STANDALONE=true .
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
@ -18,7 +18,7 @@ include(CMakeToolsHelpers OPTIONAL)
|
||||
include(CheckDependencies)
|
||||
include(CheckAtomic)
|
||||
include(ConfigureRpath)
|
||||
include(ConfigureStaticPaths) # highest priority lib paths
|
||||
include(ConfigureStandalone)
|
||||
include(ConfigureBsdPaths)
|
||||
include(AddDarwinSystemLibs)
|
||||
include(ConfigureCurses)
|
||||
@ -26,6 +26,7 @@ include(ConfigureTaglib)
|
||||
include(ConfigureCompilerFlags)
|
||||
|
||||
message(STATUS "[vendor-link-directories] ${VENDOR_LINK_DIRECTORIES}")
|
||||
message(STATUS "[vendor-include-directories] ${VENDOR_INCLUDE_DIRECTORIES}")
|
||||
|
||||
# our include directories
|
||||
include_directories(
|
||||
@ -43,10 +44,10 @@ include_directories(${Boost_INCLUDE_DIRS})
|
||||
message(STATUS "[boost] libs: " ${Boost_LIBRARIES})
|
||||
message(STATUS "[boost] includes: " ${Boost_INCLUDE_DIRS})
|
||||
|
||||
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})
|
||||
find_library(LIBCURL NAMES curl PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(LIBSSL NAMES ssl)
|
||||
find_library(LIBCRYPTO NAMES crypto)
|
||||
find_library(LIBZ NAMES z)
|
||||
|
||||
set(musikcube_LINK_LIBS ${DEFAULT_OS_SYSTEM_LIBS} ${Boost_LIBRARIES} ${LIBCURL} ${LIBSSL} ${LIBCRYPTO} ${LIBZ})
|
||||
|
||||
|
@ -12,7 +12,7 @@ SCRIPTDIR=`dirname "$0"`
|
||||
rm -rf bin/
|
||||
|
||||
${SCRIPTDIR}/clean-nix.sh
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DLINK_STATICALLY=true .
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_STANDALONE=true .
|
||||
make -j7
|
||||
|
||||
DIRNAME="musikcube_macos_$VERSION"
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
install_name_tool -add_rpath "@executable_path/" bin/musikcube
|
||||
install_name_tool -add_rpath "@executable_path/lib" bin/musikcube
|
||||
install_name_tool -add_rpath "@executable_path/" bin/musikcubed
|
||||
install_name_tool -add_rpath "@executable_path/lib" bin/musikcubed
|
||||
exit 0
|
@ -6,10 +6,23 @@ if [[ "$PLATFORM" == 'Darwin' ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p bin/lib/
|
||||
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/
|
||||
cp vendor/ffmpeg-bin/lib/libavcodec-musikcube.so.59 ./bin/plugins/
|
||||
cp vendor/ffmpeg-bin/lib/libavformat-musikcube.so.59 ./bin/plugins
|
||||
cp vendor/ffmpeg-bin/lib/libavutil-musikcube.so.57 ./bin/plugins
|
||||
cp vendor/ffmpeg-bin/lib/libswresample-musikcube.so.4 ./bin/plugins
|
||||
|
||||
cp vendor/boost-bin/lib/libboost_filesystem.so.1.78.0 ./bin/lib/
|
||||
cp vendor/boost-bin/lib/libboost_thread.so.1.78.0 ./bin/lib/
|
||||
cp vendor/ffmpeg-bin/lib/libavcodec-musikcube.so.59 ./bin/lib/
|
||||
cp vendor/ffmpeg-bin/lib/libavformat-musikcube.so.59 ./bin/lib/
|
||||
cp vendor/ffmpeg-bin/lib/libavutil-musikcube.so.57 ./bin/lib/
|
||||
cp vendor/ffmpeg-bin/lib/libswresample-musikcube.so.4 ./bin/lib/
|
||||
cp vendor/curl-bin/lib/libcurl.so.4 ./bin/lib/
|
||||
|
||||
cp /lib/x86_64-linux-gnu/libssl.so.1.1 ./bin/lib/
|
||||
cp /lib/x86_64-linux-gnu/libcrypto.so.1.1 ./bin/lib/
|
||||
cp /lib/x86_64-linux-gnu/libz.so.1 ./bin/lib/
|
||||
cp /lib/x86_64-linux-gnu/libmp3lame.so.0 ./bin/lib/
|
||||
cp /lib/x86_64-linux-gnu/libopenmpt.so.0 ./bin/lib
|
||||
cp /lib/x86_64-linux-gnu/libmpg123.so.0 ./bin/lib
|
||||
cp /lib/x86_64-linux-gnu/libvorbis.so.0 ./bin/lib
|
||||
cp /lib/x86_64-linux-gnu/libvorbisfile.so.3 ./bin/lib
|
||||
cp /lib/x86_64-linux-gnu/libogg.so.0 ./bin/lib
|
||||
|
@ -80,7 +80,7 @@ add_executable(musikcube ${CUBE_SRCS})
|
||||
add_definitions(-DNCURSES_WIDECHAR)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
find_library(
|
||||
NCURSESWLIB
|
||||
NAMES libncursesw.a ncursesw
|
||||
|
@ -12,7 +12,7 @@ endif()
|
||||
configure_file("musikcubed.in" "musikcubed" @ONLY)
|
||||
add_executable(musikcubed ${DAEMON_SRCS})
|
||||
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
find_library(EVLIB NAMES libev.a ev)
|
||||
target_link_libraries(musikcubed ${musikcube_LINK_LIBS} ${EVLIB} musikcore)
|
||||
else()
|
||||
|
@ -1,23 +1,23 @@
|
||||
set (ffmpegdecoder_SOURCES
|
||||
plugin.cpp
|
||||
FfmpegDecoder.cpp
|
||||
)
|
||||
FfmpegDecoder.cpp)
|
||||
|
||||
add_library(ffmpegdecoder SHARED ${ffmpegdecoder_SOURCES})
|
||||
target_include_directories(ffmpegdecoder PRIVATE BEFORE ${VENDOR_INCLUDE_DIRECTORIES})
|
||||
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
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})
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
find_library(AVCODEC NAMES avcodec-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(AVUTIL NAMES avutil-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(AVFORMAT NAMES avformat-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(SWRESAMPLE NAMES swresample-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
else()
|
||||
# fedora (and probably other RPM-based distros) put ffmpeg includes here...
|
||||
include_directories("/usr/include/ffmpeg")
|
||||
include_directories("/usr/local/include/ffmpeg")
|
||||
ensure_library_exists(avcodec)
|
||||
ensure_library_exists(avutil)
|
||||
ensure_library_exists(avformat)
|
||||
ensure_library_exists(swresample)
|
||||
target_link_libraries(ffmpegdecoder avcodec avutil avformat swresample)
|
||||
find_library(AVCODEC NAMES avcodec)
|
||||
find_library(AVUTIL NAMES avutil)
|
||||
find_library(AVFORMAT NAMES avformat)
|
||||
find_library(SWRESAMPLE NAMES swresample)
|
||||
endif()
|
||||
|
||||
target_link_libraries(ffmpegdecoder ${AVCODEC} ${AVUTIL} ${AVFORMAT} ${SWRESAMPLE})
|
||||
|
@ -10,16 +10,7 @@ ensure_library_exists(openmpt)
|
||||
|
||||
add_library(openmptdecoder SHARED ${openmptdecoder_SOURCES})
|
||||
|
||||
# prefer static libraries on mac to make redist easier
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
ensure_library_exists(mpg123)
|
||||
find_library(OPENMPTLIB NAMES libopenmpt.a openmpt)
|
||||
find_library(MPG123LIB NAMES libmpg123.a mpg123)
|
||||
find_library(ZLIB NAMES libz.a z)
|
||||
message(STATUS "[libopenmptdecoder] using ${OPENMPTLIB}")
|
||||
message(STATUS "[libopenmptdecoder] using ${MPG123LIB}")
|
||||
message(STATUS "[libopenmptdecoder] using ${ZLIB}")
|
||||
target_link_libraries(openmptdecoder ${OPENMPTLIB} ${MPG123LIB} ${ZLIB})
|
||||
else()
|
||||
target_link_libraries(openmptdecoder openmpt)
|
||||
endif()
|
||||
find_library(OPENMPTLIB NAMES openmpt)
|
||||
find_library(MPG123LIB NAMES mpg123)
|
||||
find_library(ZLIB NAMES z)
|
||||
target_link_libraries(openmptdecoder ${OPENMPTLIB} ${MPG123LIB} ${ZLIB})
|
||||
|
@ -10,25 +10,23 @@ set (server_SOURCES
|
||||
|
||||
add_library(server SHARED ${server_SOURCES})
|
||||
|
||||
set (server_LINK_LIBS ${Boost_LIBRARIES})
|
||||
target_include_directories(
|
||||
server
|
||||
BEFORE PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include"
|
||||
${VENDOR_INCLUDE_DIRECTORIES})
|
||||
|
||||
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include")
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
# unclear why NO_DEFAULT_PATH NO_CACHE is required; we want to use our vendor'd version,
|
||||
# but without NO_CACHE we always get the brew one. other deps are fine.
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
find_library(LIBMICROHTTPD NAMES libmicrohttpd.a PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH NO_CACHE)
|
||||
find_library(LIBZ NAMES libz.a PATHS ${VENDOR_LINK_DIRECTORIES})
|
||||
else()
|
||||
if (APPLE)
|
||||
find_library(LIBGNUTLS NAMES gnuatls)
|
||||
set(EXTRA_LIBS "${LIBGNUTLS}")
|
||||
endif()
|
||||
find_library(LIBMICROHTTPD NAMES microhttpd)
|
||||
find_library(LIBZ NAMES z)
|
||||
endif()
|
||||
|
||||
find_library(LIBZ NAMES z)
|
||||
message(STATUS "[server] using " ${LIBMICROHTTPD} ", " ${LIBZ})
|
||||
|
||||
target_link_libraries(server ${server_LINK_LIBS} ${LIBZ} ${LIBMICROHTTPD} ${EXTRA_LIBS})
|
||||
target_link_libraries(server ${LIBZ} ${LIBMICROHTTPD} ${EXTRA_LIBS})
|
||||
|
@ -1,36 +1,25 @@
|
||||
set (stockencoders_SOURCES
|
||||
main.cpp
|
||||
LameEncoder.cpp
|
||||
FfmpegEncoder.cpp
|
||||
)
|
||||
FfmpegEncoder.cpp)
|
||||
|
||||
add_library(stockencoders SHARED ${stockencoders_SOURCES})
|
||||
target_include_directories(stockencoders BEFORE PRIVATE ${VENDOR_INCLUDE_DIRECTORIES})
|
||||
|
||||
ensure_library_exists(mp3lame)
|
||||
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
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})
|
||||
if (${BUILD_STANDALONE} MATCHES "true")
|
||||
find_library(AVCODEC NAMES avcodec-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(AVUTIL NAMES avutil-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(AVFORMAT NAMES avformat-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
find_library(SWRESAMPLE NAMES swresample-musikcube PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH)
|
||||
else()
|
||||
# fedora (and probably other RPM-based distros) put ffmpeg includes here...
|
||||
include_directories("/usr/include/ffmpeg")
|
||||
include_directories("/usr/local/include/ffmpeg")
|
||||
ensure_library_exists(avcodec)
|
||||
ensure_library_exists(avutil)
|
||||
ensure_library_exists(avformat)
|
||||
ensure_library_exists(swresample)
|
||||
target_link_libraries(stockencoders ${musikcube_LINK_LIBS} avcodec avutil avformat swresample)
|
||||
find_library(AVCODEC NAMES avcodec)
|
||||
find_library(AVUTIL NAMES avutil)
|
||||
find_library(AVFORMAT NAMES avformat)
|
||||
find_library(SWRESAMPLE NAMES swresample)
|
||||
endif()
|
||||
|
||||
# prefer static libraries on mac to make redist easier
|
||||
if (${LINK_STATICALLY} MATCHES "true")
|
||||
find_library(MP3LAMELIB NAMES libmp3lame.a)
|
||||
target_link_libraries(stockencoders ${MP3LAMELIB})
|
||||
else()
|
||||
target_link_libraries(stockencoders mp3lame)
|
||||
endif()
|
||||
|
||||
target_link_libraries(stockencoders ${musikcube_LINK_LIBS})
|
||||
find_library(MP3LAME NAMES mp3lame)
|
||||
target_link_libraries(stockencoders ${AVCODEC} ${AVUTIL} ${AVFORMAT} ${SWRESAMPLE} ${MP3LAME})
|
||||
|
Loading…
Reference in New Issue
Block a user