From 49116a0669675daa8239f27afa40104ff615fbeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 18 Dec 2024 16:05:30 +0100 Subject: [PATCH] modules: use the COMPILE_LANGUAGE genexp instead of LINKER_LANGUAGE. I spent ages looking for a COMPILE_LANGUAGE CMake target property, it was just not there. Obviously it wasn't, because this is different on a per-file basis, it's a generator expression on its own. With this, the Corrade pedantic flags should no longer cause annoying warning when used with targets that mix C and C++. Unfortunately, in CMake 3.11 and older, if the projects uses just C or CXX, the thing will fail with an error that the language is unknown, which makes it useless. Thus gotta wait with this until 3.12 is the minimum supported: https://gitlab.kitware.com/cmake/cmake/-/commit/4f82199befee194aa924fd4dcdb2f4aad1f7dab6 --- modules/UseCorrade.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/UseCorrade.cmake b/modules/UseCorrade.cmake index e2a7d73cf..7f4bcc944 100644 --- a/modules/UseCorrade.cmake +++ b/modules/UseCorrade.cmake @@ -102,10 +102,10 @@ endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang" AND NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") OR CORRADE_TARGET_EMSCRIPTEN) set(CORRADE_PEDANTIC_COMPILER_OPTIONS "-Wall" "-Wextra" - "$<$,CXX>:-Wold-style-cast>" + "$<$:-Wold-style-cast>" "-Winit-self" # -Werror=return-type doesn't work on nvcc, use it just for C and C++ - "$<$,C>,$,CXX>>:-Werror=return-type>" + "$<$,$>:-Werror=return-type>" "-Wmissing-declarations" # -Wpedantic is since 4.8, until then only -pedantic (which doesn't # have any -Wno-pedantic or a way to disable it for a particular line) @@ -139,7 +139,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "(Appl # TODO: do this with check_c_compiler_flags() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS - "$<$,CXX>:-Wzero-as-null-pointer-constant>" + "$<$:-Wzero-as-null-pointer-constant>" # TODO: enable when this gets to Clang (not in 3.9, but in master # since https://github.com/llvm-mirror/clang/commit/0a022661c797356e9c28e4999b6ec3881361371e) @@ -330,7 +330,7 @@ endif() # COMPILE_FEATURES is present either. It doesn't cover adding flags using # target_compile_options(), though. set(_CORRADE_CXX_STANDARD_ONLY_IF_NOT_ALREADY_SET - "$,CXX>,$>>,$>>") + "$,$>>,$>>") foreach(_standard 11 14 17 20) if(CORRADE_CXX${_standard}_STANDARD_FLAG) set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS