base: Format CMakeLists.txt (again)

This commit is contained in:
tt2468 2022-07-28 11:46:32 -07:00
parent e52d5402cf
commit 268a45e8dd

View File

@ -17,16 +17,17 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON) # For resources.qrc set(CMAKE_AUTORCC ON) # For resources.qrc
# Find Qt # Find Qt
if (NOT COMMAND find_qt) if(NOT COMMAND find_qt)
if(NOT QT_VERSION) if(NOT QT_VERSION)
set(QT_VERSION set(QT_VERSION
AUTO AUTO
CACHE STRING "obs-websocket Qt version [AUTO, 5, 6]" FORCE) CACHE STRING "obs-websocket Qt version [AUTO, 5, 6]" FORCE)
set_property(CACHE QT_VERSION PROPERTY STRINGS AUTO 5 6) set_property(CACHE QT_VERSION PROPERTY STRINGS AUTO 5 6)
endif() endif()
macro(find_qt) macro(find_qt)
set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC COMPONENTS_LINUX) set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC
COMPONENTS_LINUX)
cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}" cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}"
${ARGN}) ${ARGN})
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON) set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
@ -38,7 +39,7 @@ if (NOT COMMAND find_qt)
Qt6 Qt6
COMPONENTS Core COMPONENTS Core
QUIET) QUIET)
if(NOT _QT_VERSION AND QT_VERSION STREQUAL AUTO) if(NOT _QT_VERSION AND QT_VERSION STREQUAL AUTO)
if(TARGET Qt5::Core) if(TARGET Qt5::Core)
set(_QT_VERSION set(_QT_VERSION
@ -64,7 +65,7 @@ if (NOT COMMAND find_qt)
WARNING WARNING
"Qt${QT_VERSION} was not found, falling back to Qt${FALLBACK_QT_VERSION}" "Qt${QT_VERSION} was not found, falling back to Qt${FALLBACK_QT_VERSION}"
) )
if(TARGET Qt${FALLBACK_QT_VERSION}::Core) if(TARGET Qt${FALLBACK_QT_VERSION}::Core)
set(_QT_VERSION set(_QT_VERSION
${FALLBACK_QT_VERSION} ${FALLBACK_QT_VERSION}
@ -72,13 +73,13 @@ if (NOT COMMAND find_qt)
endif() endif()
endif() endif()
endif() endif()
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF) set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
if(NOT _QT_VERSION) if(NOT _QT_VERSION)
message(FATAL_ERROR "Neither Qt5 or Qt6 were found") message(FATAL_ERROR "Neither Qt5 or Qt6 were found")
endif() endif()
if(OS_WINDOWS) if(OS_WINDOWS)
find_package( find_package(
Qt${_QT_VERSION} Qt${_QT_VERSION}
@ -95,17 +96,18 @@ if (NOT COMMAND find_qt)
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_LINUX} COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_LINUX}
REQUIRED) REQUIRED)
endif() endif()
list(APPEND FIND_QT_COMPONENTS "Core") list(APPEND FIND_QT_COMPONENTS "Core")
if("Gui" IN_LIST FIND_QT_COMPONENTS_LINUX) if("Gui" IN_LIST FIND_QT_COMPONENTS_LINUX)
list(APPEND FIND_QT_COMPONENTS_LINUX "GuiPrivate") list(APPEND FIND_QT_COMPONENTS_LINUX "GuiPrivate")
endif() endif()
foreach(_COMPONENT IN LISTS FIND_QT_COMPONENTS FIND_QT_COMPONENTS_WIN foreach(_COMPONENT IN LISTS FIND_QT_COMPONENTS FIND_QT_COMPONENTS_WIN
FIND_QT_COMPONENTS_MAC FIND_QT_COMPONENTS_LINUX) FIND_QT_COMPONENTS_MAC FIND_QT_COMPONENTS_LINUX)
if(NOT TARGET Qt::${_COMPONENT} AND TARGET Qt${_QT_VERSION}::${_COMPONENT}) if(NOT TARGET Qt::${_COMPONENT} AND TARGET
Qt${_QT_VERSION}::${_COMPONENT})
add_library(Qt::${_COMPONENT} INTERFACE IMPORTED) add_library(Qt::${_COMPONENT} INTERFACE IMPORTED)
set_target_properties( set_target_properties(
Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES
@ -244,9 +246,9 @@ if(WIN32)
add_definitions(-D_WEBSOCKETPP_CPP11_STL_) add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
target_compile_options(obs-websocket PRIVATE /wd4267) target_compile_options(obs-websocket PRIVATE /wd4267)
# Set the correct Windows preprocessor var for asio # Set the correct Windows preprocessor var for asio
macro(get_WIN32_WINNT version) macro(get_WIN32_WINNT version)
if (WIN32 AND CMAKE_SYSTEM_VERSION) if(WIN32 AND CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION}) set(ver ${CMAKE_SYSTEM_VERSION})
string(REPLACE "." "" ver ${ver}) string(REPLACE "." "" ver ${ver})
string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver}) string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
@ -255,7 +257,7 @@ if(WIN32)
endif() endif()
endmacro() endmacro()
get_WIN32_WINNT(ver) get_win32_winnt(ver)
add_definitions(-D_WIN32_WINNT=${ver}) add_definitions(-D_WIN32_WINNT=${ver})
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
target_compile_options( target_compile_options(
@ -263,7 +265,8 @@ elseif(UNIX AND NOT APPLE)
-Wno-variadic-macros -Wno-error=format-overflow) -Wno-variadic-macros -Wno-error=format-overflow)
elseif(APPLE) elseif(APPLE)
target_compile_options( target_compile_options(
obs-websocket PRIVATE -Wno-error=null-pointer-subtraction -Wno-error=deprecated-declarations) obs-websocket PRIVATE -Wno-error=null-pointer-subtraction
-Wno-error=deprecated-declarations)
endif() endif()
# Final CMake helpers # Final CMake helpers