[LyX/master] Cmake build: Remove warnings about deprecated policy CMP0069

Kornel Benko kornel at lyx.org
Sat Nov 9 15:45:57 UTC 2019


commit c9c86b49666e49a6cc0c850af7413bfea500c5fd
Author: Kornel Benko <kornel at lyx.org>
Date:   Sat Nov 9 16:56:16 2019 +0100

    Cmake build: Remove warnings about deprecated policy CMP0069
    
    Deprecated since cmake version 3.16
    (Now explicitly enable/disable interprocedural optimization
    if supported and not debugging)
---
 3rdparty/hunspell/CMakeLists.txt |   11 +++++++----
 3rdparty/libiconv/CMakeLists.txt |   11 +++++++++--
 3rdparty/mythes/CMakeLists.txt   |   11 +++++++----
 3rdparty/zlib/CMakeLists.txt     |   11 +++++++++--
 CMakeLists.txt                   |    7 ++++---
 src/CMakeLists.txt               |    5 +++--
 src/tex2lyx/CMakeLists.txt       |    4 +++-
 7 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/3rdparty/hunspell/CMakeLists.txt b/3rdparty/hunspell/CMakeLists.txt
index ad67b43..9921d6d 100644
--- a/3rdparty/hunspell/CMakeLists.txt
+++ b/3rdparty/hunspell/CMakeLists.txt
@@ -1,11 +1,12 @@
 
 cmake_minimum_required(VERSION 3.1)
 
+set(LYX_IPO_SUPPORTED FALSE)
 if (POLICY CMP0069)
-  if (LYX_DEBUG)
-    cmake_policy(SET CMP0069 OLD)
-  else()
+  if (NOT LYX_DEBUG)
     cmake_policy(SET CMP0069 NEW)
+    include(CheckIPOSupported)
+    check_ipo_supported(RESULT LYX_IPO_SUPPORTED)
   endif()
 endif()
 
@@ -61,4 +62,6 @@ set(HUNSPELL_LIBRARY hunspell CACHE STRING "Hunspell library" FORCE)
 set(HUNSPELL_INCLUDE_DIR ${SRCDIR} CACHE STRING "Hunspell include dir" FORCE)
 set(HUNSPELL_FOUND CACHE STRING "Hunspell found" FORCE)
 
