Commit 6cd2b6cd authored by Vitaliy Kirsanov's avatar Vitaliy Kirsanov Committed by Erik de Castro Lopo

FindOGG.cmake module added

parent c39718d7
......@@ -6,10 +6,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(BUILD_CXXLIBS "Build libFLAC++" ON)
option(BUILD_EXAMPLES "Build and install examples" ON)
option(WITH_OGG "ogg support (default: test for libogg)" ON)
if(WITH_OGG)
find_package(OGG REQUIRED)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
if(CMAKE_BULD_TYPE STREQUAL Release)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -funroll-loops")
......@@ -17,6 +21,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
option(ENABLE_SSP "Enable GNU GCC stack smash protection" OFF)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_EXE_LINKER_FLAGS -no-pie)
endif()
include(CMakePackageConfigHelpers)
include(CPack)
......@@ -114,6 +124,7 @@ install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake"
"cmake/FindOGG.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
file(GLOB FLAC_HEADERS "include/FLAC/*.h")
......
find_package(PkgConfig)
pkg_check_modules(_OGG QUIET ogg)
find_path(_OGG_INCLUDE_DIR
NAMES "ogg/ogg.h"
PATHS ${_OGG_INCLUDE_DIRS})
find_library(_OGG_LIBRARY
NAMES ogg libogg
HINTS ${_OGG_LIBRARY_DIRS})
find_library(_OGG_LIBRARY_STATIC
NAMES libogg.a libogg_static
HINTS ${_OGG_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OGG
REQUIRED_VARS _OGG_INCLUDE_DIR _OGG_LIBRARY
VERSION_VAR _OGG_VERSION)
if(OGG_FOUND)
if(NOT Ogg::Ogg)
add_library(Ogg::Ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::Ogg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_OGG_INCLUDE_DIR}"
IMPORTED_LOCATION "${_OGG_LIBRARY}")
endif()
if(NOT Ogg::Ogg-static AND _OGG_LIBRARY_STATIC)
add_library(Ogg::Ogg-static STATIC IMPORTED)
set_target_properties(Ogg::Ogg-static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_OGG_INCLUDE_DIR}"
IMPORTED_LOCATION "${_OGG_LIBRARY_STATIC}")
endif()
endif()
@PACKAGE_INIT@
if(@OGG_FOUND@)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
include(CMakeFindDependencyMacro)
find_dependency(OGG)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake")
cmake_minimum_required(VERSION 3.12)
option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8 (4 is the default)" OFF)
option(WITH_OGG "ogg support (default: test for libogg)" ON)
option(WITH_XMMS "Build XMMS plugin" OFF)
if(WITH_OGG)
find_package(OGG REQUIRED)
endif()
check_include_file("iconv.h" HAVE_ICONV_H)
add_compile_definitions(
......
......@@ -102,9 +102,16 @@ target_include_directories(FLAC-static INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
target_link_libraries(FLAC-static PUBLIC
$<TARGET_NAME_IF_EXISTS:Ogg::Ogg>
$<TARGET_NAME_IF_EXISTS:Ogg::Ogg-static>
$<TARGET_NAME_IF_EXISTS:FLAC-asm>
$<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET Ogg::Ogg-static)
target_link_libraries(FLAC-static PUBLIC
$<TARGET_NAME_IF_EXISTS:Ogg::Ogg-static>)
elseif(TARGET Ogg::Ogg)
target_link_libraries(FLAC-static PUBLIC
$<TARGET_NAME_IF_EXISTS:Ogg::Ogg>)
endif()
add_library(FLAC SHARED ${SOURCES})
target_compile_definitions(FLAC PRIVATE FLAC_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
......@@ -112,6 +119,7 @@ target_include_directories(FLAC INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
target_link_libraries(FLAC PRIVATE
$<TARGET_NAME_IF_EXISTS:Ogg::Ogg>
$<TARGET_NAME_IF_EXISTS:FLAC-asm>
$<$<BOOL:${HAVE_LROUND}>:m>)
set_target_properties(FLAC PROPERTIES C_VISIBILITY_PRESET hidden)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment