Skip to content
Permalink
Browse files

fixed: manually look for openssl

need to make sure we get the correct linker directory set
if RTMP is found without pkg-config aid
  • Loading branch information...
akva2 committed Sep 5, 2016
1 parent 92bc7fe commit e5e4cee142c6614664448318c7b3df3b3809930e
Showing with 3 additions and 1 deletion.
  1. +3 −1 CMakeLists.txt
@@ -7,15 +7,17 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
enable_language(CXX)

find_package(Kodi REQUIRED)
find_package(OpenSSL REQUIRED)

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Sep 5, 2016

Not entirely sure why but, when building LibreELEC, before find_package(OpenSSL REQUIRED) is called the value of ${PKG_CONFIG_FOUND} is not set, however after the call to find_package(OpenSSL REQUIRED) the variable is set to TRUE, which then causes FindRTMP.cmake to take the pkg-config path (https://github.com/notspiff/inputstream.rtmp/blob/master/FindRTMP.cmake#L9-L10), which fails.

-- Checking to see if CXX compiler accepts flag -flto - yes
-- Found OpenSSL: /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi.arm-8.0-devel/toolchain/armv6zk-libreelec-linux-gnueabi/sysroot/usr/lib/libssl.so;/home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi.arm-8.0-devel/toolchain/armv6zk-libreelec-linux-gnueabi/sysroot/usr/lib/libcrypto.so (found version "2.0.0")
-- Found ZLIB: /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi.arm-8.0-devel/toolchain/armv6zk-libreelec-linux-gnueabi/sysroot/usr/lib/libz.so (found version "1.2.8")
-- Checking for module 'librtmp'
--   Found librtmp, version v2.4
CMake Error at /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi.arm-8.0-devel/toolchain/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find RTMP (missing: RTMP_INCLUDE_DIRS)
Call Stack (most recent call first):
  /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi.arm-8.0-devel/toolchain/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  FindRTMP.cmake:17 (find_package_handle_standard_args)
  CMakeLists.txt:12 (find_package)

Adding unset(PKG_CONFIG_FOUND) after find_package(OpenSSL REQUIRED) fixes the issue, but I'm pretty sure that's not the right solution!

This comment has been minimized.

Copy link
@notspiff

notspiff Sep 6, 2016

Collaborator

grgl, it's the stupid pkg-config handler in cmake.

try adding

list(APPEND RTMP_INCLUDE_DIRS ${RTMP_INCLUDEDIR})

inside the pkg-config block in FindRTMP.cmake.

if the package is installed in default system directories, it does not fill XXX_INCLUDE_DIRS under certain circumstances. i have never quite found the system to it, but that ^^ typically does the trick.

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Sep 6, 2016

That's already there:

if(PKG_CONFIG_FOUND)
  pkg_check_modules (RTMP librtmp)
  list(APPEND RTMP_INCLUDE_DIRS ${RTMP_INCLUDEDIR})

The problem with the above is that pkg_check_modules (RTMP librtmp) appears to be working - it finds librtmp - but it isn't setting any variables, so RTMP_INCLUDEDIR is blank which leads to RTMP_INCLUDE_DIRS being blank.

The thing is this is now new behaviour with LibreELEC, as previously PKG_CONFIG_FOUND would never be set, but now it is.

In addition, the find_package(ZLIB REQUIRED) (in your next commit) doesn't set PKG_CONFIG_FOUND - it's only the find_package(OpenSSL REQUIRED) call that is setting PKG_CONFIG_FOUND, for some reason.

This comment has been minimized.

Copy link
@akva2

akva2 Sep 6, 2016

Author Contributor

(sorry for hopping users all the time..)

yes, the reason for that is that the built-in OpenSSL cmake rule locates pkg-config for us. actually it was a bug that i never did that earlier. you must have some borked librtmp.pc file then ? maybe i have to eat it and do like @fetzerch does in his rules - don't trust pkg-config.

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Sep 6, 2016

you must have some borked librtmp.pc file then ?

neil@nm-linux:~/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel$ pkg-config librtmp --modversion
v2.4
neil@nm-linux:~/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel$ pkg-config librtmp --print-variables
exec_prefix
incdir
libdir
pcfiledir
prefix
neil@nm-linux:~/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel$ pkg-config librtmp --variable=incdir
/usr/include
neil@nm-linux:~/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel$ pkg-config librtmp --variable=libdir
/usr/lib/x86_64-linux-gnu
neil@nm-linux:~/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel$ pkg-config librtmp --variable=prefix
/usr

I guess so, or it's a consequence of cross-compiling as the pkg-config route in FindRTMP.cmake hasn't been used before when building inputstream.rtmp with LibreELEC, in which case simply not trusting pkg-config works just fine for LibreELEC! :)

