cmake: Disable warnings for most externals on MSVC, like we do in the VS project files.

This commit is contained in:
Admiral H. Curtiss 2022-05-21 15:09:05 +02:00
parent a5e85627b0
commit 6ea7af13e8
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
30 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,18 @@
include(RemoveCompileFlag)
macro(dolphin_disable_warnings_msvc _target)
if (MSVC)
get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
if (_target_cxx_flags)
set(new_flags "")
foreach(flag IN LISTS _target_cxx_flags)
# all warning flags start with "/W" or "/w" or "-W" or "-w"
if (NOT "${flag}" MATCHES "^[-/][Ww]")
list(APPEND new_flags "${flag}")
endif()
endforeach()
set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${new_flags}")
endif()
target_compile_options(${_target} PRIVATE "/W0")
endif()
endmacro()

View File

@ -128,6 +128,7 @@ include(CheckAndAddFlag)
include(CheckCCompilerFlag)
include(CheckVendoringApproved)
include(DolphinCompileDefinitions)
include(DolphinDisableWarningsMSVC)
include(RemoveCompileFlag)
# Enable folders for IDE

View File

@ -4,6 +4,7 @@ add_library(bdisasm STATIC
resolve.cc
syntax.cc
)
dolphin_disable_warnings_msvc(bdisasm)
if (WIN32)
target_sources(bdisasm

View File

@ -12,5 +12,6 @@ set(SRCS
)
add_library(FreeSurround STATIC ${SRCS})
dolphin_disable_warnings_msvc(FreeSurround)
target_include_directories(FreeSurround PUBLIC include)
target_compile_options(FreeSurround PRIVATE -w)

View File

@ -1,6 +1,7 @@
add_library(lzo2 STATIC
minilzo.c
)
dolphin_disable_warnings_msvc(lzo2)
target_include_directories(lzo2
PUBLIC

View File

@ -25,3 +25,5 @@ set(SRC_SYSTEM
add_library(sfml-network ${SRC_NETWORK})
add_library(sfml-system ${SRC_SYSTEM})
dolphin_disable_warnings_msvc(sfml-network)
dolphin_disable_warnings_msvc(sfml-system)

View File

@ -70,6 +70,7 @@ set(BZIP2_SRCS
add_library(bzip2 STATIC ${BZIP2_SRCS} ${BZIP2_PUBLIC_HDRS} ${BZIP2_PRIVATE_HDRS})
add_library(BZip2::BZip2 ALIAS bzip2)
dolphin_disable_warnings_msvc(bzip2)
target_include_directories(bzip2
PUBLIC

View File

@ -3,4 +3,5 @@ check_and_add_flag(CXX11 -std=c++11)
set(SRCS OptionParser.cpp OptionParser.h)
add_library(cpp-optparse STATIC ${SRCS})
dolphin_disable_warnings_msvc(cpp-optparse)
target_include_directories(cpp-optparse PUBLIC .)

View File

@ -48,6 +48,7 @@ add_library(cubeb
src/cubeb_log.cpp
src/cubeb_strings.c
$<TARGET_OBJECTS:speex>)
dolphin_disable_warnings_msvc(cubeb)
target_include_directories(cubeb
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
)
@ -100,6 +101,7 @@ install(
add_library(speex OBJECT
src/speex/resample.c)
dolphin_disable_warnings_msvc(speex)
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
target_compile_definitions(speex PRIVATE OUTSIDE_SPEEX)
target_compile_definitions(speex PRIVATE FLOATING_POINT)

View File

@ -12,6 +12,7 @@ add_library(
STATIC
${SRCS}
)
dolphin_disable_warnings_msvc(curl)
target_link_libraries(curl ${MBEDTLS_LIBRARIES} z)
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)

View File

@ -31,6 +31,7 @@ if(WIN32)
add_definitions(-DDISCORD_WINDOWS)
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
add_library(discord-rpc ${BASE_RPC_SRC})
dolphin_disable_warnings_msvc(discord-rpc)
if (MSVC)
if(USE_STATIC_CRT)
foreach(CompilerFlag

View File

@ -11,3 +11,4 @@ add_library(ed25519
sc.c
sha512.c
verify.c)
dolphin_disable_warnings_msvc(ed25519)

View File

@ -72,6 +72,7 @@ add_library(enet STATIC
unix.c
win32.c
)
dolphin_disable_warnings_msvc(enet)
if(HAIKU)
target_link_libraries(enet network)
endif(HAIKU)

View File

@ -229,6 +229,7 @@ else()
endif ()
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst)
dolphin_disable_warnings_msvc(fmt)
add_library(fmt::fmt ALIAS fmt)
if (FMT_WERROR)

View File

@ -73,6 +73,7 @@ endif()
endif()
add_library(glslang STATIC ${SRCS})
dolphin_disable_warnings_msvc(glslang)
target_include_directories(glslang
PRIVATE

View File

@ -1,6 +1,7 @@
project(hidapi)
add_library(hidapi STATIC hidapi/hidapi.h)
dolphin_disable_warnings_msvc(hidapi)
target_include_directories(hidapi PUBLIC hidapi)
if(APPLE)

View File

@ -12,6 +12,7 @@ set(SRCS
)
add_library(imgui STATIC ${SRCS})
dolphin_disable_warnings_msvc(imgui)
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(imgui

View File

@ -7,3 +7,4 @@ set(SRCS lib/iconv.c
)
add_library(iconv STATIC ${SRCS})
dolphin_disable_warnings_msvc(iconv)

View File

@ -207,6 +207,7 @@ set(LZMA_SRCS
add_library(lzma STATIC ${LZMA_SRCS} ${LZMA_PUBLIC_HDRS})
add_library(LibLZMA::LibLZMA ALIAS lzma)
dolphin_disable_warnings_msvc(lzma)
target_compile_definitions(lzma PUBLIC LZMA_API_STATIC)

View File

@ -39,6 +39,8 @@ add_library(png STATIC
pngwutil.c
)
dolphin_disable_warnings_msvc(png)
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations for libpng" OFF)
if(PNG_HARDWARE_OPTIMIZATIONS)

View File

@ -6,6 +6,8 @@ add_library(usb STATIC EXCLUDE_FROM_ALL
libusb/libusb/strerror.c
libusb/libusb/sync.c
)
dolphin_disable_warnings_msvc(usb)
set_target_properties(usb PROPERTIES VERSION 1.0.26)
if(WIN32)
target_include_directories(usb BEFORE PUBLIC libusb/libusb PRIVATE libusb/msvc)

View File

@ -1,6 +1,7 @@
set(LIBMGBA_ONLY ON)
set(USE_LZMA ON)
add_subdirectory(mgba EXCLUDE_FROM_ALL)
dolphin_disable_warnings_msvc(mgba)
if(NOT MSVC)
target_compile_options(mgba PRIVATE -Wno-unused-parameter -Wno-unused-result -Wno-unused-variable)

View File

@ -189,28 +189,34 @@ endif()
if(USE_STATIC_MBEDTLS_LIBRARY)
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
dolphin_disable_warnings_msvc(${mbedcrypto_static_target})
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
target_link_libraries(${mbedcrypto_static_target} PUBLIC ${libs})
add_library(${mbedx509_static_target} STATIC ${src_x509})
dolphin_disable_warnings_msvc(${mbedx509_static_target})
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target})
add_library(${mbedtls_static_target} STATIC ${src_tls})
dolphin_disable_warnings_msvc(${mbedtls_static_target})
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target})
endif(USE_STATIC_MBEDTLS_LIBRARY)
if(USE_SHARED_MBEDTLS_LIBRARY)
add_library(${mbedcrypto_target} SHARED ${src_crypto})
dolphin_disable_warnings_msvc(${mbedcrypto_target})
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.28.0 SOVERSION 7)
target_link_libraries(${mbedcrypto_target} PUBLIC ${libs})
add_library(${mbedx509_target} SHARED ${src_x509})
dolphin_disable_warnings_msvc(${mbedx509_target})
set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.28.0 SOVERSION 1)
target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target})
add_library(${mbedtls_target} SHARED ${src_tls})
dolphin_disable_warnings_msvc(${mbedtls_target})
set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.28.0 SOVERSION 14)
target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
endif(USE_SHARED_MBEDTLS_LIBRARY)

