1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
|
include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckLibraryExists)
include (CheckSymbolExists)
include (CheckTypeSize)
include (TestBigEndian)
include (TestInline)
include (ClipMode)
include (TestLargeFiles)
include (CheckCPUArch)
test_large_files (_LARGEFILES)
if (LARGE_FILES_DEFINITIONS)
add_definitions(${LARGE_FILES_DEFINITIONS})
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
find_package (Sndio)
elseif (NOT WIN32)
find_package (ALSA)
endif ()
if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15))
set (CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
endif ()
if (CMAKE_FIND_PACKAGE_PREFER_CONFIG)
find_package (Ogg 1.3 CONFIG)
find_package (Vorbis CONFIG COMPONENTS Enc)
find_package (FLAC CONFIG)
find_package (Opus CONFIG)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Ogg CONFIG_MODE)
find_package_handle_standard_args (Vorbis CONFIG_MODE)
find_package_handle_standard_args (FLAC CONFIG_MODE)
find_package_handle_standard_args (Opus CONFIG_MODE)
else ()
find_package (Ogg 1.3)
find_package (Vorbis COMPONENTS Enc)
find_package (FLAC)
find_package (Opus)
endif ()
if (Vorbis_FOUND AND FLAC_FOUND AND Opus_FOUND)
set (HAVE_EXTERNAL_XIPH_LIBS 1)
else ()
set (HAVE_EXTERNAL_XIPH_LIBS 0)
endif ()
find_package (mp3lame)
find_package (mpg123 1.25.10)
if (TARGET mp3lame::mp3lame AND (TARGET MPG123::libmpg123))
set (HAVE_MPEG_LIBS 1)
else ()
set (HAVE_MPEG_LIBS 0)
endif()
find_package (Speex)
find_package (SQLite3)
check_include_file (byteswap.h HAVE_BYTESWAP_H)
check_include_file (dlfcn.h HAVE_DLFCN_H)
check_include_file (direct.h HAVE_DIRECT_H)
check_include_file (endian.h HAVE_ENDIAN_H)
check_include_file (inttypes.h HAVE_INTTYPES_H)
check_include_file (io.h HAVE_IO_H)
check_include_file (stdint.h HAVE_STDINT_H)
check_include_file (sys/time.h HAVE_SYS_TIME_H)
check_include_file (sys/types.h HAVE_SYS_TYPES_H)
check_include_file (unistd.h HAVE_UNISTD_H)
check_include_file (immintrin.h HAVE_IMMINTRIN_H)
check_include_file (stdbool.h HAVE_STDBOOL_H)
check_cpu_arch_x86 (CPU_IS_X86)
check_cpu_arch_x64 (CPU_IS_X64)
if ((CPU_IS_X86 OR CPU_IS_X64) AND HAVE_IMMINTRIN_H)
set (HAVE_SSE2 1)
endif ()
# Never checked
# check_include_file (stdlib.h HAVE_STDLIB_H)
# check_include_file (string.h HAVE_STRING_H)
# check_include_file (strings.h HAVE_STRINGS_H)
# check_include_file (sys/stat.h HAVE_SYS_STAT_H)
# check_include_file (memory.h HAVE_MEMORY_H)
if (BUILD_TESTING)
check_include_file (locale.h HAVE_LOCALE_H)
check_include_file (sys/wait.h HAVE_SYS_WAIT_H)
endif ()
check_type_size (int64_t SIZEOF_INT64_T)
check_type_size (long SIZEOF_LONG)
check_type_size (long\ long SIZEOF_LONG_LONG)
check_type_size (ssize_t SIZEOF_SSIZE_T)
check_type_size (wchar_t SIZEOF_WCHAR_T)
# Never used
# check_type_size (loff_t SIZEOF_LOFF_T)
# check_type_size (offt64_t SIZEOF_OFF64_T)
# Never checked
# check_type_size (size_t SIZEOF_SIZE_T)
# Used in configre.ac
# check_type_size (double SIZEOF_DOUBLE)
# check_type_size (float SIZEOF_FLOAT)
# check_type_size (int SIZEOF_INT)
# check_type_size (short SIZEOF_SHORT)
if (ENABLE_TESTING)
check_type_size (void* SIZEOF_VOIDP)
endif()
if (NOT WIN32)
check_library_exists (m floor "" LIBM_REQUIRED)
if (LIBM_REQUIRED)
list (APPEND CMAKE_REQUIRED_LIBRARIES m)
endif ()
endif ()
check_library_exists (sqlite3 sqlite3_close "" HAVE_SQLITE3)
check_function_exists (fstat HAVE_FSTAT)
check_function_exists (fstat64 HAVE_FSTAT64)
check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists (gmtime HAVE_GMTIME)
check_function_exists (gmtime_r HAVE_GMTIME_R)
check_function_exists (localtime HAVE_LOCALTIME)
check_function_exists (localtime_r HAVE_LOCALTIME_R)
check_function_exists (lseek HAVE_LSEEK)
check_function_exists (open HAVE_OPEN)
check_function_exists (read HAVE_READ)
check_function_exists (write HAVE_WRITE)
check_function_exists (lrint HAVE_LRINT)
check_function_exists (lrintf HAVE_LRINTF)
if (NOT WIN32)
check_function_exists (ftruncate HAVE_FTRUNCATE)
check_function_exists (fsync HAVE_FSYNC)
endif ()
if (BUILD_TESTING)
check_function_exists (pipe HAVE_PIPE)
check_function_exists (setlocale HAVE_SETLOCALE)
check_function_exists (waitpid HAVE_WAITPID)
endif ()
# Never checked
# check_function_exists (calloc HAVE_CALLOC)
# check_function_exists (free HAVE_FREE)
# check_function_exists (getpagesize HAVE_GETPAGESIZE)
# check_function_exists (malloc HAVE_MALLOC)
# check_function_exists (realloc HAVE_REALLOC)
# check_function_exists (snprintf HAVE_SNPRINTF)
# check_function_exists (vsnprintf HAVE_VSNPRINTF)
# check_function_exists (floor HAVE_FLOOR)
# check_function_exists (fmod HAVE_FMOD)
# Never used
# check_function_exists (mmap HAVE_MMAP)
# check_function_exists (ceil HAVE_CEIL)
# check_function_exists (lround HAVE_LROUND)
# check_function_exists (lseek64 HAVE_LSEEK64)
check_symbol_exists (S_IRGRP sys/stat.h HAVE_DECL_S_IRGRP)
test_big_endian (WORDS_BIGENDIAN)
if (WORDS_BIGENDIAN)
set (CPU_IS_BIG_ENDIAN 1)
else ()
set (CPU_IS_LITTLE_ENDIAN 1)
endif ()
if (WIN32)
set (OS_IS_WIN32 1)
set (USE_WINDOWS_API 1)
if (BUILD_SHARED_LIBS)
set (WIN32_TARGET_DLL 1)
endif ()
if (MINGW)
add_definitions (-D__USE_MINGW_ANSI_STDIO=1)
endif ()
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
set (OS_IS_OPENBSD 1)
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set (COMPILER_IS_GCC 1)
endif ()
test_inline ()
clip_mode ()
if (MSVC)
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif (MSVC)
if (DEFINED ENABLE_STATIC_RUNTIME)
if (MSVC)
if (ENABLE_STATIC_RUNTIME)
foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
)
if (${flag_var} MATCHES "/MD")
string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif ()
endforeach (flag_var)
else ()
foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
)
if (${flag_var} MATCHES "/MT")
string (REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
endif (${flag_var} MATCHES "/MT")
endforeach (flag_var)
endif ( )
elseif (MINGW)
if (ENABLE_STATIC_RUNTIME)
if (CMAKE_C_COMPILER_ID STREQUAL GNU)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s")
endif ()
if (CMAKE_C_COMPILER_ID STREQUAL Clang)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static")
endif ()
endif ()
else ()
message (AUTHOR_WARNING "ENABLE_STATIC_RUNTIME option is for MSVC or MinGW only.")
endif ()
endif ()
if (BUILD_SHARED_LIBS)
find_package (PythonInterp REQUIRED)
endif()
|