From fa704d50f70e2ead66f34594023aebb50714926c Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Mon, 5 Apr 2021 11:14:13 +0200 Subject: [PATCH] Cmake build: Omit use -f '-Wno-deprecated-copy' on compilers which do not support this flag. Patch from P. De Visschere Citing Patrick: As is stands the patch unsets the test-variable from the cache and the test is performed for each cmake-run. Otherwise after running cmake once the check is never run again, until one throws away the cmakecache.txt, which I try to avoid. I suppose that after time this check will be forgotten and if the issue is solved (by an upgrade of the Apple clang compiler) this will pass unnoticed. --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4ed8cfc11..c3eed1a52d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -699,7 +699,14 @@ else() # The following setting with LYX_GCC11_MODE is needed because cmake does not honor # CMAKE_CXX_STANDARD while performing tests like # check_cxx_source_compiles("..." HAVE_DEF_MAKE_UNIQUE) - set(LYX_CXX_FLAGS "-Wall -Wextra -Wno-deprecated-copy ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}") + include(CheckCXXCompilerFlag) + unset(CHECK_WNODEPRECATEDCOPY_FLAG CACHE) + CHECK_CXX_COMPILER_FLAG("-Wno-deprecated-copy" CHECK_WNODEPRECATEDCOPY_FLAG) + if(${CHECK_WNODEPRECATEDCOPY_FLAG}) + set(LYX_CXX_FLAGS "-Wall -Wextra -Wno-deprecated-copy ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}") + else() + set(LYX_CXX_FLAGS "-Wall -Wextra ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}") + endif() if(LYX_STDLIB_DEBUG) set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC") else()