doc/doxygen-build.stamp
lib/test_sharedbook
test/test
+
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Testing
+Makefile
+cmake_install.cmake
+install_manifest.txt
+compile_commands.json
+CTestTestfile.cmake
+CMakeSettings.json
+
+*[Bb]uild*/
+
+.vs/
+.vscode/
-cmake_minimum_required(VERSION 2.8.7)
+cmake_minimum_required(VERSION 2.8.12)
project(vorbis)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
# Required modules
include(GNUInstallDirs)
include(CheckIncludeFiles)
+include(CheckLibraryExists)
# Build options
option(BUILD_SHARED_LIBS "Build shared library" OFF)
set(BUILD_SHARED_LIBS TRUE)
endif()
+option(INSTALL_CMAKE_PACKAGE_MODULE "Install CMake package configiguration module" ON)
+
# Extract project version from configure.ac
file(READ configure.ac CONFIGURE_AC_CONTENTS)
string(REGEX MATCH "AC_INIT\\(\\[libvorbis\\],\\[([0-9]*).([0-9]*).([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS})
message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
+# Find math library
+
+check_library_exists(m floor "" HAVE_LIBM)
+
# Find ogg dependency
-if(NOT OGG_ROOT)
- find_package(PkgConfig QUIET)
- pkg_check_modules(PC_OGG QUIET ogg)
- find_path(OGG_INCLUDE_DIRS NAMES ogg/ogg.h HINTS ${PC_OGG_INCLUDE_DIRS} PATH_SUFFIXES ogg)
- find_library(OGG_LIBRARIES NAMES ogg HINTS ${PC_OGG_LIBRARY_DIRS})
-else()
- find_path(OGG_INCLUDE_DIRS NAMES ogg/ogg.h HINTS ${OGG_ROOT}/include PATH_SUFFIXES ogg)
- find_library(OGG_LIBRARIES NAMES ogg HINTS ${OGG_ROOT}/lib ${OGG_ROOT}/lib64)
-endif()
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(OGG DEFAULT_MSG OGG_INCLUDE_DIRS OGG_LIBRARIES)
+find_package(Ogg REQUIRED)
add_subdirectory(lib)
vorbisenc-uninstalled.pc.in \
vorbisfile-uninstalled.pc.in \
symbian \
- macosx win32 CMakeLists.txt
+ macosx win32 CMakeLists.txt cmake/FindOgg.cmake \
+ cmake/VorbisConfig.cmake.in
DISTCHECK_CONFIGURE_FLAGS = --enable-docs
--- /dev/null
+#[=======================================================================[.rst:
+
+FindOgg
+--------
+
+Find the native Ogg includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``Ogg::ogg``, if
+Ogg has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ OGG_INCLUDE_DIRS - where to find ogg.h, etc.
+ OGG_LIBRARIES - List of libraries when using ogg.
+ OGG_FOUND - True if ogg found.
+
+::
+
+ OGG_VERSION_STRING - The version of ogg found (x.y.z)
+
+Hints
+^^^^^
+
+A user may set ``OGG_ROOT`` to a ogg installation root to tell this
+module where to look.
+#]=======================================================================]
+
+if(OGG_INCLUDE_DIR)
+ # Already in cache, be silent
+ set(OGG_FIND_QUIETLY TRUE)
+endif()
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_OGG QUIET ogg)
+
+set(OGG_VERSION_STRING ${PC_OGG_VERSION})
+
+find_path(OGG_INCLUDE_DIR ogg/ogg.h
+ HINTS
+ ${PC_OGG_INCLUDEDIR}
+ ${PC_OGG_INCLUDE_DIRS}
+ ${OGG_ROOT}
+ PATH_SUFFIXES
+ include
+)
+# MSVC built ogg may be named ogg_static.
+# The provided project files name the library with the lib prefix.
+find_library(OGG_LIBRARY
+ NAMES
+ ogg
+ ogg_static
+ libogg
+ libogg_static
+ HINTS
+ ${PC_OGG_LIBDIR}
+ ${PC_OGG_LIBRARY_DIRS}
+ ${OGG_ROOT}
+ PATH_SUFFIXES
+ lib
+)
+
+# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
+# to TRUE if all listed variables are TRUE.
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Ogg
+ REQUIRED_VARS
+ OGG_LIBRARY
+ OGG_INCLUDE_DIR
+ VERSION_VAR
+ OGG_VERSION_STRING
+)
+
+if(OGG_FOUND)
+ set(OGG_LIBRARIES ${OGG_LIBRARY})
+ set(OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
+
+ if(NOT TARGET Ogg::ogg)
+ add_library(Ogg::ogg UNKNOWN IMPORTED)
+ set_target_properties(Ogg::ogg PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
+ IMPORTED_LOCATION "${OGG_LIBRARIES}"
+ )
+ endif()
+endif()
+
+mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY)
--- /dev/null
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(Ogg REQUIRED)
+
+include(${CMAKE_CURRENT_LIST_DIR}/vorbis-targets.cmake)
+
+set(Vorbis_Vorbis_FOUND 1)
+set(Vorbis_Enc_FOUND 0)
+set(Vorbis_File_FOUND 0)
+
+if(TARGET Vorbis::vorbisenc)
+ set(Vorbis_Enc_FOUND TRUE)
+endif()
+if(TARGET Vorbis::vorbisfile)
+ set(Vorbis_File_FOUND TRUE)
+endif()
+
+check_required_components(Vorbis)
list(APPEND VORBISFILE_SOURCES ../win32/vorbisfile.def)
endif()
-include_directories(../include)
-include_directories(.)
-include_directories(${OGG_INCLUDE_DIRS})
-
if (NOT BUILD_FRAMEWORK)
add_library(vorbis ${VORBIS_HEADERS} ${VORBIS_SOURCES})
add_library(vorbisenc ${VORBISENC_SOURCES})
get_version_info(VORBISFILE_VERSION_INFO "VF_LIB_CURRENT" "VF_LIB_AGE" "VF_LIB_REVISION")
set_target_properties(vorbisfile PROPERTIES SOVERSION ${VORBISFILE_VERSION_INFO})
- target_link_libraries(vorbis ${OGG_LIBRARIES})
- target_link_libraries(vorbisenc ${OGG_LIBRARIES} vorbis)
- target_link_libraries(vorbisfile ${OGG_LIBRARIES} vorbis)
+ target_include_directories(vorbis
+ PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ target_include_directories(vorbisenc
+ PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ target_include_directories(vorbisfile
+ PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ )
+
+ target_link_libraries(vorbis
+ PUBLIC Ogg::ogg
+ PRIVATE $<$<BOOL:${HAVE_LIBM}>:m>
+ )
+ target_link_libraries(vorbisenc PUBLIC vorbis)
+ target_link_libraries(vorbisfile PUBLIC vorbis)
+
+ install(FILES ${VORBIS_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/Vorbis)
+
+ install(TARGETS vorbis vorbisenc vorbisfile
+ EXPORT VorbisTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+
+ if(INSTALL_CMAKE_PACKAGE_MODULE)
+
+ set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Vorbis)
+
+ install(EXPORT VorbisTargets
+ DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
+ NAMESPACE Vorbis::
+ )
+
+
+ include(CMakePackageConfigHelpers)
+
+ configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/VorbisConfig.cmake.in ${PROJECT_BINARY_DIR}/VorbisConfig.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
+ )
+
+ write_basic_package_version_file(${PROJECT_BINARY_DIR}/VorbisConfigVersion.cmake
+ COMPATIBILITY SameMajorVersion
+ )
- install(FILES ${VORBIS_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/vorbis)
+ install(FILES ${PROJECT_BINARY_DIR}/VorbisConfig.cmake ${PROJECT_BINARY_DIR}/VorbisConfigVersion.cmake
+ DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
+ )
- install(TARGETS vorbis RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
- install(TARGETS vorbisenc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
- install(TARGETS vorbisfile RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
else()
add_library(vorbis ${VORBIS_PUBLIC_HEADERS} ${VORBIS_HEADERS} ${VORBIS_SOURCES} ${VORBISFILE_SOURCES} ${VORBISENC_SOURCES})
set_target_properties(vorbis PROPERTIES