-set_target_properties(hunspell PROPERTIES FOLDER "3rd_party")
+set_target_properties(hunspell PROPERTIES
+	FOLDER "3rd_party"
+	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
diff --git a/3rdparty/libiconv/CMakeLists.txt b/3rdparty/libiconv/CMakeLists.txt
index 7f5c73b..6261b3c 100644
--- a/3rdparty/libiconv/CMakeLists.txt
+++ b/3rdparty/libiconv/CMakeLists.txt
@@ -7,8 +7,13 @@
 project ( libiconv C )
 cmake_minimum_required(VERSION 3.1)
 
+set(LYX_IPO_SUPPORTED FALSE)
 if (POLICY CMP0069)
-  cmake_policy(SET CMP0069 NEW)
+  if (NOT LYX_DEBUG)
+    cmake_policy(SET CMP0069 NEW)
+    include(CheckIPOSupported)
+    check_ipo_supported(RESULT LYX_IPO_SUPPORTED)
+  endif()
 endif()
 
 set(CMAKE_MODULE_PATH .)
@@ -59,4 +64,6 @@ set(ICONV_INCLUDE_DIR ${BINDIR}/include CACHE STRING "libiconv include  dir" FOR
 set(ICONV_LIBRARY iconv CACHE STRING "libiconv library" FORCE)
 set(ICONV_FOUND iconv CACHE STRING "libiconv found" FORCE)
 
-set_target_properties(iconv PROPERTIES FOLDER "3rd_party")
+set_target_properties(iconv PROPERTIES
+	FOLDER "3rd_party"
+	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
diff --git a/3rdparty/mythes/CMakeLists.txt b/3rdparty/mythes/CMakeLists.txt
index d970ef2..1b224a9 100644
--- a/3rdparty/mythes/CMakeLists.txt
+++ b/3rdparty/mythes/CMakeLists.txt
@@ -1,10 +1,11 @@
 cmake_minimum_required(VERSION 3.1)
 
+set(LYX_IPO_SUPPORTED FALSE)
 if (POLICY CMP0069)
-  if (LYX_DEBUG)
-    cmake_policy(SET CMP0069 OLD)
-  else()
+  if (NOT LYX_DEBUG)
     cmake_policy(SET CMP0069 NEW)
+    include(CheckIPOSupported)
+    check_ipo_supported(RESULT LYX_IPO_SUPPORTED)
   endif()
 endif()
 
@@ -27,4 +28,6 @@ set(MYTHESLIB_LIBRARY mytheslibstatic CACHE STRING "Mytheslib library" FORCE)
 set(MYTHESLIB_INCLUDE_DIR  ${SRCDIR} CACHE STRING "Mytheslib include dir" FORCE)
 set(MYTHESLIB_FOUND CACHE STRING "Mytheslib found" FORCE )
 
-set_target_properties(mytheslibstatic PROPERTIES FOLDER "3rd_party")
+set_target_properties(mytheslibstatic PROPERTIES
+	FOLDER "3rd_party"
+	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt
index a8ca489..b14776e 100644
--- a/3rdparty/zlib/CMakeLists.txt
+++ b/3rdparty/zlib/CMakeLists.txt
@@ -1,7 +1,12 @@
 cmake_minimum_required(VERSION 3.1)
 
+set(LYX_IPO_SUPPORTED FALSE)
 if (POLICY CMP0069)
-  cmake_policy(SET CMP0069 NEW)
+  if (NOT LYX_DEBUG)
+    cmake_policy(SET CMP0069 NEW)
+    include(CheckIPOSupported)
+    check_ipo_supported(RESULT LYX_IPO_SUPPORTED)
+  endif()
 endif()
 
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
@@ -163,4 +168,6 @@ set(ZLIB_LIBRARY zlibstatic CACHE STRING "Zlib library" FORCE)
 set(ZLIB_INCLUDE_DIR  ${SRCDIR} CACHE STRING "Zlib include dir" FORCE)
 set(ZLIB_FOUND CACHE STRING "Zlib found" FORCE )
 
-set_target_properties(zlibstatic PROPERTIES FOLDER "3rd_party")
+set_target_properties(zlibstatic PROPERTIES
+	FOLDER "3rd_party"
+	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f759d8f..779d9e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,11 +82,12 @@ if(NOT help AND NOT HELP)
     endif()
   endif()
   # Enable LTO if supported and not debugging
+  set(LYX_IPO_SUPPORTED FALSE)
   if (POLICY CMP0069)
-    if (LYX_DEBUG)
-      cmake_policy(SET CMP0069 OLD)
-    else()
+    if (NOT LYX_DEBUG)
       cmake_policy(SET CMP0069 NEW)
+      include(CheckIPOSupported)
+      check_ipo_supported(RESULT LYX_IPO_SUPPORTED)
     endif()
   endif()
 endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 39c751f..7793179 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -122,8 +122,9 @@ add_executable(${_lyx}
 
 add_dependencies(${_lyx} lyx_version)
 
-set_target_properties(${_lyx} PROPERTIES FOLDER "applications/LyX")
-
+set_target_properties(${_lyx} PROPERTIES
+	FOLDER "applications/LyX"
+	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
 lyx_add_gcc_pch(${_lyx})
 
 target_link_libraries(${_lyx}
diff --git a/src/tex2lyx/CMakeLists.txt b/src/tex2lyx/CMakeLists.txt
index 36db723..1927655 100644
--- a/src/tex2lyx/CMakeLists.txt
+++ b/src/tex2lyx/CMakeLists.txt
@@ -40,7 +40,9 @@ else()
 	lyx_const_touched_files(_allinone_linked  LINKED_sources)
 	add_executable(${_tex2lyx} ${_allinone_files} ${_allinone_linked_files} ${FILE_RC})
 endif()
-set_target_properties(${_tex2lyx} PROPERTIES FOLDER "applications/TeX2LyX")
+set_target_properties(${_tex2lyx} PROPERTIES
+	FOLDER "applications/TeX2LyX"
+	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
 
 target_link_libraries(${_tex2lyx}
 	support


More information about the lyx-cvs mailing list