[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-buildsystem
Subject:    Fixing OpenAL and libsndfile dependencies in kdegames (Was `Re:
From:       Raphael Kubo da Costa <kubito () gmail ! com>
Date:       2011-05-18 16:35:13
Message-ID: 83liy455mm.fsf_-_ () gmail ! com
[Download RAW message or body]

Raphael Kubo da Costa <kubito@gmail.com> writes:

> CC'ing kde-buildsystem to this thread.
>
> Ian Wadham <iandw.au@gmail.com> writes:
>> SVN commit 1232491 by ianw:
>>
>> Make the dependency of Granatier and KGoldrunner on OpenAL and SndFile
>> optional. The dependency should really be REQUIRED, but that kills the
>> whole KDE Games build if OpenAL or SndFile is not present. If OpenAL
>> is absent, Granatier will not be built and KGoldrunner will be built
>> but with sound completely disabled.
>>
>>  M  +5 -0      CMakeLists.txt  
>>  M  +3 -7      kgoldrunner/CMakeLists.txt  
>>  M  +0 -2      kgoldrunner/src/kgrglobals.h  
>
> Hi, Ian,
>
> I saw the commit message by chance in #kde-commits and decided to take a
> look.
>
> From what I understood, you want both libsndfile and OpenAL to be hard
> (ie. required) dependencies for Granatier and KGoldRunner, but only if
> they are built (ie. if one passes -DBUILD_granatier=OFF and
> -DBUILD_kgoldrunner=OFF), kdegames should build just fine without
> libsndfile and OpenAL installed in the system.
>
> In this case, wouldn't it be enough to call find_package(SndFile) and
> find_package(OpenAL) and then add the respective macro_log_feature()
> calls with the `REQUIRED' parameter set to TRUE instead of FALSE?
>
> By putting these commands inside granatier/CMakeLists.txt and
> kgoldrunner/CMakeLists.txt, you avoid calling them when granatier and
> kgoldrunner are not build, while still failing to build when they are
> not found.

Hey there again,

I'm replying to this list and thread instead of release-team@ as the
subject is more appropriate to be discussed here. I also suggest
subscribing to this list, as more people might want to give their
suggestions and they might forget to CC you.

So what I have in mind is the following:

  * Granatier and KGoldRunner are optional parts of kdegames (ie. one
    can call cmake with -DBUILD_granatier=OFF and
    -DBUILD_kgoldrunner=OFF and none of them will be built).
  * If one chooses not to build Granatier and KGoldRunner, CMake must
    not check for libsndfile and OpenAL.
  * If one does choose to build Granatier and/or KGoldRunner, CMake must
    check for both libsndfile and OpenAL, and fail at the end of the
    configuration phase (ie. after cmake runs and before you run make)
    if either of them (or both) is not found.

So the attached patch:

  * Moves FindSndFile.cmake to the top-level cmake/modules directory
    (you might want to avoid this as kdegames is splitting in git).
  * Unconditionally adds
        macro_optional_add_subdirectory(granatier)
        macro_optional_add_subdirectory(kgoldrunner)
    to the top-level CMakeLists.txt
  * In {granatier,kgoldrunner}/CMakeLists.txt it calls
    find_package()+macro_log_feature() for both OpenAL and
    libsndfile. As `REQUIRED' is not passed to find_package(), CMake
    keeps going until the end, when the build fails if the dependencies
    are not met, as macro_log_feature() is called with required=TRUE.

Is it clear now?


["kdegames-openal-sndfile-deps.diff" (text/x-patch)]

Index: kdegames/granatier/cmake/modules/FindSndFile.cmake
===================================================================
--- kdegames/granatier/cmake/modules/FindSndFile.cmake	(revision 1232623)
+++ kdegames/granatier/cmake/modules/FindSndFile.cmake	(working copy)
@@ -1,47 +0,0 @@
-#
-# Try to find libsndfile
-# Once done this will define
-#
-#  SNDFILE_FOUND - libsndfile was found
-#  SNDFILE_INCLUDE_DIR - the libsndfile include directory
-#  SNDFILE_LIBRARIES - libsndfile libraries to link to
-#
-# Copyright (c) 2008, Sebastian Trueg, <trueg@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
-
-
-if ( SNDFILE_INCLUDE_DIR AND SNDFILE_LIBRARIES )
-  # in cache already
-SET(Sndfile_FIND_QUIETLY TRUE)
-endif ( SNDFILE_INCLUDE_DIR AND SNDFILE_LIBRARIES )
-
-IF (NOT WIN32)
-# use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
-INCLUDE(UsePkgConfig)
-
-PKGCONFIG(sndfile _SndfileIncDir _SndfileLinkDir _SndfileLinkFlags _SndfileCflags)
-ENDIF (NOT WIN32)
-
-
-FIND_PATH(SNDFILE_INCLUDE_DIR
-NAMES sndfile.h
-PATHS ${_SndfileIncDir}
-NO_DEFAULT_PATH
-)
-
-FIND_LIBRARY(SNDFILE_LIBRARIES 
-NAMES sndfile
-PATHS ${_SndfileLinkDir}
-NO_DEFAULT_PATH
-)
-
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sndfile DEFAULT_MSG SNDFILE_INCLUDE_DIR \
                SNDFILE_LIBRARIES )
-
-# show the SNDFILE_INCLUDE_DIR and SNDFILE_LIBRARIES variables only in the advanced \
                view
-MARK_AS_ADVANCED(SNDFILE_INCLUDE_DIR SNDFILE_LIBRARIES )
-
Index: kdegames/granatier/CMakeLists.txt
===================================================================
--- kdegames/granatier/CMakeLists.txt	(revision 1232623)
+++ kdegames/granatier/CMakeLists.txt	(working copy)
@@ -7,11 +7,10 @@
   include_directories(${KDE4_INCLUDES})
 endif (NOT KDE4_FOUND)
 
-find_package(OpenAL REQUIRED)
+find_package(OpenAL)
 macro_log_feature(OPENAL_FOUND "OpenAL" "OpenAL (Open Audio Library) is a free \
software cross-platform audio API." "http://connect.creativelabs.com/openal" TRUE "" \
"Granatier uses OpenAL for sound output.")  
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
-find_package(SndFile REQUIRED)
+find_package(SndFile)
 macro_log_feature(SNDFILE_FOUND "SndFile" "libsndfile is a C library written by Erik \
de Castro Lopo for reading and writing audio files." \
"http://www.mega-nerd.com/libsndfile/" TRUE "" "SndFile is needed to decode the sound \
files.")  
 if(OPENAL_FOUND AND SNDFILE_FOUND)
Index: kdegames/CMakeLists.txt
===================================================================
--- kdegames/CMakeLists.txt	(revision 1232623)
+++ kdegames/CMakeLists.txt	(working copy)
@@ -24,9 +24,6 @@
 macro_optional_find_package(PythonInterp)
 macro_log_feature(PYTHONINTERP_FOUND "Python" "Programming language that lets you \
work more quickly and integrate your systems more effectively." "http://python.org" \
FALSE "" "Kajongg will not be built without the python interpreter (version 2.6 < \
3.0).")  
-macro_optional_find_package(OpenAL)
-macro_log_feature(OPENAL_FOUND "OpenAL" "OpenAL (Open Audio Library) is a free \
software cross-platform audio API." "http://connect.creativelabs.com/openal" FALSE "" \
"KGoldrunner and Granatier need OpenAL for sound output. If OpenAL cannot be provided \
on some platform or distribution, please email the KDE Games list <kde-games-devel at \
                kde dot org>.")
-
 if(OPENGL_FOUND AND QT_QTOPENGL_FOUND)
     set(OPENGL_SUPPORT true)
 endif(OPENGL_FOUND AND QT_QTOPENGL_FOUND)
@@ -54,9 +51,7 @@
 
 macro_optional_add_subdirectory(bomber)
 macro_optional_add_subdirectory(bovo)
-if(OPENAL_FOUND)
-    macro_optional_add_subdirectory(granatier)
-endif(OPENAL_FOUND)
+macro_optional_add_subdirectory(granatier)
 macro_optional_add_subdirectory(lskat)
 macro_optional_add_subdirectory(kapman)
 macro_optional_add_subdirectory(katomic)
Index: kdegames/kgoldrunner/cmake/modules/FindSndFile.cmake
===================================================================
--- kdegames/kgoldrunner/cmake/modules/FindSndFile.cmake	(revision 1232623)
+++ kdegames/kgoldrunner/cmake/modules/FindSndFile.cmake	(working copy)
@@ -1,47 +0,0 @@
-#
-# Try to find libsndfile
-# Once done this will define
-#
-#  SNDFILE_FOUND - libsndfile was found
-#  SNDFILE_INCLUDE_DIR - the libsndfile include directory
-#  SNDFILE_LIBRARIES - libsndfile libraries to link to
-#
-# Copyright (c) 2008, Sebastian Trueg, <trueg@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
-
-
-if ( SNDFILE_INCLUDE_DIR AND SNDFILE_LIBRARIES )
-  # in cache already
-SET(Sndfile_FIND_QUIETLY TRUE)
-endif ( SNDFILE_INCLUDE_DIR AND SNDFILE_LIBRARIES )
-
-IF (NOT WIN32)
-# use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
-INCLUDE(UsePkgConfig)
-
-PKGCONFIG(sndfile _SndfileIncDir _SndfileLinkDir _SndfileLinkFlags _SndfileCflags)
-ENDIF (NOT WIN32)
-
-
-FIND_PATH(SNDFILE_INCLUDE_DIR
-NAMES sndfile.h
-PATHS ${_SndfileIncDir}
-NO_DEFAULT_PATH
-)
-
-FIND_LIBRARY(SNDFILE_LIBRARIES 
-NAMES sndfile
-PATHS ${_SndfileLinkDir}
-NO_DEFAULT_PATH
-)
-
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sndfile DEFAULT_MSG SNDFILE_INCLUDE_DIR \
                SNDFILE_LIBRARIES )
-
-# show the SNDFILE_INCLUDE_DIR and SNDFILE_LIBRARIES variables only in the advanced \
                view
-MARK_AS_ADVANCED(SNDFILE_INCLUDE_DIR SNDFILE_LIBRARIES )
-
Index: kdegames/kgoldrunner/CMakeLists.txt
===================================================================
--- kdegames/kgoldrunner/CMakeLists.txt	(revision 1232623)
+++ kdegames/kgoldrunner/CMakeLists.txt	(working copy)
@@ -1,21 +1,22 @@
 project(kgoldrunner)
 
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
-macro_optional_find_package(SndFile)
-macro_log_feature(SNDFILE_FOUND "SndFile" "SndFile (libsndfile) is a C library \
written by Erik de Castro Lopo for reading and writing audio files." \
"http://www.mega-nerd.com/libsndfile/" FALSE "" "KGoldrunner needs SndFile to decode \
sound files. If SndFile cannot be provided on some platform or distribution, please \
email the KDE Games list <kde-games-devel at kde dot org>.") +find_package(OpenAL)
+macro_log_feature(OPENAL_FOUND "OpenAL" "OpenAL (Open Audio Library) is a free \
software cross-platform audio API." "http://connect.creativelabs.com/openal" TRUE "" \
"KGoldrunner and Granatier need OpenAL for sound output. If OpenAL cannot be provided \
on some platform or distribution, please email the KDE Games list <kde-games-devel at \
kde dot org>.")  
-# KGoldrunner sound requires access to the OpenAL and SndFile libraries.  The
-# use of Phonon, as an alternative, does not give good results and is deprecated
-# (2011-05-09).
-if(OPENAL_FOUND AND SNDFILE_FOUND)
-    include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIRS})
-    include_directories(src/TagaroAudio)
-    set(KGOLDRUNNER_OPENAL TRUE)
-    ADD_DEFINITIONS(-DKGOLDRUNNER_USE_OPENAL)
-    ADD_DEFINITIONS(-DENABLE_SOUND_SUPPORT)
-endif(OPENAL_FOUND AND SNDFILE_FOUND)
+find_package(SndFile)
+macro_log_feature(SNDFILE_FOUND "SndFile" "SndFile (libsndfile) is a C library \
written by Erik de Castro Lopo for reading and writing audio files." \
"http://www.mega-nerd.com/libsndfile/" TRUE "" "KGoldrunner needs SndFile to decode \
sound files. If SndFile cannot be provided on some platform or distribution, please \
email the KDE Games list <kde-games-devel at kde dot org>.")  
-add_subdirectory( src ) 
-add_subdirectory( gamedata ) 
-add_subdirectory( themes ) 
+if(OPENAL_FOUND AND SNDFILE_FOUND)
+  # KGoldrunner sound requires access to the OpenAL and SndFile libraries.  The
+  # use of Phonon, as an alternative, does not give good results and is deprecated
+  # (2011-05-09).
+  include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIRS})
+  include_directories(src/TagaroAudio)
+  set(KGOLDRUNNER_OPENAL TRUE)
+  ADD_DEFINITIONS(-DKGOLDRUNNER_USE_OPENAL)
+  ADD_DEFINITIONS(-DENABLE_SOUND_SUPPORT)
 
+  add_subdirectory( src ) 
+  add_subdirectory( gamedata ) 
+  add_subdirectory( themes ) 
+endif(OPENAL_FOUND AND SNDFILE_FOUND)



_______________________________________________
Kde-buildsystem mailing list
Kde-buildsystem@kde.org
https://mail.kde.org/mailman/listinfo/kde-buildsystem


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic