CMake minimum required lowered to 3.1

This commit is contained in:
Vitaly Kirsanov 2019-04-25 14:14:28 +00:00 committed by Erik de Castro Lopo
parent d38b867f68
commit a82a014cf1
10 changed files with 296 additions and 88 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.0)
project(FLAC VERSION 1.3.2 HOMEPAGE_URL "https://www.xiph.org/flac/")
project(FLAC VERSION 1.3.2) # HOMEPAGE_URL "https://www.xiph.org/flac/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@ -45,7 +45,7 @@ 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_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
check_function_exists(fseeko HAVE_FSEEKO)
@ -64,19 +64,6 @@ 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:${HAVE_FSEEKO}>:HAVE_FSEEKO>
$<$<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>
@ -93,6 +80,18 @@ endif()
include_directories("include")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_definitions(-DHAVE_CONFIG_H)
if(MSVC)
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
-D_USE_MATH_DEFINES)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
add_definitions(-DFLAC__OVERFLOW_DETECT)
endif()
add_subdirectory("doc")
add_subdirectory("src")
add_subdirectory("microbench")
@ -103,6 +102,8 @@ if(BUILD_TESTING)
add_subdirectory("test")
endif()
configure_file(config.cmake.h.in config.h)
install(
EXPORT targets
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake"

View File

@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 3.12)
include(CheckCSourceCompiles)
check_c_source_compiles("
@ -63,19 +61,14 @@ check_c_source_compiles("
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__>)
add_definitions(
-D_DARWIN_C_SOURCE
-D_POSIX_PTHREAD_SEMANTICS
-D__STDC_WANT_IEC_60559_ATTRIBS_EXT__
-D__STDC_WANT_IEC_60559_BFP_EXT__
-D__STDC_WANT_IEC_60559_DFP_EXT__
-D__STDC_WANT_IEC_60559_FUNCS_EXT__
-D__STDC_WANT_IEC_60559_TYPES_EXT__
-D__STDC_WANT_LIB_EXT2__
-D__STDC_WANT_MATH_SPEC_FUNCS__
-D_TANDEM_SOURCE)

239
config.cmake.h.in Normal file
View File

@ -0,0 +1,239 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#cmakedefine AC_APPLE_UNIVERSAL_BUILD
/* Target processor is big endian. */
#cmakedefine01 CPU_IS_BIG_ENDIAN
/* Target processor is little endian. */
#cmakedefine01 CPU_IS_LITTLE_ENDIAN
/* Set FLAC__BYTES_PER_WORD to 8 (4 is the default) */
#cmakedefine01 ENABLE_64_BIT_WORDS
/* define to align allocated memory on 32-byte boundaries */
#cmakedefine FLAC__ALIGN_MALLOC_DATA
/* define if you have docbook-to-man or docbook2man */
#cmakedefine FLAC__HAS_DOCBOOK_TO_MAN
/* define if you are compiling for x86 and have the NASM assembler */
#cmakedefine FLAC__HAS_NASM
/* define if you have the ogg library */
#cmakedefine01 OGG_FOUND
#define FLAC__HAS_OGG OGG_FOUND
/* define if compiler has __attribute__((target("cpu=power8"))) support */
#cmakedefine FLAC__HAS_TARGET_POWER8
/* define if compiler has __attribute__((target("cpu=power9"))) support */
#cmakedefine FLAC__HAS_TARGET_POWER9
/* Set to 1 if <x86intrin.h> is available. */
#cmakedefine01 FLAC__HAS_X86INTRIN
/* define if building for Darwin / MacOS X */
#cmakedefine FLAC__SYS_DARWIN
/* define if building for Linux */
#cmakedefine FLAC__SYS_LINUX
/* define to enable use of Altivec instructions */
#cmakedefine FLAC__USE_ALTIVEC
/* define to enable use of AVX instructions */
#cmakedefine01 WITH_AVX
#define FLAC__USE_AVX WITH_AVX
/* define to enable use of VSX instructions */
#cmakedefine FLAC__USE_VSX
/* Compiler has the __builtin_bswap16 intrinsic */
#cmakedefine01 HAVE_BSWAP16
/* Compiler has the __builtin_bswap32 intrinsic */
#cmakedefine01 HAVE_BSWAP32
/* Define to 1 if you have the <byteswap.h> header file. */
#cmakedefine HAVE_BYTESWAP_H
/* define if you have clock_gettime */
#cmakedefine HAVE_CLOCK_GETTIME
/* Define to 1 if you have the <cpuid.h> header file. */
#cmakedefine HAVE_CPUID_H
/* Define to 1 if C++ supports variable-length arrays. */
#cmakedefine HAVE_CXX_VARARRAYS
/* Define to 1 if C supports variable-length arrays. */
#cmakedefine HAVE_C_VARARRAYS
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#cmakedefine HAVE_FSEEKO
/* Define to 1 if you have the `getopt_long' function. */
#cmakedefine HAVE_GETOPT_LONG
/* Define if you have the iconv() function and it works. */
#cmakedefine HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine01 HAVE_INTTYPES_H
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#cmakedefine HAVE_LANGINFO_CODESET
/* lround support */
#cmakedefine01 HAVE_LROUND
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H
/* Define to 1 if the system has the type `socklen_t'. */
#cmakedefine HAVE_SOCKLEN_T
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine01 HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#cmakedefine HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/param.h> header file. */
#cmakedefine HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H
/* Define to 1 if typeof works with your compiler. */
#cmakedefine HAVE_TYPEOF
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H
/* Define to 1 if you have the <x86intrin.h> header file. */
#cmakedefine HAVE_X86INTRIN_H
/* Define as const if the declaration of iconv() needs const. */
#cmakedefine ICONV_CONST
/* Define if debugging is disabled */
#cmakedefine NDEBUG
/* Name of package */
#cmakedefine PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME
/* Define to the home page for this package. */
#cmakedefine PACKAGE_URL
/* Define to the version of this package. */
#define PACKAGE_VERSION "@PROJECT_VERSION@"
/* The size of `off_t', as computed by sizeof. */
#cmakedefine SIZEOF_OFF_T
/* The size of `void*', as computed by sizeof. */
#cmakedefine SIZEOF_VOIDP
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
#define _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef _FORTIFY_SOURCE
#cmakedefine DODEFINE_FORTIFY_SOURCE 2
#define _FORTIFY_SOURCE DODEFINE_FORTIFY_SOURCE
#endif
#ifndef _XOPEN_SOURCE
#cmakedefine DODEFINE_XOPEN_SOURCE 500
#define _XOPEN_SOURCE DODEFINE_XOPEN_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
#cmakedefine _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
#cmakedefine _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
#cmakedefine DODEFINE_EXTENSIONS
#define __EXTENSIONS__ DODEFINE_EXTENSIONS
#endif
/* Version number of package */
#cmakedefine VERSION
/* Target processor is big endian. */
#define WORDS_BIGENDIAN CPU_IS_BIG_ENDIAN
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#cmakedefine _FILE_OFFSET_BITS
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
#cmakedefine _LARGEFILE_SOURCE
/* Define for large files, on AIX-style hosts. */
#cmakedefine _LARGE_FILES
/* Define to 1 if on MINIX. */
#cmakedefine _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#cmakedefine _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#cmakedefine _POSIX_SOURCE
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#cmakedefine inline
#endif
/* Define to __typeof__ if your compiler spells it that way. */
#cmakedefine typeof

View File

@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.1)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)

