From 2dda27362785f9e7e3ec615f6c7eaf7328d6368c Mon Sep 17 00:00:00 2001 From: Naram Qashat Date: Tue, 19 Mar 2019 22:00:48 -0400 Subject: [PATCH] Add install rules to CMake scripts --- CMakeLists.txt | 26 ++++++++++++++++++++++++++ audacious/CMakeLists.txt | 4 ++++ cli/CMakeLists.txt | 7 +++++++ cmake/vgmstream.cmake | 36 ++++++++++++++++++++++++++++++++++++ fb2k/CMakeLists.txt | 7 +++++++ winamp/CMakeLists.txt | 7 +++++++ xmplay/CMakeLists.txt | 7 +++++++ 7 files changed, 94 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36d8dc14..466ab981 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,11 @@ if(WIN32) option(BUILD_FB2K "Build foobar2000 component" ON) set(FB2K_SDK_PATH CACHE PATH "Path to foobar2000 SDK") set(WTL_INCLUDE_PATH CACHE PATH "Path to WTL include directory") + set(FB2K_COMPONENT_INSTALL_PREFIX CACHE PATH "Path to foobar2000 component installation directory") option(BUILD_WINAMP "Build Winamp plugin" ON) + set(WINAMP_INSTALL_PREFIX CACHE PATH "Path to Winamp installation directory") option(BUILD_XMPLAY "Build XMPlay plugin" ON) + set(XMPLAY_INSTALL_PREFIX CACHE PATH "Path to XMPlay installation directory") else() option(BUILD_AUDACIOUS "Build Audacious plugin" ON) endif() @@ -102,6 +105,7 @@ else() if(BUILD_AUDACIOUS) include(FindPkgConfig) pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6) + pkg_get_variable(AUDACIOUS_PLUGIN_DIR audacious plugin_dir) pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0) endif() endif() @@ -168,6 +172,9 @@ add_subdirectory(src) if(WIN32) add_subdirectory(ext_libs) if(BUILD_WINAMP) + if(NOT WINAMP_INSTALL_PREFIX) + message(FATAL_ERROR "The path to Winamp must be set. (Use WINAMP_INSTALL_PREFIX, the plugin will be installed into the Plugins directory)") + endif() add_subdirectory(winamp) endif() if(BUILD_FB2K) @@ -177,6 +184,9 @@ if(WIN32) if(NOT WTL_INCLUDE_PATH) message(FATAL_ERROR "The path to the WTL include directory must be set. (Use WTL_INCLUDE_PATH)") endif() + if(NOT FB2K_COMPONENT_INSTALL_PREFIX) + message(FATAL_ERROR "The path to foobar2000 must be set. (Use FB2K_COMPONENT_INSTALL_PREFIX, this is where the component will be installed)") + endif() include_external_msproject(fb2k_sdk ${FB2K_SDK_PATH}/foobar2000/SDK/foobar2000_SDK.vcxproj) include_external_msproject(fb2k_sdk_helpers ${FB2K_SDK_PATH}/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj) include_external_msproject(fb2k_atl_helpers ${FB2K_SDK_PATH}/foobar2000/ATLHelpers/foobar2000_ATL_helpers.vcxproj) @@ -185,6 +195,9 @@ if(WIN32) add_subdirectory(fb2k) endif() if(BUILD_XMPLAY) + if(NOT XMPLAY_INSTALL_PREFIX) + message(FATAL_ERROR "The path to XMPlay must be set. (Use XMPlay_INSTALL_PREFIX, this is where the plugin will be installed)") + endif() add_subdirectory(xmplay) endif() else() @@ -227,3 +240,16 @@ else() message(STATUS " Audacious plugin: ${BUILD_AUDACIOUS}") endif() message(STATUS "") + +# Install Summary +message(STATUS " Install Paths") +message(STATUS "=========================") +message(STATUS " CLI: ${CMAKE_INSTALL_PREFIX}/bin") +if(WIN32) + message(STATUS "foobar2000 component: ${FB2K_COMPONENT_INSTALL_PREFIX}") + message(STATUS " Winamp plugin: ${WINAMP_INSTALL_PREFIX}/Plugins") + message(STATUS " XMPlay plugin: ${XMPLAY_INSTALL_PREFIX}") +else() + message(STATUS " Audacious plugin: ${AUDACIOUS_PLUGIN_DIR}/Input") +endif() +message(STATUS "") diff --git a/audacious/CMakeLists.txt b/audacious/CMakeLists.txt index 041ab877..8e79dee2 100644 --- a/audacious/CMakeLists.txt +++ b/audacious/CMakeLists.txt @@ -65,3 +65,7 @@ target_compile_features(audacious_vgmstream PRIVATE cxx_strong_enums cxx_variadic_macros cxx_variadic_templates) + +# Install the plugin +install(TARGETS audacious_vgmstream + DESTINATION ${AUDACIOUS_PLUGIN_DIR}/Input) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 7906b873..504c8dc9 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -32,7 +32,14 @@ if(WIN32) LINK_FLAGS "-static-libgcc -static-libstdc++") endif() endif() + + # Install the DLLs + install_dlls(${CMAKE_INSTALL_PREFIX}/bin) elseif(VGMSTREAM_VERSION) # Include the version string target_compile_definitions(vgmstream_cli PRIVATE VERSION="${VGMSTREAM_VERSION}") endif() + +# Install the CLI program +install(TARGETS vgmstream_cli + RUNTIME DESTINATION bin) diff --git a/cmake/vgmstream.cmake b/cmake/vgmstream.cmake index 4f0d70c8..0ea6d2ca 100644 --- a/cmake/vgmstream.cmake +++ b/cmake/vgmstream.cmake @@ -127,3 +127,39 @@ macro(setup_target TARGET) endif() endif() endmacro() + +# Installs the DLLs to the given install prefix +macro(install_dlls INSTALL_PREFIX) + # Paths to the DLLs + set(MPEG_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libmpg123-0.dll) + set(VORBIS_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libvorbis.dll) + set(G7221_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libg7221_decode.dll) + set(G719_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libg719_decode.dll) + set(FFMPEG_DLL + ${CMAKE_SOURCE_DIR}/ext_libs/avcodec-vgmstream-58.dll + ${CMAKE_SOURCE_DIR}/ext_libs/avformat-vgmstream-58.dll + ${CMAKE_SOURCE_DIR}/ext_libs/avutil-vgmstream-56.dll + ${CMAKE_SOURCE_DIR}/ext_libs/swresample-vgmstream-3.dll) + set(ATRAC9_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libatrac9.dll) + set(CELT_DLL + ${CMAKE_SOURCE_DIR}/ext_libs/libcelt-0061.dll + ${CMAKE_SOURCE_DIR}/ext_libs/libcelt-0110.dll) + + # List of DLLs to check for install + set(DLLS + MPEG + VORBIS + G7221 + G719 + FFMPEG + ATRAC9 + CELT) + + # Loop over DLLs and only install if the USE_* is set for that DLL + foreach(DLL ${DLLS}) + if(${USE_${DLL}}) + install(FILES ${${DLL}_DLL} + DESTINATION ${INSTALL_PREFIX}) + endif() + endforeach() +endmacro() diff --git a/fb2k/CMakeLists.txt b/fb2k/CMakeLists.txt index 619f6951..f9bb482a 100644 --- a/fb2k/CMakeLists.txt +++ b/fb2k/CMakeLists.txt @@ -72,3 +72,10 @@ elseif(MINGW) LINK_FLAGS "-static-libgcc -static-libstdc++") endif() endif() + +# Install the DLLs +install_dlls(${FB2K_COMPONENT_INSTALL_PREFIX}/foo_input_vgmstream) + +# Install the component +install(TARGETS foo_input_vgmstream + DESTINATION ${FB2K_COMPONENT_INSTALL_PREFIX}/foo_input_vgmstream) diff --git a/winamp/CMakeLists.txt b/winamp/CMakeLists.txt index f29be1bf..46f5f5f9 100644 --- a/winamp/CMakeLists.txt +++ b/winamp/CMakeLists.txt @@ -45,3 +45,10 @@ elseif(MINGW) LINK_FLAGS "-static-libgcc -static-libstdc++") endif() endif() + +# Install the DLLs +install_dlls(${XMPLAY_INSTALL_PREFIX}) + +# Install the plugin +install(TARGETS in_vgmstream + DESTINATION ${WINAMP_INSTALL_PREFIX}/Plugins) diff --git a/xmplay/CMakeLists.txt b/xmplay/CMakeLists.txt index 96361396..72411549 100644 --- a/xmplay/CMakeLists.txt +++ b/xmplay/CMakeLists.txt @@ -31,3 +31,10 @@ elseif(MINGW) LINK_FLAGS "-static-libgcc -static-libstdc++") endif() endif() + +# Install the DLLs +install_dlls(${XMPLAY_INSTALL_PREFIX}) + +# Install the plugin +install(TARGETS xmp-vgmstream + DESTINATION ${XMPLAY_INSTALL_PREFIX})