From cc87acce1067d3f09fdef96a039213665f767681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conrad=20Berh=C3=B6rster?= Date: Wed, 20 Mar 2024 21:52:07 +0100 Subject: [PATCH 1/3] add cmake files for building with cmake --- CMakeLists.txt | 380 ++++++++++++++++++++++++++++++++++++ INSTALL | 9 + libaudiofile/config.h.cmake | 309 +++++++++++++++++++++++++++++ 3 files changed, 698 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 libaudiofile/config.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..722d382 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,380 @@ + +cmake_minimum_required (VERSION 3.5..3.26) + + +project(libaudiofile VERSION 0.3.6) + +# +# Variables +# + +set (CMAKE_C_STANDARD 99) +set (CMAKE_C_STANDARD_REQUIRED TRUE) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +set (PACKAGE_NAME ${PROJECT_NAME}) +set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set (CPACK_PACKAGE_VERSION_STAGE "") +set (CPACK_PACKAGE_VERSION_FULL "${PROJECT_VERSION}${CPACK_PACKAGE_VERSION_STAGE}") + +# +# System-wide includes +# + +include (GNUInstallDirs) +include (FeatureSummary) +include (CMakeDependentOption) +include (CTest) +include (CheckCCompilerFlag) + + + +# +# Options +# + +option (BUILD_SHARED_LIBS "Build shared libraries" OFF) + +if (BUILD_SHARED_LIBS AND BUILD_TESTING) + set (BUILD_TESTING OFF) + message ("Build testing required static libraries. To prevent build errors BUILD_TESTING disabled.") +endif () +option (BUILD_COMMANDS "Build commands" ON) +option (BUILD_EXAMPLES "Build examples" ON) +option (ENABLE_CPACK "Enable CPack support" ON) +option (ENABLE_BOW_DOCS "Enable black-on-white html docs" OFF) +if (MSVC AND (DEFINED ENABLE_STATIC_RUNTIME)) + option (ENABLE_STATIC_RUNTIME "Enable static runtime" ${ENABLE_STATIC_RUNTIME}) +elseif (MINGW) + option (ENABLE_STATIC_RUNTIME "Enable static runtime" OFF) +endif () +option (ENABLE_PACKAGE_CONFIG "Generate and install package config file" ON) +option (INSTALL_PKGCONFIG_MODULE "Generate and install pkg-config module" ON) + +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +if (CMAKE_VERSION VERSION_LESS 3.14) + list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlite") +endif () + + +# +# Setup configuration +# + +configure_file (libaudiofile/config.h.cmake libaudiofile/config.h) + +if (INSTALL_PKGCONFIG_MODULE) + + set (prefix ${CMAKE_INSTALL_PREFIX}) + set (exec_prefix "\$\{prefix\}") + set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}") + set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + set (VERSION ${PROJECT_VERSION}) + if (ENABLE_EXTERNAL_LIBS) + set (EXTERNAL_XIPH_REQUIRE "flac ogg vorbis vorbisenc opus") + if (ENABLE_EXPERIMENTAL) + set (EXTERNAL_XIPH_REQUIRE "${EXTERNAL_XIPH_REQUIRE} speex") + endif () + endif () + if (ENABLE_MPEG) + set (EXTERNAL_MPEG_REQUIRE "libmpg123") + set (EXTERNAL_MPEG_LIBS "-lmp3lame") + endif () + +# configure_file (sndfile.pc.in sndfile.pc @ONLY) + +endif () + +# +# libsndfile +# + +# Public libaudiofile headers +set (audiofile_HDRS + libaudiofile/audiofile.h + ) + + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libaudiofile }) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/libaudiofile) + + +#target_include_directories(Tutorial PUBLIC +# "${PROJECT_BINARY_DIR}" +# "${PROJECT_SOURCE_DIR}/MathFunctions" +# ) + +# +# libaudiofile static library +# + +set(libaudiofile_src + libaudiofile/AIFF.cpp + libaudiofile/FileHandle.h + libaudiofile/PacketTable.h + libaudiofile/aes.cpp + libaudiofile/error.h + libaudiofile/AIFF.h + libaudiofile/IFF.cpp + libaudiofile/Raw.cpp + libaudiofile/af_vfs.cpp + libaudiofile/extended.c + libaudiofile/AVR.cpp + libaudiofile/IFF.h + libaudiofile/Raw.h + libaudiofile/af_vfs.h + libaudiofile/extended.h + libaudiofile/AVR.h + libaudiofile/IRCAM.cpp + libaudiofile/SampleVision.cpp + libaudiofile/afinternal.h + libaudiofile/format.cpp + libaudiofile/AudioFormat.cpp + libaudiofile/IRCAM.h + libaudiofile/SampleVision.h + libaudiofile/g711.c + libaudiofile/AudioFormat.h + libaudiofile/Instrument.cpp + libaudiofile/Setup.cpp + libaudiofile/g711.h + libaudiofile/Buffer.cpp + libaudiofile/Instrument.h + libaudiofile/Setup.h + libaudiofile/audiofile.h + libaudiofile/Buffer.h + libaudiofile/Loop.cpp + libaudiofile/Shared.h + libaudiofile/aupv.c + libaudiofile/openclose.cpp + libaudiofile/CAF.cpp + libaudiofile/Tag.h + libaudiofile/aupvinternal.h + libaudiofile/pcm.cpp + libaudiofile/CAF.h + libaudiofile/Marker.cpp + libaudiofile/Track.cpp + libaudiofile/aupvlist.h + libaudiofile/pcm.h + libaudiofile/Compiler.h + libaudiofile/Marker.h + libaudiofile/Track.h + libaudiofile/byteorder.h + libaudiofile/query.cpp + libaudiofile/FLACFile.cpp + libaudiofile/Miscellaneous.cpp + libaudiofile/UUID.cpp + libaudiofile/compression.cpp + libaudiofile/units.cpp + libaudiofile/FLACFile.h + libaudiofile/NIST.cpp + libaudiofile/UUID.h + libaudiofile/compression.h + libaudiofile/units.h + libaudiofile/Features.h + libaudiofile/NIST.h + libaudiofile/VOC.cpp + libaudiofile/data.cpp + libaudiofile/util.cpp + libaudiofile/File.cpp + libaudiofile/NeXT.cpp + libaudiofile/VOC.h + libaudiofile/debug.cpp + libaudiofile/util.h + libaudiofile/File.h + libaudiofile/NeXT.h + libaudiofile/WAVE.cpp + libaudiofile/debug.h + libaudiofile/FileHandle.cpp + libaudiofile/PacketTable.cpp + libaudiofile/WAVE.h + libaudiofile/error.c + libaudiofile/modules/ALAC.cpp + libaudiofile/modules/FileModule.cpp + libaudiofile/modules/MSADPCM.cpp + libaudiofile/modules/ModuleState.h + libaudiofile/modules/SimpleModule.h + libaudiofile/modules/ALAC.h + libaudiofile/modules/FileModule.h + libaudiofile/modules/MSADPCM.h + libaudiofile/modules/PCM.cpp + libaudiofile/modules/BlockCodec.cpp + libaudiofile/modules/G711.cpp + libaudiofile/modules/PCM.h + libaudiofile/modules/BlockCodec.h + libaudiofile/modules/G711.h + libaudiofile/modules/Module.cpp + libaudiofile/modules/RebufferModule.cpp + libaudiofile/modules/FLAC.cpp + libaudiofile/modules/IMA.cpp + libaudiofile/modules/Module.h + libaudiofile/modules/RebufferModule.h + libaudiofile/modules/FLAC.h + libaudiofile/modules/IMA.h + libaudiofile/modules/ModuleState.cpp + libaudiofile/modules/SimpleModule.cpp + libaudiofile/alac/ALACAudioTypes.h + libaudiofile/alac/ALACDecoder.h + libaudiofile/alac/EndianPortable.h + libaudiofile/alac/aglib.h + libaudiofile/alac/matrix_dec.c + libaudiofile/alac/ALACBitUtilities.c + libaudiofile/alac/ALACEncoder.cpp + libaudiofile/alac/dp_dec.c + libaudiofile/alac/matrix_enc.c + libaudiofile/alac/ALACBitUtilities.h + libaudiofile/alac/ALACEncoder.h + libaudiofile/alac/ag_dec.c + libaudiofile/alac/dp_enc.c + libaudiofile/alac/matrixlib.h + libaudiofile/alac/ALACDecoder.cpp + libaudiofile/alac/EndianPortable.c + libaudiofile/alac/ag_enc.c + libaudiofile/alac/dplib.h + ${audiofile_HDRS} + ${CMAKE_CURRENT_BINARY_DIR}/libaudiofile/config.h +) + + +add_library (libaudiofile_shared SHARED ${libaudiofile_src} ) + +SET_TARGET_PROPERTIES (libaudiofile_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1) + + +target_include_directories (libaudiofile_shared + PUBLIC + $ + $ + $ + PRIVATE + libaudiofile_shared + $ + ) + + + +#install( +# TARGETS foo +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib +# RUNTIME DESTINATION bin +#) + + + + +# +# Testing +# + +if (BUILD_TESTING_) + + + enable_testing () + ### test_main + + add_executable (test_main + test/ADPCM.cpp + test/instparamwrite.c + test/AES.cpp + test/Marker.cpp + test/printmarkers.c + test/ALAC.cpp + test/Miscellaneous.cpp + test/query2.c + test/ChannelMatrix.cpp + test/NeXT.cpp + test/sixteen-to-eight.c + test/Error.cpp + test/PCMData.cpp + test/testaupv.c + test/FLAC.cpp + test/PCMMapping.cpp + test/testchannelmatrix.c + test/FloatToInt.cpp + test/Pipe.cpp + test/testdouble.c + test/FormatWithChannels.cpp + test/Query.cpp + test/testfloat.c + test/Identify.cpp + test/SampleFormat.cpp + test/testmarkers.c + test/Instrument.cpp + test/Seek.cpp + test/twentyfour.c + test/IntToFloat.cpp + test/Sign.cpp + test/twentyfour2.c + test/InvalidCompressionFormat.cpp + test/TestUtilities.cpp + test/writealaw.c + test/InvalidSampleFormat.cpp + test/TestUtilities.h + test/writeraw.c + test/Large.cpp + test/VirtualFile.cpp + test/writeulaw.c + test/Loop.cpp + test/floatto24.c + test/Lossless.h + test/instparamtest.c + ) + + target_include_directories (test_main + PUBLIC + src + ${CMAKE_CURRENT_BINARY_DIR}/libaudiofile + ${CMAKE_CURRENT_BINARY_DIR}/test + ) + target_link_libraries (test_main PRIVATE libaudiofile_shared) + if (MSVC) + target_compile_definitions (test_main PRIVATE _USE_MATH_DEFINES) + endif () + add_test (test_main test_main) + + +endif () + + + + +# +# Programs +# +if (BUILD_COMMANDS) + + +# libaudiofile-info + + add_executable (sfinfo + sfcommands/sfinfo.c + sfcommands/printinfo.c + sfcommands/printinfo.h + ) + + target_link_libraries (sfinfo + PRIVATE + libaudiofile_shared + $<$:m> + ) + + +# sfconvert + + add_executable (sfconvert + sfcommands/sfconvert.c + sfcommands/printinfo.c + sfcommands/printinfo.h + ) + + target_link_libraries (sfconvert + PRIVATE + libaudiofile_shared + $<$:m> + ) + +endif () + diff --git a/INSTALL b/INSTALL index b42a17a..98676a6 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,12 @@ + + +Install with cmake +===================== +cmake -S . -B build +cmake --build build + + + Basic Installation ================== diff --git a/libaudiofile/config.h.cmake b/libaudiofile/config.h.cmake new file mode 100644 index 0000000..9e2cf45 --- /dev/null +++ b/libaudiofile/config.h.cmake @@ -0,0 +1,309 @@ +/* Set to 1 if the compile is GNU GCC. */ +#cmakedefine01 COMPILER_IS_GCC + +/* Target processor is big endian. */ +#cmakedefine01 CPU_IS_BIG_ENDIAN + +/* Target processor is little endian. */ +#cmakedefine01 CPU_IS_LITTLE_ENDIAN + +/* Set to 1 to enable experimental code. */ +#cmakedefine01 ENABLE_EXPERIMENTAL_CODE + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_ALSA_ASOUNDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_BYTESWAP_H + +/* Define to 1 if you have the `calloc' function. */ +#cmakedefine01 HAVE_CALLOC + +/* Define to 1 if you have the `ceil' function. */ +#cmakedefine01 HAVE_CEIL + +/* Set to 1 if S_IRGRP is defined. */ +#cmakedefine01 HAVE_DECL_S_IRGRP + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DIRECT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_ENDIAN_H + +/* Will be set to 1 if flac, ogg and vorbis are available. */ +#cmakedefine01 HAVE_EXTERNAL_XIPH_LIBS + +/* Will be set to 1 if lame and mpg123 are available. */ +#cmakedefine01 HAVE_MPEG + +/* Define to 1 if you have the `floor' function. */ +#cmakedefine01 HAVE_FLOOR + +/* Define to 1 if you have the `fmod' function. */ +#cmakedefine01 HAVE_FMOD + +/* Define to 1 if you have the `free' function. */ +#cmakedefine01 HAVE_FREE + +/* Define to 1 if you have the `fstat' function. */ +#cmakedefine01 HAVE_FSTAT + +/* Define to 1 if you have the `fstat64' function. */ +#cmakedefine01 HAVE_FSTAT64 + +/* Define to 1 if you have the `fsync' function. */ +#cmakedefine01 HAVE_FSYNC + +/* Define to 1 if you have the `ftruncate' function. */ +#cmakedefine01 HAVE_FTRUNCATE + +/* Define to 1 if you have the `getpagesize' function. */ +#cmakedefine01 HAVE_GETPAGESIZE + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine01 HAVE_GETTIMEOFDAY + +/* Define if you have the `gmtime' function. */ +#cmakedefine HAVE_GMTIME + +/* Define if you have the `gmtime_r' function. */ +#cmakedefine HAVE_GMTIME_R + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IO_H + +/* Define to 1 if you have the `m' library (-lm). */ +#cmakedefine01 HAVE_LIBM + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_LOCALE_H + +/* Define if you have the `localtime' function. */ +#cmakedefine HAVE_LOCALTIME + +/* Define if you have the `localtime_r' function. */ +#cmakedefine HAVE_LOCALTIME_R + +/* Define if you have C99's lrint function. */ +#cmakedefine01 HAVE_LRINT + +/* Define if you have C99's lrintf function. */ +#cmakedefine01 HAVE_LRINTF + +/* Define to 1 if you have the `lround' function. */ +#cmakedefine01 HAVE_LROUND + +/* Define to 1 if you have the `lseek' function. */ +#cmakedefine01 HAVE_LSEEK + +/* Define to 1 if you have the `lseek64' function. */ +#cmakedefine01 HAVE_LSEEK64 + +/* Define to 1 if you have the `malloc' function. */ +#cmakedefine01 HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_MEMORY_H + +/* Define to 1 if you have the `mmap' function. */ +#cmakedefine01 HAVE_MMAP + +/* Define to 1 if you have the `open' function. */ +#cmakedefine01 HAVE_OPEN + +/* Define to 1 if you have the `pipe' function. */ +#cmakedefine01 HAVE_PIPE + +/* Define to 1 if you have the `read' function. */ +#cmakedefine01 HAVE_READ + +/* Define to 1 if you have the `realloc' function. */ +#cmakedefine01 HAVE_REALLOC + +/* Define to 1 if you have the `setlocale' function. */ +#cmakedefine01 HAVE_SETLOCALE + +/* Set to 1 if is available. */ +#cmakedefine01 HAVE_SNDIO_H + +/* Define to 1 if you have the `snprintf' function. */ +#cmakedefine01 HAVE_SNPRINTF + +/* Set to 1 if you have libsqlite3. */ +#cmakedefine01 HAVE_SQLITE3 + +/* Define to 1 if the system has the type `ssize_t'. */ +#cmakedefine01 HAVE_SSIZE_T + +#if (HAVE_SSIZE_T == 0) +#define ssize_t intptr_t +#endif + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#cmakedefine01 HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_IMMINTRIN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDBOOL_H + +/* Define to 1 if you have the `vsnprintf' function. */ +#cmakedefine01 HAVE_VSNPRINTF + +/* Define to 1 if you have the `waitpid' function. */ +#cmakedefine01 HAVE_WAITPID + +/* Define to 1 if you have the `write' function. */ +#cmakedefine01 HAVE_WRITE + +/* The darwin version, no-zero is valid */ +#cmakedefine01 OSX_DARWIN_VERSION + +/* Set to 1 if compiling for OpenBSD */ +#cmakedefine01 OS_IS_OPENBSD + +/* Set to 1 if compiling for Win32 */ +#cmakedefine01 OS_IS_WIN32 + +/* Set to 1 if SSE2 is enabled */ +#cmakedefine USE_SSE2 + +/* Name of package */ +#define PACKAGE "@PACKAGE_NAME@" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@PACKAGE_NAME@" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@PACKAGE_NAME@ @CPACK_PACKAGE_VERSION_FULL@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@PACKAGE_NAME@" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "@PACKAGE_URL@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@CPACK_PACKAGE_VERSION_FULL@" + +/* The size of `double', as computed by sizeof. */ +@SIZEOF_DOUBLE_CODE@ + +/* The size of `float', as computed by sizeof. */ +@SIZEOF_FLOAT_CODE@ + +/* The size of `int', as computed by sizeof. */ +@SIZEOF_INT_CODE@ + +/* The size of `int64_t', as computed by sizeof. */ +@SIZEOF_INT64_T_CODE@ + +/* The size of `loff_t', as computed by sizeof. */ +@SIZEOF_LOFF_T_CODE@ + +/* The size of `long', as computed by sizeof. */ +@SIZEOF_LONG_CODE@ + +/* The size of `long long', as computed by sizeof. */ +@SIZEOF_LONG_LONG_CODE@ + +/* The size of `off64_t', as computed by sizeof. */ +@SIZEOF_OFF64_T_CODE@ + +/* The size of `off_t', as computed by sizeof. */ +@SIZEOF_OFF_T_CODE@ + +/* The size of `short', as computed by sizeof. */ +@SIZEOF_SHORT_CODE@ + +/* The size of `size_t', as computed by sizeof. */ +@SIZEOF_SIZE_T_CODE@ + +/* The size of `ssize_t', as computed by sizeof. */ +@SIZEOF_SSIZE_T_CODE@ + +/* The size of `void*', as computed by sizeof. */ +@SIZEOF_VOIDP_CODE@ + +/* The size of `wchar_t', as computed by sizeof. */ +@SIZEOF_WCHAR_T_CODE@ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Set to 1 to use the native windows API */ +#cmakedefine01 USE_WINDOWS_API + +/* Version number of package */ +#define VERSION "@PROJECT_VERSION@" + +/* Set to 1 if windows DLL is being built. */ +#cmakedefine01 WIN32_TARGET_DLL + +/* Target processor is big endian. */ +#cmakedefine01 WORDS_BIGENDIAN + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Define to 1 if on MINIX. */ +#cmakedefine01 _MINIX + +/* Define as `__inline' or '__inline__' if that's what the C compiler calls it, or to nothing if it is not supported. */ +@INLINE_CODE@ From f47fbd5126725c5697b49772e0a330f34948bc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conrad=20Berh=C3=B6rster?= Date: Mon, 9 Sep 2024 22:33:25 +0200 Subject: [PATCH 2/3] add cmake install --- CMakeLists.txt | 86 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 722d382..3c29457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,10 @@ project(libaudiofile VERSION 0.3.6) # Variables # -set (CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +#add_compile_options(-std=c++14) +set (CMAKE_C_STANDARD 17) set (CMAKE_C_STANDARD_REQUIRED TRUE) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -238,10 +241,22 @@ set(libaudiofile_src ) +# +# libaudiofile +# + +# Public libsndfile headers +set (audiofile_HDRS + libaudiofile/audiofile.h + ) + + add_library (libaudiofile_shared SHARED ${libaudiofile_src} ) SET_TARGET_PROPERTIES (libaudiofile_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1) +set_target_properties (libaudiofile_shared PROPERTIES + PUBLIC_HEADER "${audiofile_HDRS}" ) target_include_directories (libaudiofile_shared PUBLIC @@ -378,3 +393,72 @@ if (BUILD_COMMANDS) endif () +# +# Installation +# + +if (ENABLE_PACKAGE_CONFIG) + + if (WIN32 AND (NOT MINGW) AND (NOT CYGWIN)) + set (CMAKE_INSTALL_PACKAGEDIR cmake) + else () + set (CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/AudioFile) + endif() + + install (TARGETS ${AUDIOFILE_PROGRAM_TARGETS} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + + install (TARGETS libaudiofile_shared + EXPORT AudioFileTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + export (EXPORT AudioFileTargets NAMESPACE SndFile:: FILE ${PROJECT_BINARY_DIR}/AudioFileTargets.cmake) + + include (CMakePackageConfigHelpers) + + set (INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) + configure_package_config_file(libaudiofile/config.h.cmake AudioFileConfig.cmake + INSTALL_DESTINATION ${PROJECT_BINARY_DIR} + INSTALL_PREFIX ${PROJECT_BINARY_DIR} + PATH_VARS INCLUDE_INSTALL_DIR + ) + configure_package_config_file(libaudiofile/config.h.cmake AudioFileConfig2.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} + PATH_VARS INCLUDE_INSTALL_DIR + ) + write_basic_package_version_file (AudioFileConfigVersion.cmake COMPATIBILITY SameMajorVersion) + + install(EXPORT AudioFileTargets + NAMESPACE AudioFile:: + DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} + ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/AudioFileConfig2.cmake + RENAME AudioFileConfig.cmake + DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} + ) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/AudioFileConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} + ) + + if (NOT BUILD_SHARED_LIBS AND FIND_MODULES_INSTALL_LIST) + file(COPY ${FIND_MODULES_INSTALL_LIST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + install(FILES ${FIND_MODULES_INSTALL_LIST} DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) + endif () +else () + + install (TARGETS audiofile ${audiofile_PROGRAMS} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +endif () + From b88c5ddcb184378ecab270f6a12485b2860ec5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conrad=20Berh=C3=B6rster?= Date: Thu, 19 Sep 2024 19:41:02 +0200 Subject: [PATCH 3/3] install as shared library --- CMakeLists.txt | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c29457..2f4bf15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,14 @@ if (CMAKE_VERSION VERSION_LESS 3.14) list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlite") endif () +option (INSTALL_PKGCONFIG_MODULE "Generate and install pkg-config module" ON) + + + +add_feature_info (BUILD_SHARED_LIBS BUILD_SHARED_LIBS "build shared libraries") +add_feature_info (ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file") +add_feature_info (INSTALL_PKGCONFIG_MODULE INSTALL_PKGCONFIG_MODULE "generate and install pkg-config module") + # # Setup configuration @@ -75,26 +83,15 @@ if (INSTALL_PKGCONFIG_MODULE) set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}") set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") set (VERSION ${PROJECT_VERSION}) - if (ENABLE_EXTERNAL_LIBS) - set (EXTERNAL_XIPH_REQUIRE "flac ogg vorbis vorbisenc opus") - if (ENABLE_EXPERIMENTAL) - set (EXTERNAL_XIPH_REQUIRE "${EXTERNAL_XIPH_REQUIRE} speex") - endif () - endif () - if (ENABLE_MPEG) - set (EXTERNAL_MPEG_REQUIRE "libmpg123") - set (EXTERNAL_MPEG_LIBS "-lmp3lame") - endif () -# configure_file (sndfile.pc.in sndfile.pc @ONLY) + configure_file (audiofile.pc.in audiofile.pc @ONLY) endif () # -# libsndfile +# libaudiofile # -# Public libaudiofile headers set (audiofile_HDRS libaudiofile/audiofile.h ) @@ -248,23 +245,24 @@ set(libaudiofile_src # Public libsndfile headers set (audiofile_HDRS libaudiofile/audiofile.h + libaudiofile/aupvlist.h ) -add_library (libaudiofile_shared SHARED ${libaudiofile_src} ) +add_library (audiofile SHARED ${libaudiofile_src} ) -SET_TARGET_PROPERTIES (libaudiofile_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1) +SET_TARGET_PROPERTIES (audiofile PROPERTIES CLEAN_DIRECT_OUTPUT 1) -set_target_properties (libaudiofile_shared PROPERTIES +set_target_properties (audiofile PROPERTIES PUBLIC_HEADER "${audiofile_HDRS}" ) -target_include_directories (libaudiofile_shared +target_include_directories (audiofile PUBLIC $ $ $ PRIVATE - libaudiofile_shared + audiofile $ ) @@ -279,6 +277,11 @@ target_include_directories (libaudiofile_shared +if (INSTALL_PKGCONFIG_MODULE) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/audiofile.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif () + + # # Testing @@ -344,7 +347,7 @@ if (BUILD_TESTING_) ${CMAKE_CURRENT_BINARY_DIR}/libaudiofile ${CMAKE_CURRENT_BINARY_DIR}/test ) - target_link_libraries (test_main PRIVATE libaudiofile_shared) + target_link_libraries (test_main PRIVATE audiofile) if (MSVC) target_compile_definitions (test_main PRIVATE _USE_MATH_DEFINES) endif () @@ -372,7 +375,7 @@ if (BUILD_COMMANDS) target_link_libraries (sfinfo PRIVATE - libaudiofile_shared + audiofile $<$:m> ) @@ -387,7 +390,7 @@ if (BUILD_COMMANDS) target_link_libraries (sfconvert PRIVATE - libaudiofile_shared + audiofile $<$:m> ) @@ -409,7 +412,7 @@ if (ENABLE_PACKAGE_CONFIG) RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) - install (TARGETS libaudiofile_shared + install (TARGETS audiofile EXPORT AudioFileTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -417,7 +420,7 @@ if (ENABLE_PACKAGE_CONFIG) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) - export (EXPORT AudioFileTargets NAMESPACE SndFile:: FILE ${PROJECT_BINARY_DIR}/AudioFileTargets.cmake) + export (EXPORT AudioFileTargets NAMESPACE AudioFile:: FILE ${PROJECT_BINARY_DIR}/AudioFileTargets.cmake) include (CMakePackageConfigHelpers)