From: Harley Laue Date: Wed, 12 May 2010 00:12:05 +0000 (-0500) Subject: Find Vorbis via CMake instead of just assuming it's installed X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=862bb5d32499f2b7f921fb1654a948fe0d4afaa5;p=lugaru.git Find Vorbis via CMake instead of just assuming it's installed --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c87964e..910e127 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ project(lugaru) cmake_minimum_required(VERSION 2.6) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + find_package(OpenAL REQUIRED) find_package(BZip2 REQUIRED) find_package(PNG REQUIRED) @@ -10,6 +12,7 @@ find_package(ZLIB REQUIRED) find_package(OpenGL REQUIRED) find_package(GLU REQUIRED) find_package(SDL REQUIRED) +find_package(Vorbis REQUIRED) include_directories( ${OPENAL_INCLUDES} @@ -20,8 +23,10 @@ include_directories( ${OPENGL_INCLUDE_DIR} ${GLU_INCLUDE_DIR} ${SDL_INCLUDE_DIR} + ${VORBIS_INCLUDE_DIR} + ${OGG_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/Source) -set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${SDL_LIBRARY} ${GLU_LIBRARY} ${OPENGL_LIBRARY} -lvorbisfile -logg) +set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${SDL_LIBRARY} ${GLU_LIBRARY} ${OPENGL_LIBRARY} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY}) add_subdirectory(Source) diff --git a/cmake/FindVorbis.cmake b/cmake/FindVorbis.cmake new file mode 100644 index 0000000..e0cb2c1 --- /dev/null +++ b/cmake/FindVorbis.cmake @@ -0,0 +1,45 @@ +# - Find vorbis +# Find the native vorbis includes and libraries +# +# VORBIS_INCLUDE_DIR - where to find vorbis.h, etc. +# VORBIS_LIBRARIES - List of libraries when using vorbis(file). +# VORBIS_FOUND - True if vorbis found. + +if(NOT GP2XWIZ) + if(VORBIS_INCLUDE_DIR) + # Already in cache, be silent + set(VORBIS_FIND_QUIETLY TRUE) + endif(VORBIS_INCLUDE_DIR) + find_path(OGG_INCLUDE_DIR ogg/ogg.h) + find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) + # MSVC built ogg/vorbis may be named ogg_static and vorbis_static + find_library(OGG_LIBRARY NAMES ogg ogg_static) + find_library(VORBIS_LIBRARY NAMES vorbis vorbis_static) + find_library(VORBISFILE_LIBRARY NAMES vorbisfile vorbisfile_static) + # Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND + # to TRUE if all listed variables are TRUE. + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(VORBIS DEFAULT_MSG + OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR + OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) +else(NOT GP2XWIZ) + find_path(VORBIS_INCLUDE_DIR tremor/ivorbisfile.h) + find_library(VORBIS_LIBRARY NAMES vorbis_dec) + find_package_handle_standard_args(VORBIS DEFAULT_MSG + VORBIS_INCLUDE_DIR VORBIS_LIBRARY) +endif(NOT GP2XWIZ) + +if(VORBIS_FOUND) + if(NOT GP2XWIZ) + set(VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} + ${OGG_LIBRARY}) + else(NOT GP2XWIZ) + set(VORBIS_LIBRARIES ${VORBIS_LIBRARY}) + endif(NOT GP2XWIZ) +else(VORBIS_FOUND) + set(VORBIS_LIBRARIES) +endif(VORBIS_FOUND) + +mark_as_advanced(OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR) +mark_as_advanced(OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) +