View File

@ -5,9 +5,9 @@ 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>)
if(APPLE)
add_definitions(-DFLAC__SYS_DARWIN)
endif()
add_executable(benchmark_residual benchmark_residual.c util.c)
target_include_directories(benchmark_residual PRIVATE

View File

@ -1,16 +1,9 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.0)
option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8 (4 is the default)" OFF)
option(WITH_XMMS "Build XMMS plugin" OFF)
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>)
check_include_file("iconv.h" HAVE_ICONV)
add_subdirectory("libFLAC")
if(BUILD_CXXLIBS)

View File

@ -1,12 +1,6 @@
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

View File

@ -18,8 +18,6 @@ check_cxx_source_compiles("
#endif"
HAVE_CXX_VARARRAYS)
add_compile_definitions($<$<BOOL:${HAVE_CXX_VARARRAYS}>:HAVE_CXX_VARARRAYS>)
set(SOURCES
metadata.cpp
stream_decoder.cpp

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.0)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86(_64)?|(AMD|amd)64|i[346]86")
option(WITH_AVX "Enable AVX, AVX2 optimizations" ON)
@ -12,36 +12,25 @@ 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)
add_definitions(-DFLAC__CPU_X86_64 -DFLAC__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)
add_definitions(-DFLAC__CPU_IA32 -DFLAC__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)
add_definitions(-DFLAC__HAS_NASM)
endif()
if(NOT WITH_ASM)
add_compile_definitions(FLAC__NO_ASM)
add_definitions(-DFLAC__NO_ASM)
endif()
if(IA32)
@ -106,10 +95,13 @@ 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:win_utf8_io>
$<TARGET_NAME_IF_EXISTS:FLAC-asm>
$<$<BOOL:${HAVE_LROUND}>:m>)
target_link_libraries(FLAC-static PUBLIC $<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET FLAC-asm)
target_link_libraries(FLAC-static PUBLIC FLAC-asm>)
endif()
if(TARGET win_utf8_io)
target_link_libraries(FLAC-static PUBLIC win_utf8_io>)
endif()
if(TARGET Ogg::Ogg-static)
target_link_libraries(FLAC-static PUBLIC Ogg::Ogg-static)
elseif(TARGET Ogg::Ogg)
@ -121,11 +113,16 @@ target_compile_definitions(FLAC PRIVATE FLAC_API_EXPORTS FLAC__USE_VISIBILITY_AT
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>
$<TARGET_NAME_IF_EXISTS:win_utf8_io>
$<$<BOOL:${HAVE_LROUND}>:m>)
target_link_libraries(FLAC PRIVATE $<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET FLAC-asm)
target_link_libraries(FLAC PUBLIC FLAC-asm>)
endif()
if(TARGET win_utf8_io)
target_link_libraries(FLAC PUBLIC win_utf8_io>)
endif()
if(TARGET Ogg::Ogg)
target_link_libraries(FLAC PUBLIC Ogg::Ogg)
endif()
set_target_properties(FLAC PROPERTIES
C_VISIBILITY_PRESET hidden
VERSION 8.3.0

View File

@ -1,12 +1,4 @@
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(getopt STATIC getopt.c getopt1.c)