CMake: Hide warnings in Externals also for non-msvc.

This commit is contained in:
Jordan Woyak 2024-03-19 01:08:54 -05:00
parent 85dee300b5
commit 25833cfd62
34 changed files with 55 additions and 53 deletions

View File

@ -1,18 +1,20 @@
include(RemoveCompileFlag)
macro(dolphin_disable_warnings_msvc _target)
macro(dolphin_disable_warnings _target)
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()
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")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(${_target} PRIVATE "-w")
endif()
endmacro()

View File

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

View File

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

View File

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

View File

@ -10,8 +10,8 @@ set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
set(OPT_DEF_LIBC ON)
add_subdirectory(SDL)
if (TARGET SDL2)
dolphin_disable_warnings_msvc(SDL2)
dolphin_disable_warnings(SDL2)
endif()
if (TARGET SDL2-static)
dolphin_disable_warnings_msvc(SDL2-static)
dolphin_disable_warnings(SDL2-static)
endif()

View File

@ -27,5 +27,5 @@ target_compile_definitions(sfml-system PUBLIC SFML_STATIC)
target_include_directories(sfml-system PUBLIC include PRIVATE src)
target_include_directories(sfml-network PUBLIC include PRIVATE src)
target_link_libraries(sfml-network PUBLIC sfml-system)
dolphin_disable_warnings_msvc(sfml-network)
dolphin_disable_warnings_msvc(sfml-system)
dolphin_disable_warnings(sfml-network)
dolphin_disable_warnings(sfml-system)

View File

@ -70,7 +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)
dolphin_disable_warnings(bzip2)
target_include_directories(bzip2
PUBLIC

View File

@ -3,5 +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)
dolphin_disable_warnings(cpp-optparse)
target_include_directories(cpp-optparse PUBLIC .)

View File

