diff --git a/README.md b/README.md index 679e1a5..e96df37 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ If you have any problems installing for your OS, you can contact me anytime in t * You will need CMake (v3.12 minimum) to build native dependencies as this project using cmake-js; you can download and install CMake [here](https://cmake.org/download/). Also, you will need a C++ compiler to build native libraries (Clang, GCC and MSVC are all supported). -* You will need to have Boost (version 1.65.0 minimum) installed on your system. You can find Boost [here](https://www.boost.org/users/download/). Only `date_time` and `system` libraries are required by this project. +* You will need to have Boost (version 1.65.0 minimum) installed on your system. You can find Boost [here](https://www.boost.org/users/download/).Only the `system` library is required by this project. * This app uses MPV via [mpv.js](https://github.com/Kagami/mpv.js) but you will need libmpv on your machine. You can find instructions on how to install libmpv [here](https://github.com/Kagami/mpv.js#get-libmpv). @@ -135,12 +135,15 @@ On Linux you'll need to install dependency packages first. Either from source or Here's the list of the dependencies: * (Required) A C/C++ Compiler, `gcc` is recommended. -* (Required) [Boost](https://www.boost.org/) > 1.65.0 -- Used by Libtorrent, only the `system` component is required. You can install `libboost-system-dev` using `apt` -* (Required) [LibtorrentRasterbar](https://www.libtorrent.org/) > 1.1.0 -- If you don't have any version installed, the build command will install it for you. You can install `libtorrent-rasterbar-dev` using `apt`. +* (Required) [Boost](https://www.boost.org/) > 1.65.0 -- Used by Libtorrent, only the `system` component is required. You can install `libboost-dev` or `libboost-all-dev` using `apt` +* (Optional) [LibtorrentRasterbar](https://www.libtorrent.org/) > 1.2 -- If you don't have any valid version installed, the build command will install it for you. * (Optional) [MPV](https://mpv.io/installation/) -- Only if you want to use the internal player. You can install `libmpv1` and `libavformat-dev` using `apt` +Once all those are installed, you can run the following commands. This will generate a `.snap` and a `.AppImage` in the `dist` folder that you can use. Alternatively you can +use the `kawanime` executable in the `dist/linux-unpacked` folder. + ``` -npm run postinstall +npm run install npm run dist:linux ``` diff --git a/bindings/torrent/CMakeLists.txt b/bindings/torrent/CMakeLists.txt index fc6a45c..a205595 100644 --- a/bindings/torrent/CMakeLists.txt +++ b/bindings/torrent/CMakeLists.txt @@ -23,8 +23,7 @@ add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) list(APPEND CMAKE_MODULE_PATH lib/libtorrent/cmake/Modules) # Libtorrent -find_package(LibtorrentRasterbar) -find_package(Boost REQUIRED COMPONENTS system) +find_package(LibtorrentRasterbar EXACT 1.2) if (LibtorrentRasterbar_FOUND) target_include_directories(${PROJECT_NAME} PRIVATE ${LibtorrentRasterbar_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) diff --git a/bindings/torrent/cmake/FindLibtorrentRasterbar.cmake b/bindings/torrent/cmake/FindLibtorrentRasterbar.cmake index fab0c60..7f9422e 100644 --- a/bindings/torrent/cmake/FindLibtorrentRasterbar.cmake +++ b/bindings/torrent/cmake/FindLibtorrentRasterbar.cmake @@ -1,8 +1,10 @@ -# Taken from https://github.com/steeve/libtorrent/blob/master/examples/cmake/FindLibtorrentRasterbar.cmake +# Taken from https://github.com/arvidn/libtorrent/blob/RC_1_2/examples/cmake/FindLibtorrentRasterbar.cmake # # - Try to find libtorrent-rasterbar # -# If not using pkg-config, you can pre-set LibtorrentRasterbar_CUSTOM_DEFINITIONS +# This module tries to locate libtorrent-rasterbar Config.cmake files and uses pkg-config if available +# and the config file could not be found. +# If that does not work, you can pre-set LibtorrentRasterbar_CUSTOM_DEFINITIONS # for definitions unrelated to Boost's separate compilation (which are already # decided by the LibtorrentRasterbar_USE_STATIC_LIBS variable). # @@ -12,85 +14,139 @@ # LibtorrentRasterbar_LIBRARIES - The libraries needed to use libtorrent-rasterbar # LibtorrentRasterbar_DEFINITIONS - Compiler switches required for using libtorrent-rasterbar # LibtorrentRasterbar_OPENSSL_ENABLED - libtorrent-rasterbar uses and links against OpenSSL +# LibtorrentRasterbar::torrent-rasterbar imported target will be created -find_package(PkgConfig QUIET) +# Let's begin with the config mode -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_LIBTORRENT_RASTERBAR QUIET libtorrent-rasterbar) +set(_exactKeyword "") +if (${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT}) + set(_exactKeyword "EXACT") endif() -if(LibtorrentRasterbar_USE_STATIC_LIBS) - set(LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) -endif() +find_package(LibtorrentRasterbar ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} ${_exactKeyword} CONFIG) -if(PC_LIBTORRENT_RASTERBAR_FOUND) - set(LibtorrentRasterbar_DEFINITIONS ${PC_LIBTORRENT_RASTERBAR_CFLAGS}) +if (LibtorrentRasterbar_FOUND) + if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + message(STATUS "LibtorrentRasterbar package found in ${LibtorrentRasterbar_DIR}") + message(STATUS "LibtorrentRasterbar version: ${LibtorrentRasterbar_VERSION}") + endif() + # Extract target properties into this module variables + get_target_property(LibtorrentRasterbar_INCLUDE_DIRS LibtorrentRasterbar::torrent-rasterbar INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(LibtorrentRasterbar_LIBRARIES LibtorrentRasterbar::torrent-rasterbar IMPORTED_LOCATION) + get_target_property(_iface_link_libs LibtorrentRasterbar::torrent-rasterbar INTERFACE_LINK_LIBRARIES) + list(APPEND LibtorrentRasterbar_LIBRARIES ${_iface_link_libs}) + get_target_property(LibtorrentRasterbar_DEFINITIONS LibtorrentRasterbar::torrent-rasterbar INTERFACE_COMPILE_DEFINITIONS) + get_target_property(_iface_compile_options LibtorrentRasterbar::torrent-rasterbar INTERFACE_COMPILE_OPTIONS) + list(APPEND LibtorrentRasterbar_DEFINITIONS ${_iface_compile_options}) + list(FIND _iface_link_libs "OpenSSL::SSL" _openssl_lib_index) + if (_openssl_lib_index GREATER -1) + set(LibtorrentRasterbar_OPENSSL_ENABLED TRUE) + else() + set(LibtorrentRasterbar_OPENSSL_ENABLED FALSE) + endif() else() - if(LibtorrentRasterbar_CUSTOM_DEFINITIONS) - set(LibtorrentRasterbar_DEFINITIONS ${LibtorrentRasterbar_CUSTOM_DEFINITIONS}) - else() - # Without pkg-config, we can't possibly figure out the correct build flags. - # libtorrent is very picky about those. Let's take a set of defaults and - # hope that they apply. If not, you the user are on your own. - set(LibtorrentRasterbar_DEFINITIONS - -DTORRENT_USE_OPENSSL - -DTORRENT_DISABLE_GEO_IP - -DBOOST_ASIO_ENABLE_CANCELIO - -DUNICODE -D_UNICODE -D_FILE_OFFSET_BITS=64) - endif() + find_package(Threads QUIET REQUIRED) + find_package(PkgConfig QUIET) - if(LibtorrentRasterbar_USE_STATIC_LIBS) - list(APPEND LibtorrentRasterbar_DEFINITIONS -DBOOST_ASIO_SEPARATE_COMPILATION) - else() - list(APPEND LibtorrentRasterbar_DEFINITIONS - -DTORRENT_LINKING_SHARED -DBOOST_ASIO_DYN_LINK - -DBOOST_DATE_TIME_DYN_LINK -DBOOST_THREAD_DYN_LINK - -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK) - endif() + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBTORRENT_RASTERBAR QUIET libtorrent-rasterbar) + endif() + + if(LibtorrentRasterbar_USE_STATIC_LIBS) + set(LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() + + if(PC_LIBTORRENT_RASTERBAR_FOUND) + set(LibtorrentRasterbar_DEFINITIONS ${PC_LIBTORRENT_RASTERBAR_CFLAGS_OTHER}) + else() + if(LibtorrentRasterbar_CUSTOM_DEFINITIONS) + set(LibtorrentRasterbar_DEFINITIONS ${LibtorrentRasterbar_CUSTOM_DEFINITIONS}) + else() + # Without pkg-config, we can't possibly figure out the correct build flags. + # libtorrent is very picky about those. Let's take a set of defaults and + # hope that they apply. If not, you the user are on your own. + set(LibtorrentRasterbar_DEFINITIONS + -DTORRENT_USE_OPENSSL + -DTORRENT_DISABLE_GEO_IP + -DBOOST_ASIO_ENABLE_CANCELIO + -D_FILE_OFFSET_BITS=64) + endif() + + if(NOT LibtorrentRasterbar_USE_STATIC_LIBS) + list(APPEND LibtorrentRasterbar_DEFINITIONS + -DTORRENT_LINKING_SHARED + -DBOOST_SYSTEM_DYN_LINK) + endif() + endif() + + if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + message(STATUS "libtorrent definitions: ${LibtorrentRasterbar_DEFINITIONS}") + endif() + + find_path(LibtorrentRasterbar_INCLUDE_DIR libtorrent + HINTS ${PC_LIBTORRENT_RASTERBAR_INCLUDEDIR} ${PC_LIBTORRENT_RASTERBAR_INCLUDE_DIRS} + PATH_SUFFIXES libtorrent-rasterbar) + + find_library(LibtorrentRasterbar_LIBRARY NAMES torrent-rasterbar + HINTS ${PC_LIBTORRENT_RASTERBAR_LIBDIR} ${PC_LIBTORRENT_RASTERBAR_LIBRARY_DIRS}) + + if(LibtorrentRasterbar_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() + + set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIR}) + + if(NOT Boost_SYSTEM_FOUND) + find_package(Boost QUIET REQUIRED COMPONENTS system) + set(LibtorrentRasterbar_LIBRARIES + ${LibtorrentRasterbar_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + set(LibtorrentRasterbar_INCLUDE_DIRS + ${LibtorrentRasterbar_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) + endif() + + list(FIND LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL LibtorrentRasterbar_ENCRYPTION_INDEX) + if(LibtorrentRasterbar_ENCRYPTION_INDEX GREATER -1) + find_package(OpenSSL QUIET REQUIRED) + set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${OPENSSL_LIBRARIES}) + set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) + set(LibtorrentRasterbar_OPENSSL_ENABLED ON) + endif() + + include(FindPackageHandleStandardArgs) + # handle the QUIETLY and REQUIRED arguments and set LibtorrentRasterbar_FOUND to TRUE + # if all listed variables are TRUE + find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG + LibtorrentRasterbar_LIBRARY + LibtorrentRasterbar_INCLUDE_DIR + Boost_SYSTEM_FOUND + ) + + mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY + LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES + LibtorrentRasterbar_ENCRYPTION_INDEX) + + if (LibtorrentRasterbar_FOUND AND NOT TARGET LibtorrentRasterbar::torrent-rasterbar) + add_library(LibtorrentRasterbar::torrent-rasterbar SHARED IMPORTED) + + # LibtorrentRasterbar_DEFINITIONS var contains a mix of -D, -f, and possible -std options + # let's split them into definitions and options (that are not definitions) + set(LibtorrentRasterbar_defines "${LibtorrentRasterbar_DEFINITIONS}") + set(LibtorrentRasterbar_options "${LibtorrentRasterbar_DEFINITIONS}") + list(FILTER LibtorrentRasterbar_defines INCLUDE REGEX "(^|;)-D.+") + list(FILTER LibtorrentRasterbar_options EXCLUDE REGEX "(^|;)-D.+") + # remove '-D' from LibtorrentRasterbar_defines + string(REGEX REPLACE "(^|;)(-D)" "\\1" LibtorrentRasterbar_defines "${LibtorrentRasterbar_defines}") + + set_target_properties(LibtorrentRasterbar::torrent-rasterbar PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${LibtorrentRasterbar_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LibtorrentRasterbar_INCLUDE_DIRS}" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${LibtorrentRasterbar_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${LibtorrentRasterbar_LIBRARIES}" + INTERFACE_COMPILE_DEFINITIONS "${LibtorrentRasterbar_defines}" + INTERFACE_COMPILE_OPTIONS "${LibtorrentRasterbar_options}" + ) + endif() endif() - -message(STATUS "libtorrent definitions: ${LibtorrentRasterbar_DEFINITIONS}") - -find_path(LibtorrentRasterbar_INCLUDE_DIR libtorrent - HINTS ${PC_LIBTORRENT_RASTERBAR_INCLUDEDIR} ${PC_LIBTORRENT_RASTERBAR_INCLUDE_DIRS} - PATH_SUFFIXES libtorrent-rasterbar) - -find_library(LibtorrentRasterbar_LIBRARY NAMES torrent-rasterbar - HINTS ${PC_LIBTORRENT_RASTERBAR_LIBDIR} ${PC_LIBTORRENT_RASTERBAR_LIBRARY_DIRS}) - -if(LibtorrentRasterbar_USE_STATIC_LIBS) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) -endif() - -set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARY}) -set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIR}) - -if(NOT Boost_SYSTEM_FOUND OR NOT Boost_THREAD_FOUND OR NOT Boost_DATE_TIME_FOUND OR NOT Boost_CHRONO_FOUND) - find_package(Boost REQUIRED COMPONENTS system thread date_time chrono) - set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${Boost_LIBRARIES}) - set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) -endif() - -list(FIND LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL LibtorrentRasterbar_ENCRYPTION_INDEX) -if(LibtorrentRasterbar_ENCRYPTION_INDEX GREATER -1) - find_package(OpenSSL REQUIRED) - set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${OPENSSL_LIBRARIES}) - set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS}) - set(LibtorrentRasterbar_OPENSSL_ENABLED ON) -endif() - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set LibtorrentRasterbar_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG - LibtorrentRasterbar_LIBRARY - LibtorrentRasterbar_INCLUDE_DIR - Boost_SYSTEM_FOUND - Boost_THREAD_FOUND - Boost_DATE_TIME_FOUND - Boost_CHRONO_FOUND) - -mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY - LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES - LibtorrentRasterbar_ENCRYPTION_INDEX) \ No newline at end of file diff --git a/scripts/externals/mpv/libs.js b/scripts/externals/mpv/libs.js index 17c3601..fc52144 100644 --- a/scripts/externals/mpv/libs.js +++ b/scripts/externals/mpv/libs.js @@ -1,19 +1,23 @@ const { copyFileSync, existsSync } = require('fs') const { join } = require('path') +const IS_LINUX = !['win32', 'darwin'].includes(process.platform) + const baseDir = ({ 'darwin': '/usr/local/lib', 'win32': 'C:\\Windows\\system32' -}[process.platform]) || '/usr/lib' +}[process.platform]) const libFilename = ({ 'darwin': 'libmpv.1.dylib', 'win32': 'mpv-1.dll' -}[process.platform]) || 'libmpv.so' +}[process.platform]) const libPath = join(baseDir, libFilename) -if (!existsSync(libPath)) { +if (IS_LINUX) { + console.log('KawANime [PostInstall] -- Linux platform detected, no need to move any library') +} else if (!existsSync(libPath)) { console.warn('KawAnime [PostInstall] -- Could not find libmpv library file. Please install it and put it in `public/mpv`') } else { console.log(`KawAnime [PostInstall] -- Found libmpv at ${libPath}`)