Check for the -Wno-deprecacted-copy compiler option in cmake build

pdv pdvisschere at edpnet.be
Sat Apr 3 16:13:17 UTC 2021


The Apple Clang compiler does not recognize the -Wno-deprecated-copy 
compiler option. See thread "Re: warning: unknown warning option 
'-Wno-deprecated-copy'" (8/10/2020) in this list.

This was solved for the autotools build with commit 4aee447af1 (13/10/2020).

I've implemented a similar check for the cmake build.

As is stands the patch unsets the test-variable from the cache and the 
test is performed for each cmake-run.
I don't know what's the preferred policy and one should remove that line 
to use the cached result instead.

P. De Visschere
-------------- next part --------------
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()


More information about the lyx-devel mailing list