Commit ce6dd6b5 authored by evpobr's avatar evpobr Committed by Erik de Castro Lopo
Browse files

CMake polishing

* Improve CPU features detection

  CMAKE_SYSTEM_PROCESSOR is pretty useless (e.g. when compiling with
  MSVC ARM64 toolchain and Ninja still returns system processor).

* Don't build src/utils targets by default

  Fix compilation for UWP platform.

* Add more Visual studio Git ignore patterns
* Autogenerate Doxygen docs
parent 37e675b7
......@@ -79,6 +79,8 @@ oss-fuzz/fuzz-decoder
oss-fuzz/fuzz-encoder
/*[Bb]uild*/
/out/
CMakeSettings.json
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
......
......@@ -43,6 +43,8 @@ EXTRA_DIST = \
flac-config.cmake.in \
cmake/FindOgg.cmake \
cmake/UseSystemExtensions.cmake \
cmake/CheckCPUArch.cmake \
cmake/CheckCPUArch.c.in \
COPYING.FDL \
COPYING.GPL \
COPYING.LGPL \
......
int main(void) {
#if @CHECK_CPU_ARCH_DEFINES@
return 0;
#else
fail
#endif
}
macro(_CHECK_CPU_ARCH ARCH ARCH_DEFINES VARIABLE)
if(NOT DEFINED HAVE_${VARIABLE})
message(STATUS "Check CPU architecture is ${ARCH}")
set(CHECK_CPU_ARCH_DEFINES ${ARCH_DEFINES})
configure_file(${PROJECT_SOURCE_DIR}/cmake/CheckCPUArch.c.in ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c @ONLY)
try_compile(HAVE_${VARIABLE} "${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c")
if(HAVE_${VARIABLE})
message(STATUS "Check CPU architecture is ${ARCH} - yes")
set(${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_CPU_ARCH_X64" FORCE)
else ()
message(STATUS "Check CPU architecture is ${ARCH} - no")
endif()
endif ()
endmacro(_CHECK_CPU_ARCH)
macro(CHECK_CPU_ARCH_X64 VARIABLE)
_CHECK_CPU_ARCH(x64 "defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" ${VARIABLE})
endmacro(CHECK_CPU_ARCH_X64)
macro(CHECK_CPU_ARCH_X86 VARIABLE)
_CHECK_CPU_ARCH(x86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" ${VARIABLE})
endmacro(CHECK_CPU_ARCH_X86)
......@@ -15,12 +15,20 @@ 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++")
if(CMAKE_VERSION VERSION_LESS 3.12)
doxygen_add_docs(FLAC-doxygen
ALL
"${PROJECT_SOURCE_DIR}/include/FLAC"
"${PROJECT_SOURCE_DIR}/include/FLAC++")
else()
doxygen_add_docs(FLAC-doxygen
"${PROJECT_SOURCE_DIR}/include/FLAC"
"${PROJECT_SOURCE_DIR}/include/FLAC++")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/api")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html/api")
endif()
install(FILES
html/images/logo.svg
......
......@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.11)
option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8 (4 is the default)" OFF)
option(WITH_XMMS "Build XMMS plugin" OFF)
option(BUILD_UTILS "Build utils" OFF)
add_subdirectory("libFLAC")
if(BUILD_CXXLIBS)
......@@ -17,7 +18,7 @@ if(BUILD_PROGRAMS)
add_subdirectory("flac")
add_subdirectory("metaflac")
endif()
if(BUILD_CXXLIBS)
if(BUILD_UTILS)
add_subdirectory(utils/flacdiff)
if(WIN32)
add_subdirectory(utils/flactimer)
......
if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86(_64)?|(AMD|amd)64|i[346]86")
option(WITH_AVX "Enable AVX, AVX2 optimizations" ON)
endif()
option(WITH_ASM "Use any assembly optimization routines" ON)
check_include_file("cpuid.h" HAVE_CPUID_H)
......@@ -10,14 +6,17 @@ check_include_file("sys/param.h" HAVE_SYS_PARAM_H)
set(CMAKE_REQUIRED_LIBRARIES m)
check_function_exists(lround HAVE_LROUND)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86_64|(AMD|amd)64")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(IA32 TRUE)
endif()
add_definitions(-DFLAC__CPU_X86_64 -DFLAC__ALIGN_MALLOC_DATA)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "([xX]|i[346])86")
set(IA32 TRUE)
add_definitions(-DFLAC__CPU_IA32 -DFLAC__ALIGN_MALLOC_DATA)
include(CheckCSourceCompiles)
include(CheckCPUArch)
check_cpu_arch_x64(FLAC__CPU_X86_64)
if(NOT FLAC__CPU_X86_64)
check_cpu_arch_x86(FLAC__CPU_IA32)
endif()
if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
set(FLAC__ALIGN_MALLOC_DATA 1)
option(WITH_AVX "Enable AVX, AVX2 optimizations" ON)
endif()
include(CheckLanguage)
......@@ -31,7 +30,7 @@ if(NOT WITH_ASM)
add_definitions(-DFLAC__NO_ASM)
endif()
if(IA32)
if(FLAC__CPU_IA32)
if(WITH_ASM AND CMAKE_ASM_NASM_COMPILER)
add_subdirectory(ia32)
endif()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment