Reformat code

This commit is contained in:
badaix 2023-12-30 11:37:50 +01:00
parent 6e786255e1
commit 6441ca0a99
4 changed files with 176 additions and 172 deletions

View file

@ -1,11 +1,10 @@
# ============================================================================== # ==============================================================================
# LLVM Release License # LLVM Release License
# ============================================================================== # ==============================================================================
# University of Illinois/NCSA # University of Illinois/NCSA Open Source License
# Open Source License
# #
# Copyright (c) 2003-2018 University of Illinois at Urbana-Champaign. # Copyright (c) 2003-2018 University of Illinois at Urbana-Champaign. All rights
# All rights reserved. # reserved.
# #
# Developed by: # Developed by:
# #
@ -15,58 +14,59 @@
# #
# http://llvm.org # http://llvm.org
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy of # Permission is hereby granted, free of charge, to any person obtaining a copy
# this software and associated documentation files (the "Software"), to deal with # of this software and associated documentation files (the "Software"), to deal
# the Software without restriction, including without limitation the rights to # with the Software without restriction, including without limitation the rights
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# of the Software, and to permit persons to whom the Software is furnished to do # copies of the Software, and to permit persons to whom the Software is
# so, subject to the following conditions: # furnished to do so, subject to the following conditions:
# #
# * Redistributions of source code must retain the above copyright notice, # * Redistributions of source code must retain the above copyright notice, this
# this list of conditions and the following disclaimers. # list of conditions and the following disclaimers.
# #
# * Redistributions in binary form must reproduce the above copyright notice, # * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimers in the # this list of conditions and the following disclaimers in the documentation
# documentation and/or other materials provided with the distribution. # and/or other materials provided with the distribution.
# #
# * Neither the names of the LLVM Team, University of Illinois at # * Neither the names of the LLVM Team, University of Illinois at
# Urbana-Champaign, nor the names of its contributors may be used to # Urbana-Champaign, nor the names of its contributors may be used to endorse
# endorse or promote products derived from this Software without specific # or promote products derived from this Software without specific prior
# prior written permission. # written permission.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
# SOFTWARE. # THE SOFTWARE.
INCLUDE(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
INCLUDE(CheckLibraryExists) include(CheckLibraryExists)
# Sometimes linking against libatomic is required for atomic ops, if
# the platform doesn't support lock-free atomics.
# Sometimes linking against libatomic is required for atomic ops, if the
# platform doesn't support lock-free atomics.
function(check_working_cxx_atomics varname) function(check_working_cxx_atomics varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
CHECK_CXX_SOURCE_COMPILES(" check_cxx_source_compiles(
"
#include <atomic> #include <atomic>
std::atomic<long long> x; std::atomic<long long> x;
int main() { int main() {
return std::atomic_is_lock_free(&x); return std::atomic_is_lock_free(&x);
} }
" ${varname}) "
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics) endfunction(check_working_cxx_atomics)
function(check_working_cxx_atomics64 varname) function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-std=c++11 ${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "-std=c++11 ${CMAKE_REQUIRED_FLAGS}")
CHECK_CXX_SOURCE_COMPILES(" check_cxx_source_compiles(
"
#include <atomic> #include <atomic>
#include <cstdint> #include <cstdint>
std::atomic<uint64_t> x (0); std::atomic<uint64_t> x (0);
@ -74,37 +74,39 @@ int main() {
uint64_t i = x.load(std::memory_order_relaxed); uint64_t i = x.load(std::memory_order_relaxed);
return std::atomic_is_lock_free(&x); return std::atomic_is_lock_free(&x);
} }
" ${varname}) "
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics64) endfunction(check_working_cxx_atomics64)
function(check_working_cxx_atomics_2args varname) function(check_working_cxx_atomics_2args varname)
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
CHECK_CXX_SOURCE_COMPILES(" check_cxx_source_compiles(
"
int main() { int main() {
__atomic_load(nullptr, 0); __atomic_load(nullptr, 0);
return 0; return 0;
} }
" ${varname}) "
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) ${varname})
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endfunction(check_working_cxx_atomics_2args) endfunction(check_working_cxx_atomics_2args)
function(check_working_cxx_atomics64_2args varname) function(check_working_cxx_atomics64_2args varname)
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
CHECK_CXX_SOURCE_COMPILES(" check_cxx_source_compiles(
"
int main() { int main() {
__atomic_load_8(nullptr, 0); __atomic_load_8(nullptr, 0);
return 0; return 0;
} }
" ${varname}) "
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) ${varname})
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endfunction(check_working_cxx_atomics64_2args) endfunction(check_working_cxx_atomics64_2args)
# First check if atomics work without the library. # First check if atomics work without the library.
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB) check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
@ -113,14 +115,14 @@ set(ATOMIC_LIBRARY "")
# If not, check if the library exists, and atomics work with it. # If not, check if the library exists, and atomics work with it.
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC) check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
if( NOT HAVE_LIBATOMIC ) if(NOT HAVE_LIBATOMIC)
check_working_cxx_atomics_2args(HAVE_LIBATOMIC_2ARGS) check_working_cxx_atomics_2args(HAVE_LIBATOMIC_2ARGS)
endif() endif()
if( HAVE_LIBATOMIC OR HAVE_LIBATOMIC_2ARGS ) if(HAVE_LIBATOMIC OR HAVE_LIBATOMIC_2ARGS)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
set(ATOMIC_LIBRARY "atomic") set(ATOMIC_LIBRARY "atomic")
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB) check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
if (NOT HAVE_CXX_ATOMICS_WITH_LIB) if(NOT HAVE_CXX_ATOMICS_WITH_LIB)
message(FATAL_ERROR "Host compiler must support std::atomic!") message(FATAL_ERROR "Host compiler must support std::atomic!")
endif() endif()
else() else()
@ -132,24 +134,24 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
endif() endif()
# If not, check if the library exists, and atomics work with it. # If not, check if the library exists, and atomics work with it.
if( NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB ) if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64) check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
if( NOT HAVE_CXX_LIBATOMICS64 ) if(NOT HAVE_CXX_LIBATOMICS64)
check_working_cxx_atomics64_2args(HAVE_CXX_LIBATOMICS64_2ARGS) check_working_cxx_atomics64_2args(HAVE_CXX_LIBATOMICS64_2ARGS)
endif() endif()
if( HAVE_CXX_LIBATOMICS64 OR HAVE_CXX_LIBATOMICS64_2ARGS ) if(HAVE_CXX_LIBATOMICS64 OR HAVE_CXX_LIBATOMICS64_2ARGS)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
set(ATOMIC_LIBRARY "atomic") set(ATOMIC_LIBRARY "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB) check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (NOT HAVE_CXX_ATOMICS64_WITH_LIB) if(NOT HAVE_CXX_ATOMICS64_WITH_LIB)
message(FATAL_ERROR "Host compiler must support std::atomic!") message(FATAL_ERROR "Host compiler must support std::atomic!")
endif() endif()
else() else()
message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.") message(
FATAL_ERROR
"Host compiler appears to require libatomic, but cannot find it.")
endif() endif()
endif() endif()
endif() endif()
endif() endif()

View file

@ -1,18 +1,17 @@
# This file is part of snapcast # This file is part of snapcast Copyright (C) 2014-2020 Johannes Pohl
# Copyright (C) 2014-2020 Johannes Pohl
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify it under
# it under the terms of the GNU General Public License as published by # the terms of the GNU General Public License as published by the Free Software
# the Free Software Foundation, either version 3 of the License, or # Foundation, either version 3 of the License, or (at your option) any later
# (at your option) any later version. # version.
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful, but WITHOUT
# but WITHOUT ANY WARRANTY; without even the implied warranty of # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# GNU General Public License for more details. # details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License along with
# along with this program. If not, see <http://www.gnu.org/licenses/>. # this program. If not, see <http://www.gnu.org/licenses/>.
#[=======================================================================[.rst: #[=======================================================================[.rst:
CheckCXX11StringSupport CheckCXX11StringSupport
@ -33,12 +32,12 @@ See also: https://stackoverflow.com/questions/17950814/how-to-use-stdstoul-and-s
failure. failure.
#]=======================================================================] #]=======================================================================]
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
macro (CHECK_CXX11_STRING_SUPPORT _RESULT) macro(CHECK_CXX11_STRING_SUPPORT _RESULT)
set(CMAKE_REQUIRED_DEFINITIONS -std=c++0x) set(CMAKE_REQUIRED_DEFINITIONS -std=c++0x)
set(_CHECK_CXX11_STRING_SUPPORT_SOURCE_CODE " set(_CHECK_CXX11_STRING_SUPPORT_SOURCE_CODE
"
#include <string> #include <string>
int main() int main()
{ {
@ -50,5 +49,6 @@ int main()
} }
") ")
CHECK_CXX_SOURCE_COMPILES("${_CHECK_CXX11_STRING_SUPPORT_SOURCE_CODE}" ${_RESULT}) check_cxx_source_compiles("${_CHECK_CXX11_STRING_SUPPORT_SOURCE_CODE}"
endmacro () ${_RESULT})
endmacro()

View file

@ -1,21 +1,22 @@
######## #
# Find systemd service dir # Find systemd service dir
pkg_check_modules(SYSTEMD "systemd") pkg_check_modules(SYSTEMD "systemd")
if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "") if(SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "")
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} execute_process(
--variable=systemdsystemunitdir systemd COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemdsystemunitdir systemd
OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR) OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR
"${SYSTEMD_SERVICES_INSTALL_DIR}") "${SYSTEMD_SERVICES_INSTALL_DIR}")
elseif (NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR) elseif(NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR)
message (FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\ message(FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\
defined, but we can't find systemd using pkg-config") defined, but we can't find systemd using pkg-config")
endif() endif()
if (SYSTEMD_FOUND) if(SYSTEMD_FOUND)
set(WITH_SYSTEMD "ON") set(WITH_SYSTEMD "ON")
message(STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}") message(
STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}")
else() else()
set(WITH_SYSTEMD "OFF") set(WITH_SYSTEMD "OFF")
endif (SYSTEMD_FOUND) endif(SYSTEMD_FOUND)

View file

@ -2,10 +2,11 @@
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h # https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) # Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
# Regarding POWER/PowerPC, just as is noted in the Qt source, # Regarding POWER/PowerPC, just as is noted in the Qt source, "There are many
# "There are many more known variants/revisions that we do not handle/detect." # more known variants/revisions that we do not handle/detect."
set(archdetect_c_code " set(archdetect_c_code
"
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) #if defined(__arm__) || defined(__TARGET_ARCH_ARM)
#if defined(__ARM_ARCH_7__) \\ #if defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\ || defined(__ARM_ARCH_7A__) \\
@ -47,22 +48,22 @@ set(archdetect_c_code "
#error cmake_ARCH unknown #error cmake_ARCH unknown
") ")
# Set ppc_support to TRUE before including this file or ppc and ppc64 # Set ppc_support to TRUE before including this file or ppc and ppc64 will be
# will be treated as invalid architectures since they are no longer supported by Apple # treated as invalid architectures since they are no longer supported by Apple
function(target_architecture output_var) function(target_architecture output_var)
if(APPLE AND CMAKE_OSX_ARCHITECTURES) if(APPLE AND CMAKE_OSX_ARCHITECTURES)
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set First let's
# First let's normalize the order of the values # normalize the order of the values
# Note that it's not possible to compile PowerPC applications if you are using # Note that it's not possible to compile PowerPC applications if you are
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we # using the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that,
# disable it by default # so we disable it by default See this page for more information:
# See this page for more information:
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. # on the CPU type detected at runtime. On OS X 10.6+ the default is x86_64
# if the CPU supports it, i386 otherwise.
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if("${osx_arch}" STREQUAL "ppc" AND ppc_support) if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
@ -99,22 +100,20 @@ function(target_architecture output_var)
enable_language(C) enable_language(C)
# Detect the architecture in a rather creative way... # Detect the architecture in a rather creative way... This compiles a small
# This compiles a small C program which is a series of ifdefs that selects a # C program which is a series of ifdefs that selects a particular #error
# particular #error preprocessor directive whose message string contains the # preprocessor directive whose message string contains the target
# target architecture. The program will always fail to compile (both because # architecture. The program will always fail to compile (both because file
# file is not a valid C program, and obviously because of the presence of the # is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in this # #error preprocessor directives... but by exploiting the preprocessor in
# way, we can detect the correct target architecture even when cross-compiling, # this way, we can detect the correct target architecture even when
# since the program itself never needs to be run (only the compiler/preprocessor) # cross-compiling, since the program itself never needs to be run (only the
# compiler/preprocessor)
try_run( try_run(
run_result_unused run_result_unused compile_result_unused "${CMAKE_BINARY_DIR}"
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/arch.c" "${CMAKE_BINARY_DIR}/arch.c"
COMPILE_OUTPUT_VARIABLE ARCH COMPILE_OUTPUT_VARIABLE ARCH
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES})
)
# Parse the architecture name from the compiler output # Parse the architecture name from the compiler output
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
@ -123,12 +122,14 @@ function(target_architecture output_var)
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# If we are compiling with an unknown architecture this variable should # If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due # already be set to "unknown" but in the case that it's empty (i.e. due to a
# to a typo in the code), then set it to unknown # typo in the code), then set it to unknown
if (NOT ARCH) if(NOT ARCH)
set(ARCH unknown) set(ARCH unknown)
endif() endif()
endif() endif()
set(${output_var} "${ARCH}" PARENT_SCOPE) set(${output_var}
"${ARCH}"
PARENT_SCOPE)
endfunction() endfunction()