View File

@ -33,6 +33,7 @@ set(SRCS src/igd_desc_parse.c
src/receivedata.c)
add_library(miniupnpc STATIC ${SRCS})
dolphin_disable_warnings_msvc(miniupnpc)
target_include_directories(miniupnpc PUBLIC src)
add_library(Miniupnpc::miniupnpc ALIAS miniupnpc)

View File

@ -26,6 +26,7 @@ add_library(minizip STATIC
unzip.h
zip.h
)
dolphin_disable_warnings_msvc(minizip)
if (UNIX)
target_sources(minizip PRIVATE

View File

@ -35,6 +35,7 @@ if(BUILD_SHARED_LIBS)
else()
add_library(pugixml STATIC ${SOURCES})
endif()
dolphin_disable_warnings_msvc(pugixml)
set_target_properties(pugixml PROPERTIES VERSION 1.8 SOVERSION 1)
get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)

View File

@ -16,4 +16,5 @@ set(SRCS
)
add_library(SoundTouch STATIC ${SRCS})
dolphin_disable_warnings_msvc(SoundTouch)
add_definitions(-w)

View File

@ -1,6 +1,7 @@
project(xxhash C)
add_library(xxhash STATIC xxhash.c)
dolphin_disable_warnings_msvc(xxhash)
target_include_directories(xxhash
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -86,6 +86,7 @@ set(ZLIB_SRCS
)
add_library(z STATIC ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
dolphin_disable_warnings_msvc(z)
add_library(ZLIB::ZLIB ALIAS z)
target_include_directories(z

View File

@ -115,6 +115,7 @@ set(ZSTD_SRCS
)
add_library(zstd STATIC ${ZSTD_SRCS} ${ZSTD_PUBLIC_HDRS} ${ZSTD_PRIVATE_HDRS})
dolphin_disable_warnings_msvc(zstd)
add_library(zstd::zstd ALIAS zstd)
target_include_directories(zstd