@ -69,7 +69,7 @@ add_library(cubeb
cubeb/src/cubeb_strings.c
cubeb/src/cubeb_utils.cpp
)
dolphin_disable_warnings_msvc(cubeb)
dolphin_disable_warnings(cubeb)
target_include_directories(cubeb
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cubeb/include> $<INSTALL_INTERFACE:include>
)
@ -127,7 +127,7 @@ endif()
if(NOT TARGET speex)
add_library(speex OBJECT cubeb/subprojects/speex/resample.c)
dolphin_disable_warnings_msvc(speex)
dolphin_disable_warnings(speex)
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
target_include_directories(speex INTERFACE cubeb/subprojects)
target_compile_definitions(speex PUBLIC

View File

@ -45,7 +45,7 @@ if(NOT CURL_CA_PATH_SET)
endif()
endif()
dolphin_disable_warnings_msvc(curl)
dolphin_disable_warnings(curl)
target_link_libraries(curl ${CURL_LIBS})
target_include_directories(curl PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/curl/include")
target_compile_definitions(curl PRIVATE "BUILDING_LIBCURL=1")

View File

@ -31,7 +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)
dolphin_disable_warnings(discord-rpc)
if (MSVC)
if(USE_STATIC_CRT)
foreach(CompilerFlag

View File

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

View File

@ -92,7 +92,7 @@ add_library(enet STATIC
)
target_include_directories(enet PUBLIC enet/include)
dolphin_disable_warnings_msvc(enet)
dolphin_disable_warnings(enet)
add_library(enet::enet ALIAS enet)
if (MINGW)

View File

@ -1,2 +1,2 @@
add_subdirectory(fmt)
dolphin_disable_warnings_msvc(fmt)
dolphin_disable_warnings(fmt)

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ set(SRCS
)
add_library(implot STATIC ${SRCS})
dolphin_disable_warnings_msvc(implot)
dolphin_disable_warnings(implot)
target_include_directories(implot
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/implot"
PRIVATE imgui

View File

@ -9,5 +9,5 @@ target_include_directories(iconv
PRIVATE
libcharset/include
)
dolphin_disable_warnings_msvc(iconv)
dolphin_disable_warnings(iconv)
add_library(Iconv::Iconv ALIAS iconv)

View File

@ -207,7 +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)
dolphin_disable_warnings(lzma)
target_compile_definitions(lzma PUBLIC LZMA_API_STATIC)

View File

@ -6,5 +6,5 @@ add_library(spng STATIC libspng/spng/spng.c)
target_compile_definitions(spng PUBLIC SPNG_STATIC)
target_link_libraries(spng PUBLIC ZLIB::ZLIB)
target_include_directories(spng PUBLIC libspng/spng)
dolphin_disable_warnings_msvc(spng)
dolphin_disable_warnings(spng)
add_library(spng::spng ALIAS spng)

View File

@ -6,7 +6,7 @@ add_library(usb STATIC EXCLUDE_FROM_ALL
libusb/libusb/strerror.c
libusb/libusb/sync.c
)
dolphin_disable_warnings_msvc(usb)
dolphin_disable_warnings(usb)
set_target_properties(usb PROPERTIES VERSION 1.0.26)
if(WIN32)

View File

@ -8,6 +8,6 @@ set(LZ4_BUNDLED_MODE ON)
add_subdirectory(lz4/build/cmake)
dolphin_disable_warnings_msvc(lz4_static)
dolphin_disable_warnings(lz4_static)
add_library(LZ4::LZ4 ALIAS lz4_static)
target_compile_definitions(lz4_static PRIVATE XXH_NAMESPACE=LZ4_)

View File

@ -1,7 +1,7 @@
set(LIBMGBA_ONLY ON)
set(USE_LZMA ON)
add_subdirectory(mgba EXCLUDE_FROM_ALL)
dolphin_disable_warnings_msvc(mgba)
dolphin_disable_warnings(mgba)
target_compile_definitions(mgba PUBLIC HAVE_CRC32)
target_link_libraries(mgba ZLIB::ZLIB)

View File

@ -189,34 +189,34 @@ endif()
if(USE_STATIC_MBEDTLS_LIBRARY)
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
dolphin_disable_warnings_msvc(${mbedcrypto_static_target})
dolphin_disable_warnings(${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})
dolphin_disable_warnings(${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})
dolphin_disable_warnings(${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})
dolphin_disable_warnings(${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})
dolphin_disable_warnings(${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})
dolphin_disable_warnings(${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,7 +33,7 @@ set(SRCS src/igd_desc_parse.c
src/receivedata.c)
add_library(miniupnpc STATIC ${SRCS})
dolphin_disable_warnings_msvc(miniupnpc)
dolphin_disable_warnings(miniupnpc)
target_include_directories(miniupnpc PUBLIC src)
add_library(Miniupnpc::miniupnpc ALIAS miniupnpc)

View File

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

View File

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

View File

@ -19,4 +19,4 @@ set(SRCS
)
add_library(SoundTouch STATIC ${SRCS})
dolphin_disable_warnings_msvc(SoundTouch)
dolphin_disable_warnings(SoundTouch)

View File

@ -47,7 +47,7 @@ endif()
endif()
add_library(spirv_cross STATIC ${SRCS})
dolphin_disable_warnings_msvc(spirv_cross)
dolphin_disable_warnings(spirv_cross)
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
target_include_directories(spirv_cross PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Cross/include ${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Cross)

View File

@ -8,4 +8,4 @@ endif()
target_sources(tinygltf PRIVATE
tinygltf/tiny_gltf.cc)
target_include_directories(tinygltf INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
dolphin_disable_warnings_msvc(tinygltf)
dolphin_disable_warnings(tinygltf)

View File

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

View File

@ -12,4 +12,4 @@ set(ZLIB_LIBRARY ZLIB::ZLIB CACHE STRING "Path to zlib library")
# Setup zlib alias project so FindZLIB doesn't recreate it
add_library(ZLIB::ZLIB ALIAS zlib)
dolphin_disable_warnings_msvc(zlib)
dolphin_disable_warnings(zlib)

View File

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