We need to pick RelWithDebInfo build_type to get the debug info along
with advanced optimization, but before this patch, -WError was also
added to RelWithDebInfo, and LTO was not activated with RelWithDebInfo

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -328,7 +328,7 @@
 endif()
 
 if(NOT MSVC)
-  if(CMAKE_BUILD_TYPE STREQUAL "Release")
+  if((CMAKE_BUILD_TYPE STREQUAL "Release") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
     message(STATUS "Compiler warnings will be ignored.")
   elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") AND (
          ((NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.2))
@@ -360,7 +360,7 @@
 if(USE_FLTO_IF_AVAILABLE STREQUAL "yes")
 # Cross-compile-unit optimization not supported by gcc with debug on!
 # Therefore, this may only be done with Release builds.
-if(CMAKE_BUILD_TYPE STREQUAL "Release")
+if((CMAKE_BUILD_TYPE STREQUAL "Release") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
   # Only tested on Linux. Might work also on other platforms.
   # If tested and found good, remove this check
   if (CMAKE_SYSTEM MATCHES "Linux")
@@ -379,7 +379,7 @@
       message(STATUS "Enabling link-time optimizations")
     endif()
   endif(CMAKE_SYSTEM MATCHES "Linux")
-endif(CMAKE_BUILD_TYPE STREQUAL "Release")
+endif((CMAKE_BUILD_TYPE STREQUAL "Release") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
 endif(USE_FLTO_IF_AVAILABLE STREQUAL  "yes")
 
 IF (WIN32)
@@ -482,7 +482,7 @@
 install (
   FILES ${CMAKE_CURRENT_BINARY_DIR}/VERSION
   DESTINATION ${WL_INSTALL_BASEDIR}
-  CONFIGURATIONS Debug;Release;None
+  CONFIGURATIONS Debug;Release;RelWithDebInfo;None
   COMPONENT CoreVersionFile
 )
 
@@ -498,7 +498,7 @@
   FILES
     data/datadirversion
   DESTINATION ${WL_INSTALL_DATADIR}
-  CONFIGURATIONS Debug;Release;None
+  CONFIGURATIONS Debug;Release;RelWithDebInfo;None
   COMPONENT VersionFile
 )
 
@@ -515,7 +515,7 @@
     data/txts
     data/world
   DESTINATION ${WL_INSTALL_DATADIR}
-  CONFIGURATIONS Debug;Release;None
+  CONFIGURATIONS Debug;Release;RelWithDebInfo;None
   COMPONENT CoreDataFiles
 )
 
@@ -523,7 +523,7 @@
   DIRECTORY
     data/maps
   DESTINATION ${WL_INSTALL_DATADIR}
-  CONFIGURATIONS Debug;Release;None
+  CONFIGURATIONS Debug;Release;RelWithDebInfo;None
   COMPONENT MapFiles
 )
 
@@ -532,7 +532,7 @@
     data/music
     data/sound
   DESTINATION ${WL_INSTALL_DATADIR}
-  CONFIGURATIONS Debug;Release;None
+  CONFIGURATIONS Debug;Release;RelWithDebInfo;None
   COMPONENT MusicFiles
 )
 
@@ -542,7 +542,7 @@
     CREDITS
     ChangeLog
   DESTINATION ${WL_INSTALL_BASEDIR}
-  CONFIGURATIONS Debug;Release;None
+  CONFIGURATIONS Debug;Release;RelWithDebInfo;None
   COMPONENT CoreLicenseFiles
 )
 
@@ -561,7 +561,7 @@
     DIRECTORY
       ${CMAKE_CURRENT_BINARY_DIR}/locale/
     DESTINATION ${WL_INSTALL_DATADIR}/locale
-    CONFIGURATIONS Debug;Release;None
+    CONFIGURATIONS Debug;Release;RelWithDebInfo;None
     COMPONENT CoreLanguageFiles
   )
 endif(OPTION_BUILD_TRANSLATIONS)
