diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..a4870fe5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,123 @@ +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}" + $<$:HAVE_BYTESWAP_H> + $<$:HAVE_INTTYPES_H> + $<$:HAVE_STDINT_H> + $<$:_CRT_SECURE_NO_WARNINGS> + CPU_IS_BIG_ENDIAN=$ + CPU_IS_LITTLE_ENDIAN=$> + FLAC__HAS_X86INTRIN=$ + HAVE_BSWAP16=$ + HAVE_BSWAP32=$) + +add_compile_options( + $<$:/wd4267> + $<$:/wd4996> + $<$:-Werror> + $<$,$>:-fstack-protector> + $<$,$>:--param> + $<$,$>: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}") diff --git a/cmake/UseSystemExtensions.cmake b/cmake/UseSystemExtensions.cmake new file mode 100644 index 00000000..4a33fd4b --- /dev/null +++ b/cmake/UseSystemExtensions.cmake @@ -0,0 +1,81 @@ +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 + mbstate_t x; + int main() { return 0; }" + HAVE_MBSTATE) +if(NOT HAVE_MBSTATE) + check_c_source_compiles(" + #define _XOPEN_SOURCE 500 + #include + mbstate_t x; + int main() { return 0; }" + DODEFINE_XOPEN_SOURCE) +endif() +check_c_source_compiles(" + #define __EXTENSIONS__ 1 + #include + #ifdef HAVE_SYS_TYPES_H + # include + #endif + #ifdef HAVE_SYS_STAT_H + # include + #endif + #ifdef STDC_HEADERS + # include + # include + #else + # ifdef HAVE_STDLIB_H + # include + # endif + #endif + #ifdef HAVE_STRING_H + # if !defined STDC_HEADERS && defined HAVE_MEMORY_H + # include + # endif + # include + #endif + #ifdef HAVE_STRINGS_H + # include + #endif + #ifdef HAVE_INTTYPES_H + # include + #endif + #ifdef HAVE_STDINT_H + # include + #endif + #ifdef HAVE_UNISTD_H + # include + #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 + $<$,$,$>>:_FORTIFY_SOURCE=2> + $<$:_XOPEN_SOURCE=500> + $<$:__EXTENSIONS__>) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..a4e38ef9 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,23 @@ +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") diff --git a/doc/html/CMakeLists.txt b/doc/html/CMakeLists.txt new file mode 100644 index 00000000..6ac1e116 --- /dev/null +++ b/doc/html/CMakeLists.txt @@ -0,0 +1,22 @@ +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") diff --git a/doc/html/images/CMakeLists.txt b/doc/html/images/CMakeLists.txt new file mode 100644 index 00000000..922d305c --- /dev/null +++ b/doc/html/images/CMakeLists.txt @@ -0,0 +1,4 @@ +install(FILES + logo.svg + logo130.gif +DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/images") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..96298fd7 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory("c") +if(BUILD_CXXLIBS) + add_subdirectory("cpp") +endif() diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt new file mode 100644 index 00000000..41153417 --- /dev/null +++ b/examples/c/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory("decode/file") +add_subdirectory("encode/file") diff --git a/examples/c/decode/file/CMakeLists.txt b/examples/c/decode/file/CMakeLists.txt new file mode 100644 index 00000000..60dc18e0 --- /dev/null +++ b/examples/c/decode/file/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(decode_file main.c) +target_link_libraries(decode_file FLAC-static) diff --git a/examples/c/encode/file/CMakeLists.txt b/examples/c/encode/file/CMakeLists.txt new file mode 100644 index 00000000..c9c8e802 --- /dev/null +++ b/examples/c/encode/file/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(encode_file main.c) +target_link_libraries(encode_file FLAC-static) diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt new file mode 100644 index 00000000..41153417 --- /dev/null +++ b/examples/cpp/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory("decode/file") +add_subdirectory("encode/file") diff --git a/examples/cpp/decode/file/CMakeLists.txt b/examples/cpp/decode/file/CMakeLists.txt new file mode 100644 index 00000000..0cea828a --- /dev/null +++ b/examples/cpp/decode/file/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(decode_file_cxx main.cpp) +target_link_libraries(decode_file_cxx FLACXX-static) diff --git a/examples/cpp/encode/file/CMakeLists.txt b/examples/cpp/encode/file/CMakeLists.txt new file mode 100644 index 00000000..b4526d71 --- /dev/null +++ b/examples/cpp/encode/file/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(encode_file_cxx main.cpp) +target_link_libraries(encode_file_cxx FLACXX-static) diff --git a/flac-config.cmake.in b/flac-config.cmake.in new file mode 100644 index 00000000..89c6e7d0 --- /dev/null +++ b/flac-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake") diff --git a/microbench/CMakeLists.txt b/microbench/CMakeLists.txt new file mode 100644 index 00000000..64042059 --- /dev/null +++ b/microbench/CMakeLists.txt @@ -0,0 +1,17 @@ +if(MSVC) + return() +endif() + +set(CMAKE_REQUIRED_LIBRARIES rt) +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) + +add_compile_definitions( + $<$:HAVE_CLOCK_GETTIME> + $<$:FLAC__SYS_DARWIN>) + +add_executable(benchmark_residual benchmark_residual.c util.c) +target_include_directories(benchmark_residual PRIVATE + "$/include") +target_link_libraries(benchmark_residual + FLAC-static + $<$:rt>) diff --git a/microbench/util.c b/microbench/util.c index e8389ed9..66003d79 100644 --- a/microbench/util.c +++ b/microbench/util.c @@ -29,7 +29,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#ifdef HAVE_CONFIG_H +# include +#endif #include #include "util.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..7de7a7fa --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,43 @@ +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=$ + FLAC__HAS_OGG=$ + WORDS_BIGENDIAN=$ + $<$:HAVE_ICONV> + $<$: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() diff --git a/src/flac/CMakeLists.txt b/src/flac/CMakeLists.txt new file mode 100644 index 00000000..3fb2e2f7 --- /dev/null +++ b/src/flac/CMakeLists.txt @@ -0,0 +1,27 @@ +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( + $<$:HAVE_SYS_IOCTL_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}") diff --git a/src/libFLAC++/CMakeLists.txt b/src/libFLAC++/CMakeLists.txt new file mode 100644 index 00000000..83031420 --- /dev/null +++ b/src/libFLAC++/CMakeLists.txt @@ -0,0 +1,48 @@ +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($<$: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 + "$" + "$") +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 + "$" + "$") +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") diff --git a/src/libFLAC/CMakeLists.txt b/src/libFLAC/CMakeLists.txt new file mode 100644 index 00000000..1ea9383a --- /dev/null +++ b/src/libFLAC/CMakeLists.txt @@ -0,0 +1,124 @@ +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( + $<$:_USE_MATH_DEFINES> + FLAC__USE_AVX=$ + HAVE_LROUND=$ + $<$:HAVE_CPUID_H> + $<$,$>: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 + $<$:ogg_decoder_aspect.c> + $<$:ogg_encoder_aspect.c> + $<$:ogg_helper.c> + $<$:ogg_mapping.c> + $<$: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 + "$" + "$") +target_link_libraries(FLAC-static PUBLIC + $ + $ + $<$:m>) + +add_library(FLAC SHARED ${SOURCES}) +target_compile_definitions(FLAC PRIVATE FLAC_API_EXPORTS FLAC__USE_VISIBILITY_ATTR) +target_include_directories(FLAC INTERFACE + "$" + "$") +target_link_libraries(FLAC PRIVATE + $ + $<$: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") diff --git a/src/libFLAC/ia32/CMakeLists.txt b/src/libFLAC/ia32/CMakeLists.txt new file mode 100644 index 00000000..94357064 --- /dev/null +++ b/src/libFLAC/ia32/CMakeLists.txt @@ -0,0 +1,18 @@ +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) diff --git a/src/metaflac/CMakeLists.txt b/src/metaflac/CMakeLists.txt new file mode 100644 index 00000000..8f99d646 --- /dev/null +++ b/src/metaflac/CMakeLists.txt @@ -0,0 +1,15 @@ +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}") diff --git a/src/plugin_common/CMakeLists.txt b/src/plugin_common/CMakeLists.txt new file mode 100644 index 00000000..b5c72c92 --- /dev/null +++ b/src/plugin_common/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(plugin_common STATIC + charset.c + dither.c + replaygain.c + tags.c) diff --git a/src/plugin_xmms/CMakeLists.txt b/src/plugin_xmms/CMakeLists.txt new file mode 100644 index 00000000..3c4b716d --- /dev/null +++ b/src/plugin_xmms/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(xmms-flac STATIC + charset.c + configure.c + fileinfo.c + http.c + plugin.c + tag.c) +target_link_libraries(xmms-flac plugin_common) diff --git a/src/share/CMakeLists.txt b/src/share/CMakeLists.txt new file mode 100644 index 00000000..b3c5a712 --- /dev/null +++ b/src/share/CMakeLists.txt @@ -0,0 +1,8 @@ +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") diff --git a/src/share/getopt/CMakeLists.txt b/src/share/getopt/CMakeLists.txt new file mode 100644 index 00000000..a247336c --- /dev/null +++ b/src/share/getopt/CMakeLists.txt @@ -0,0 +1,12 @@ +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( + $<$:HAVE_LIBINTL_H> + $<$:HAVE_STRING_H>) + +add_library(getopt STATIC + getopt.c + getopt1.c) diff --git a/src/share/grabbag/CMakeLists.txt b/src/share/grabbag/CMakeLists.txt new file mode 100644 index 00000000..6d405d05 --- /dev/null +++ b/src/share/grabbag/CMakeLists.txt @@ -0,0 +1,12 @@ +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 + $) diff --git a/src/share/replaygain_analysis/CMakeLists.txt b/src/share/replaygain_analysis/CMakeLists.txt new file mode 100644 index 00000000..4362b902 --- /dev/null +++ b/src/share/replaygain_analysis/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(replaygain_analysis STATIC + replaygain_analysis.c) diff --git a/src/share/replaygain_synthesis/CMakeLists.txt b/src/share/replaygain_synthesis/CMakeLists.txt new file mode 100644 index 00000000..0736f4fc --- /dev/null +++ b/src/share/replaygain_synthesis/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(replaygain_synthesis STATIC + replaygain_synthesis.c) diff --git a/src/share/utf8/CMakeLists.txt b/src/share/utf8/CMakeLists.txt new file mode 100644 index 00000000..e0e32ac1 --- /dev/null +++ b/src/share/utf8/CMakeLists.txt @@ -0,0 +1,9 @@ +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 $<$:iconv>) diff --git a/src/share/win_utf8_io/CMakeLists.txt b/src/share/win_utf8_io/CMakeLists.txt new file mode 100644 index 00000000..797e728b --- /dev/null +++ b/src/share/win_utf8_io/CMakeLists.txt @@ -0,0 +1 @@ +add_library(win_utf8_io STATIC win_utf8_io.c) diff --git a/src/test_grabbag/CMakeLists.txt b/src/test_grabbag/CMakeLists.txt new file mode 100644 index 00000000..56abe810 --- /dev/null +++ b/src/test_grabbag/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(cuesheet) +add_subdirectory(picture) diff --git a/src/test_grabbag/cuesheet/CMakeLists.txt b/src/test_grabbag/cuesheet/CMakeLists.txt new file mode 100644 index 00000000..35c1987d --- /dev/null +++ b/src/test_grabbag/cuesheet/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test_cuesheet main.c) +target_link_libraries(test_cuesheet FLAC-static grabbag) diff --git a/src/test_grabbag/picture/CMakeLists.txt b/src/test_grabbag/picture/CMakeLists.txt new file mode 100644 index 00000000..0ae66449 --- /dev/null +++ b/src/test_grabbag/picture/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test_picture main.c) +target_link_libraries(test_picture FLAC-static grabbag) diff --git a/src/test_libFLAC++/CMakeLists.txt b/src/test_libFLAC++/CMakeLists.txt new file mode 100644 index 00000000..a517faed --- /dev/null +++ b/src/test_libFLAC++/CMakeLists.txt @@ -0,0 +1,10 @@ +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++) diff --git a/src/test_libFLAC/CMakeLists.txt b/src/test_libFLAC/CMakeLists.txt new file mode 100644 index 00000000..9a4a475b --- /dev/null +++ b/src/test_libFLAC/CMakeLists.txt @@ -0,0 +1,20 @@ +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 + $<$:ENABLE_64_BIT_WORDS>) +target_include_directories(test_libFLAC PRIVATE "$/include") +target_link_libraries(test_libFLAC FLAC-static grabbag test_libs_common) + +add_test(NAME FLAC COMMAND test_libFLAC) diff --git a/src/test_libs_common/CMakeLists.txt b/src/test_libs_common/CMakeLists.txt new file mode 100644 index 00000000..806f3530 --- /dev/null +++ b/src/test_libs_common/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(test_libs_common STATIC + file_utils_flac.c + metadata_utils.c) +target_link_libraries(test_libs_common PUBLIC FLAC-static) diff --git a/src/test_seeking/CMakeLists.txt b/src/test_seeking/CMakeLists.txt new file mode 100644 index 00000000..1c2a2f4b --- /dev/null +++ b/src/test_seeking/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test_seeking main.c) +target_link_libraries(test_seeking FLAC-static) diff --git a/src/test_streams/CMakeLists.txt b/src/test_streams/CMakeLists.txt new file mode 100644 index 00000000..13e30234 --- /dev/null +++ b/src/test_streams/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test_streams main.c) +target_link_libraries(test_streams FLAC-static grabbag) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt new file mode 100644 index 00000000..cd7b060f --- /dev/null +++ b/src/utils/CMakeLists.txt @@ -0,0 +1,6 @@ +if(BUILD_CXXLIBS) + add_subdirectory(flacdiff) + if(WIN32) + add_subdirectory(flactimer) + endif() +endif() diff --git a/src/utils/flacdiff/CMakeLists.txt b/src/utils/flacdiff/CMakeLists.txt new file mode 100644 index 00000000..d64383ff --- /dev/null +++ b/src/utils/flacdiff/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(flacdiff main.cpp) +target_link_libraries(flacdiff + FLACXX-static + $) \ No newline at end of file diff --git a/src/utils/flactimer/CMakeLists.txt b/src/utils/flactimer/CMakeLists.txt new file mode 100644 index 00000000..d40de89c --- /dev/null +++ b/src/utils/flactimer/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(flactimer main.cpp) +target_link_libraries(flactimer FLACXX-static)