According to the cmake documentation, PKG_CONFIG_FOUND will be set when the pkg-config executable is found (and it obviously exists on the LibreELEC host system) but in this case we don't want/need to use it...

This comment has been minimized.

Copy link
@akva2

akva2 Sep 6, 2016

Author Contributor

actually i seem to recall that the pc file from vanilla librtmp is utterly borked, and debian / ubuntu patch it into shape. i'll add validation of the info from pkg-config.. soon. need to do stuff that puts food on the table right now.

This comment has been minimized.

Copy link
@akva2

akva2 Sep 7, 2016

Author Contributor

please try HEAD.

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Sep 7, 2016

Looks good now, many thanks!

-- Checking to see if CXX compiler accepts flag -flto
-- Checking to see if CXX compiler accepts flag -flto - yes
-- Found OpenSSL: /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel/toolchain/armv7ve-libreelec-linux-gnueabi/sysroot/usr/lib/libssl.so;/home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel/toolchain/armv7ve-libreelec-linux-gnueabi/sysroot/usr/lib/libcrypto.so (found version "2.0.0")
-- Found ZLIB: /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel/toolchain/armv7ve-libreelec-linux-gnueabi/sysroot/usr/lib/libz.so (found version "1.2.8")
-- Found RTMP: /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel/toolchain/armv7ve-libreelec-linux-gnueabi/sysroot/usr/include
-- RTMP_VERSION=1.0.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/neil/projects/LibreELEC.tv/build.LibreELEC-RPi2.arm-8.0-devel/inputstream.rtmp-9c05b8d/.armv7ve-libreelec-linux-gnueabi

This comment has been minimized.

Copy link
@fetzerch

fetzerch Oct 25, 2016

Member

@akva2: I'm trying to fix game.moonlight which is also using openssl. Tried to 'borrow' your module, but now I'm wondering how this is supposed to work. The openssl dependency doesn't install an OpenSSL cmake module if I'm not overlooking something. It always falls back to the system one (or probably the one in system depends). Also on linux building openssl (with https://github.com/notspiff/inputstream.rtmp/blob/master/depends/common/openssl/CMakeLists.txt) doesn't install anything into build/depends. Is that how it should be?

This comment has been minimized.

Copy link
@akva2

akva2 Oct 25, 2016

Author Contributor

OpenSSL module is shipped with cmake. It does install, but not with the submodule target but as part of the hosting build system, see bottom of cmakelists. This is how all dependencies do it to fit with the expectations of the glue in cmake/addons in kodi.

This comment has been minimized.

Copy link
@fetzerch

fetzerch Oct 25, 2016

Member

Thx for the quick reply! Sry, I think I'm still confused. I still guess that the addon should use the openssl version that we build (otherwise it wouldn't make sense to build it, right). For me that's not the case, I can see that in the CMakeCache.txt it's using my system installed openssl.

That's how I build it:

cmake -DADDONS_TO_BUILD="inputstream.rtmp" -DADDON_SRC_PREFIX=/home/jcf/develop/kodi/games -DCMAKE_BUILD_TYPE=Debug -DPACKAGE_ZIP=1 -DCMAKE_INSTALL_PREFIX=../../kodi-retroplayer/addons  ../../kodi/project/cmake/addons
make

After the build the directory build/depends still doesn't contain anything related to openssl.
How is the CMake build-in FindOpenSSL.cmake supposed to find it in the local addon build directory? via pkg_config?

This comment has been minimized.

Copy link
@akva2

akva2 Oct 25, 2016

Author Contributor

It runs jailed, see depends/tools/binary-addons. Not sure how the find module operates.

This comment has been minimized.

Copy link
@akva2

akva2 Oct 25, 2016

Author Contributor

okay, back on pc so i can be more verbose. you cannot really test the depends based build on your system if you have the library installed on the system level. you either have to remove the lib from the system, build through depends or otherwise jail the build so it cannot see the system libraries. there's no preferring certain dirs or anything such in the build system since it's only supposed to be used on a system where the library just built is the only version it can locate.

This comment has been minimized.

Copy link
@fetzerch

fetzerch Oct 26, 2016

Member

Allright thanks. Then I'll just assume for the moment, that it works on my linux box. On osx with depends it somehow failed to install openssl (with make[6]: *** [install_sw] Broken pipe: 13). Need to look into that later when I have a bit more time.

find_package(RTMP REQUIRED)

set(RTMP_SOURCES src/RTMPStream.cpp)

include_directories(${INCLUDES}
${RTMP_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
${KODI_INCLUDE_DIR})

list(APPEND DEPLIBS ${RTMP_LIBRARIES})
list(APPEND DEPLIBS ${RTMP_LIBRARIES} ${OPENSSL_LIBRARIES})

build_addon(inputstream.rtmp RTMP DEPLIBS)

0 comments on commit e5e4cee

Please sign in to comment.
You can’t perform that action at this time.