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

CMake support added

parent 12ec86c6
cmake_minimum_required(VERSION 3.12)
project(FLAC VERSION 1.3.2 HOMEPAGE_URL "https://www.xiph.org/flac/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(BUILD_CXXLIBS "Build libFLAC++" ON)
option(BUILD_EXAMPLES "Build and install examples" ON)
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")
endif()
option(ENABLE_SSP "Enable GNU GCC stack smash protection" OFF)
endif()
include(CMakePackageConfigHelpers)
include(CPack)
include(CTest)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(GNUInstallDirs)
include(UseSystemExtensions)
include(TestBigEndian)
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("x86intrin.h" HAVE_X86INTRIN_H)
check_c_source_compiles("int main() { return __builtin_bswap16 (0) ; }" HAVE_BSWAP16)
check_c_source_compiles("int main() { return __builtin_bswap32 (0) ; }" HAVE_BSWAP32)
test_big_endian(CPU_IS_BIG_ENDIAN)
check_c_compiler_flag(-Werror HAVE_WERROR_FLAG)
check_c_compiler_flag(-Wdeclaration-after-statement HAVE_DECL_AFTER_STMT_FLAG)
check_c_compiler_flag("-fstack-protector --param ssp-buffer-size=4" HAVE_SSP_FLAG)
check_c_compiler_flag(-mstackrealign HAVE_STACKREALIGN_FLAG)
check_cxx_compiler_flag(-Weffc++ HAVE_WEFFCXX_FLAG)
if(HAVE_WERROR_FLAG)
option(ENABLE_WERROR "Enable -Werror in all Makefiles" OFF)
endif()
add_compile_definitions(
PACKAGE_VERSION="${PROJECT_VERSION}"
$<$<BOOL:${HAVE_BYTESWAP_H}>:HAVE_BYTESWAP_H>
$<$<BOOL:${HAVE_INTTYPES_H}>:HAVE_INTTYPES_H>
$<$<BOOL:${HAVE_STDINT_H}>:HAVE_STDINT_H>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
CPU_IS_BIG_ENDIAN=$<BOOL:${CPU_IS_BIG_ENDIAN}>
CPU_IS_LITTLE_ENDIAN=$<NOT:$<BOOL:${CPU_IS_BIG_ENDIAN}>>
FLAC__HAS_X86INTRIN=$<BOOL:${HAVE_X86INTRIN_H}>
HAVE_BSWAP16=$<BOOL:${HAVE_BSWAP16}>
HAVE_BSWAP32=$<BOOL:${HAVE_BSWAP32}>)
add_compile_options(
$<$<BOOL:${MSVC}>:/wd4267>
$<$<BOOL:${MSVC}>:/wd4996>
$<$<BOOL:${ENABLE_WERROR}>:-Werror>
$<$<AND:$<BOOL:${HAVE_SSP_FLAG}>,$<BOOL:${ENABLE_SSP}>>:-fstack-protector>
$<$<AND:$<BOOL:${HAVE_SSP_FLAG}>,$<BOOL:${ENABLE_SSP}>>:--param>
$<$<AND:$<BOOL:${HAVE_SSP_FLAG}>,$<BOOL:${ENABLE_SSP}>>:ssp-buffer-size=4>)
if(HAVE_WEFFCXX_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
endif()
if(HAVE_DECL_AFTER_STMT_FLAG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND HAVE_STACKREALIGN_FLAG)
add_compile_options(-mstackrealign)
endif()
include_directories("include")
add_subdirectory("doc")
add_subdirectory("src")
add_subdirectory("microbench")
if(BUILD_EXAMPLES)
add_subdirectory("examples")
endif()
if(WIN32)
set(EXEEXT .exe)
endif()
set(top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
set(top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
configure_file(test/common.sh.in test/common.sh @ONLY)
install(
EXPORT targets
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake"
NAMESPACE FLAC::)
configure_package_config_file(
flac-config.cmake.in flac-config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
write_basic_package_version_file(
flac-config-version.cmake COMPATIBILITY AnyNewerVersion)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
file(GLOB FLAC_HEADERS "include/FLAC/*.h")
file(GLOB FLACXX_HEADERS "include/FLAC++/*.h")
install(FILES ${FLAC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FLAC")
install(FILES ${FLACXX_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FLAC++")
install(FILES "man/flac.1" "man/metaflac.1" DESTINATION "${CMAKE_INSTALL_MANDIR}")
cmake_minimum_required(VERSION 3.12)
include(CheckCSourceCompiles)
check_c_source_compiles("
int main()
{
#ifndef _FORTIFY_SOURCE
return 0;
#else
this_is_an_error;
#endif
}"
DODEFINE_FORTIFY_SOURCE)
check_c_source_compiles("
#include <wchar.h>
mbstate_t x;
int main() { return 0; }"
HAVE_MBSTATE)
if(NOT HAVE_MBSTATE)
check_c_source_compiles("
#define _XOPEN_SOURCE 500
#include <wchar.h>
mbstate_t x;
int main() { return 0; }"
DODEFINE_XOPEN_SOURCE)
endif()
check_c_source_compiles("
#define __EXTENSIONS__ 1
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
int main() { return 0; }"
DODEFINE_EXTENSIONS)
add_compile_definitions(
_ALL_SOURCE
_DARWIN_C_SOURCE
_GNU_SOURCE
_POSIX_PTHREAD_SEMANTICS
__STDC_WANT_IEC_60559_ATTRIBS_EXT__
__STDC_WANT_IEC_60559_BFP_EXT__
__STDC_WANT_IEC_60559_DFP_EXT__
__STDC_WANT_IEC_60559_FUNCS_EXT__
__STDC_WANT_IEC_60559_TYPES_EXT__
__STDC_WANT_LIB_EXT2__
__STDC_WANT_MATH_SPEC_FUNCS__
_TANDEM_SOURCE
$<$<AND:$<BOOL:${DODEFINE_FORTIFY_SOURCE}>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:_FORTIFY_SOURCE=2>
$<$<BOOL:${DODEFINE_XOPEN_SOURCE}>:_XOPEN_SOURCE=500>
$<$<BOOL:${DODEFINE_EXTENTIONS}>:__EXTENSIONS__>)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)
return()
endif()
option(BUILD_DOXYGEN "Enable API documentation building via Doxygen" ON)
if (NOT BUILD_DOXYGEN)
return()
endif()
set(DOXYGEN_HTML_FOOTER doxygen.footer.html)
set(DOXYGEN_GENERATE_TAGFILE FLAC.tag)
doxygen_add_docs(FLAC-doxygen
"${PROJECT_SOURCE_DIR}/include/FLAC"
"${PROJECT_SOURCE_DIR}/include/FLAC++")
add_subdirectory(html)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/api")
add_subdirectory(images)
install(FILES
changelog.html
developers.html
documentation.html
documentation_bugs.html
documentation_example_code.html
documentation_format_overview.html
documentation_tools.html
documentation_tools_flac.html
documentation_tools_metaflac.html
faq.html
favicon.ico
features.html
flac.css
format.html
id.html
index.html
license.html
ogg_mapping.html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html")
install(FILES
logo.svg
logo130.gif
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/images")
add_subdirectory("c")
if(BUILD_CXXLIBS)
add_subdirectory("cpp")
endif()
add_subdirectory("decode/file")
add_subdirectory("encode/file")
add_executable(decode_file main.c)
target_link_libraries(decode_file FLAC-static)
add_executable(encode_file main.c)
target_link_libraries(encode_file FLAC-static)
add_subdirectory("decode/file")
add_subdirectory("encode/file")
add_executable(decode_file_cxx main.cpp)
target_link_libraries(decode_file_cxx FLACXX-static)
add_executable(encode_file_cxx main.cpp)
target_link_libraries(encode_file_cxx FLACXX-static)
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake")
if(MSVC)
return()
endif()
set(CMAKE_REQUIRED_LIBRARIES rt)
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
add_compile_definitions(
$<$<BOOL:${HAVE_CLOCK_GETTIME}>:HAVE_CLOCK_GETTIME>
$<$<BOOL:${APPLE}>:FLAC__SYS_DARWIN>)
add_executable(benchmark_residual benchmark_residual.c util.c)
target_include_directories(benchmark_residual PRIVATE
"$<TARGET_PROPERTY:FLAC-static,SOURCE_DIR>/include")
target_link_libraries(benchmark_residual
FLAC-static
$<$<BOOL:${HAVE_CLOCK_GETTIME}>:rt>)
......@@ -29,7 +29,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "util.h"
......
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(
ENABLE_64_BIT_WORDS=$<BOOL:${ENABLE_64_BIT_WORDS}>
FLAC__HAS_OGG=$<BOOL:${OGG_FOUND}>
WORDS_BIGENDIAN=$<BOOL:${CPU_IS_BIG_ENDIAN}>
$<$<BOOL:${HAVE_ICONV_H}>:HAVE_ICONV>
$<$<BOOL:${HAVE_SYS_PARAM_H}>:HAVE_SYS_PARAM_H>)
add_subdirectory("libFLAC")
if(BUILD_CXXLIBS)
add_subdirectory("libFLAC++")
endif()
add_subdirectory("flac")
add_subdirectory("metaflac")
add_subdirectory("share")
add_subdirectory("utils")
if(WITH_XMMS)
add_subdirectory("plugin_common")
add_subdirectory("plugin_xmms")
endif()
if(BUILD_TESTING)
add_subdirectory("test_libs_common")
add_subdirectory("test_libFLAC")
if(BUILD_CXXLIBS)
add_subdirectory("test_libFLAC++")
endif()
add_subdirectory("test_grabbag")
add_subdirectory("test_seeking")
add_subdirectory("test_streams")
endif()
cmake_minimum_required(VERSION 3.12)
check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
check_include_file("termios.h" HAVE_TERMIOS_H)
add_compile_definitions(
$<$<BOOL:${HAVE_SYS_IOCTL_H}>:HAVE_SYS_IOCTL_H>
$<$<BOOL:${HAVE_TERMIOS_H}>:HAVE_TERMIOS_H>)
add_executable(flac
analyze.c
decode.c
encode.c
foreign_metadata.c
main.c
local_string_utils.c
utils.c
vorbiscomment.c)
target_link_libraries(flac
FLAC-static
getopt
grabbag
replaygain_synthesis
utf8)
install(TARGETS flac EXPORT targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
configure_file(flac++.pc.in flac++.pc @ONLY)
check_cxx_source_compiles("
#ifdef __STDC_NO_VLA__
syntax error;
#else
int fvla (int m, int * c)
{
int D[m];
return D[0] == c[0];
}
int main(int, char * []) { return 0; }
#endif"
HAVE_CXX_VARARRAYS)
add_compile_definitions($<$<BOOL:${HAVE_CXX_VARARRAYS}>:HAVE_CXX_VARARRAYS>)
set(SOURCES
metadata.cpp
stream_decoder.cpp
stream_encoder.cpp)
add_library(FLACXX-static STATIC ${SOURCES})
target_compile_definitions(FLACXX-static PUBLIC FLAC__NO_DLL)
target_include_directories(FLACXX-static INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
target_link_libraries(FLACXX-static PUBLIC FLAC-static)
add_library(FLACXX SHARED ${SOURCES})
target_compile_definitions(FLACXX PRIVATE FLACPP_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
target_include_directories(FLACXX INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
target_link_libraries(FLACXX PRIVATE FLAC)
set_target_properties(FLACXX PROPERTIES CXX_VISIBILITY_PRESET hidden)
install(TARGETS FLACXX FLACXX-static EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
cmake_minimum_required(VERSION 3.12)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86(_64)?|(AMD|amd)64|i[346]86")
option(WITH_AVX "Enable AVX, AVX2 optimizations" ON)
option(WITH_SSE "Enable AVX, AVX2 optimizations" ON)
endif()
check_c_compiler_flag(-msse2 HAVE_MSSE2_FLAG)
if(HAVE_MSSE2_FLAG AND WITH_SSE)
add_compile_options(-msse2)
endif()
option(WITH_ASM "Use any assembly optimization routines" ON)
check_include_file("cpuid.h" HAVE_CPUID_H)
check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
set(CMAKE_REQUIRED_LIBRARIES m)
check_function_exists(lround HAVE_LROUND)
add_compile_definitions(
$<$<BOOL:${MSVC}>:_USE_MATH_DEFINES>
FLAC__USE_AVX=$<BOOL:${WITH_AVX}>
HAVE_LROUND=$<BOOL:${HAVE_LROUND}>
$<$<BOOL:${HAVE_CPUID_H}>:HAVE_CPUID_H>
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:FLAC__OVERFLOW_DETECT>)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86_64|(AMD|amd)64")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(IA32 TRUE)
endif()
add_compile_definitions(
FLAC__CPU_X86_64
FLAC__ALIGN_MALLOC_DATA)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "([xX]|i[346])86")
set(IA32 TRUE)
add_compile_definitions(
FLAC__CPU_IA32
FLAC__ALIGN_MALLOC_DATA)
endif()
include(CheckLanguage)
check_language(ASM_NASM)
if(CMAKE_ASM_NASM_COMPILER)
enable_language(ASM_NASM)
add_compile_definitions(FLAC__HAS_NASM)
endif()
if(NOT WITH_ASM)
add_compile_definitions(FLAC__NO_ASM)
endif()
if(WITH_ASM AND IA32 AND CMAKE_ASM_NASM_COMPILER)
add_subdirectory(ia32)
endif()
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
configure_file(flac.pc.in flac.pc @ONLY)
set(SOURCES
bitmath.c
bitreader.c
bitwriter.c
cpu.c
crc.c
fixed.c
fixed_intrin_sse2.c
fixed_intrin_ssse3.c
float.c
format.c
lpc.c
lpc_intrin_sse.c
lpc_intrin_sse2.c
lpc_intrin_sse41.c
lpc_intrin_avx2.c
lpc_intrin_vsx.c
md5.c
memory.c
metadata_iterators.c
metadata_object.c
stream_decoder.c
stream_encoder.c
stream_encoder_intrin_sse2.c
stream_encoder_intrin_ssse3.c
stream_encoder_intrin_avx2.c
stream_encoder_framing.c
window.c
$<$<BOOL:${OGG_FOUND}>:ogg_decoder_aspect.c>
$<$<BOOL:${OGG_FOUND}>:ogg_encoder_aspect.c>
$<$<BOOL:${OGG_FOUND}>:ogg_helper.c>
$<$<BOOL:${OGG_FOUND}>:ogg_mapping.c>
$<$<BOOL:${WIN32}>:windows_unicode_filenames.c>)
include_directories("include")
add_library(FLAC-static STATIC ${SOURCES})
target_compile_definitions(FLAC-static PUBLIC FLAC__NO_DLL)
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:FLAC-asm>
$<$<BOOL:${HAVE_LROUND}>:m>)
add_library(FLAC SHARED ${SOURCES})
target_compile_definitions(FLAC PRIVATE FLAC_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
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:FLAC-asm>
$<$<BOOL:${HAVE_LROUND}>:m>)
set_target_properties(FLAC PROPERTIES C_VISIBILITY_PRESET hidden)
install(TARGETS FLAC FLAC-static EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac.pc"
DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig")
cmake_minimum_required(VERSION 3.12)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
if(APPLE)
add_compile_options(-dOBJ_FORMAT_macho)
elseif(WIN32)
#add_compile_options(-d OBJ_FORMAT_win32)
# FIXME the command above doesn't seem to work on Windows
set(CMAKE_ASM_NASM_FLAGS -dOBJ_FORMAT_win32)
else()
add_compile_options(-dOBJ_FORMAT_elf)
endif()
add_library(FLAC-asm STATIC
cpu_asm.nasm
fixed_asm.nasm
lpc_asm.nasm)
add_executable(metaflac
main.c
operations.c
operations_shorthand_cuesheet.c
operations_shorthand_picture.c
operations_shorthand_seektable.c
operations_shorthand_streaminfo.c
operations_shorthand_vorbiscomment.c
options.c
usage.c
utils.c)
target_link_libraries(metaflac FLAC-static grabbag getopt utf8)
install(TARGETS metaflac EXPORT targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
add_library(plugin_common STATIC
charset.c
dither.c
replaygain.c
tags.c)
add_library(xmms-flac STATIC
charset.c
configure.c
fileinfo.c
http.c
plugin.c
tag.c)
target_link_libraries(xmms-flac plugin_common)
add_subdirectory("replaygain_analysis")
add_subdirectory("replaygain_synthesis")
add_subdirectory("getopt")
add_subdirectory("utf8")
if(WIN32)
add_subdirectory("win_utf8_io")
endif()
add_subdirectory("grabbag")
cmake_minimum_required(VERSION 3.12)
check_include_file("libintl.h" HAVE_LIBINTL_H)
check_include_file("string.h" HAVE_STRING_H)
add_compile_definitions(
$<$<BOOL:${HAVE_LIBINTL_H}>:HAVE_LIBINTL_H>
$<$<BOOL:${HAVE_STRING_H}>:HAVE_STRING_H>)
add_library(getopt STATIC
getopt.c
getopt1.c)
add_library(grabbag STATIC
alloc.c
cuesheet.c
file.c
picture.c
replaygain.c
seektable.c
snprintf.c)
target_link_libraries(grabbag
FLAC-static
replaygain_analysis
$<TARGET_NAME_IF_EXISTS:win_utf8_io>)
add_library(replaygain_analysis STATIC
replaygain_analysis.c)
add_library(replaygain_synthesis STATIC
replaygain_synthesis.c)
set(CMAKE_REQUIRED_LIBRARIES iconv)
check_symbol_exists(iconv "iconv.h" HAVE_ICONV_LIB)
add_library(utf8 STATIC
charset.c
iconvert.c
utf8.c)
target_link_libraries(utf8 PUBLIC $<$<BOOL:${HAVE_ICONV_LIB}>:iconv>)
add_library(win_utf8_io STATIC win_utf8_io.c)
add_subdirectory(cuesheet)
add_subdirectory(picture)
add_executable(test_cuesheet main.c)
target_link_libraries(test_cuesheet FLAC-static grabbag)
add_executable(test_picture main.c)
target_link_libraries(test_picture FLAC-static grabbag)
add_executable(test_libFLAC++
decoders.cpp
encoders.cpp
main.cpp
metadata.cpp
metadata_manip.cpp
metadata_object.cpp)
target_link_libraries(test_libFLAC++ FLACXX-static test_libs_common grabbag)
add_test(NAME FLACXX COMMAND test_libFLAC++)
add_executable(test_libFLAC
bitreader.c
bitwriter.c
crc.c
decoders.c
encoders.c
endswap.c
format.c
main.c
metadata.c
metadata_manip.c
metadata_object.c
md5.c)
target_compile_definitions(test_libFLAC PRIVATE
$<$<BOOL:${ENABLE_64_BIT_WORDS}>:ENABLE_64_BIT_WORDS>)
target_include_directories(test_libFLAC PRIVATE "$<TARGET_PROPERTY:FLAC-static,SOURCE_DIR>/include")
target_link_libraries(test_libFLAC FLAC-static grabbag test_libs_common)
add_test(NAME FLAC COMMAND test_libFLAC)
add_library(test_libs_common STATIC
file_utils_flac.c
metadata_utils.c)
target_link_libraries(test_libs_common PUBLIC FLAC-static)
add_executable(test_seeking main.c)
target_link_libraries(test_seeking FLAC-static)
add_executable(test_streams main.c)
target_link_libraries(test_streams FLAC-static grabbag)
if(BUILD_CXXLIBS)
add_subdirectory(flacdiff)
if(WIN32)
add_subdirectory(flactimer)
endif()
endif()
add_executable(flacdiff main.cpp)
target_link_libraries(flacdiff
FLACXX-static
$<TARGET_NAME_IF_EXISTS:win_utf8_io>)
\ No newline at end of file