Re: Fwd: cmake patches

Peter von Kaehne <[email protected]>
Newsgroups gmane.comp.literature.sword.devel
Message-ID <[email protected]>
How to suggest improvements to the sword project?

You did it the right way. It just is a bit on/off as a project. GHellings is the cmake pumpkin holder as far as I know. I bcc him on a different email address.

Peter

BR,

Zdenko

---------- Forwarded message ---------
From: ZdPo Ster <[email protected] >
Date: Sun, 6 Nov 2022 at 22:22
Subject: cmake patches
To: <[email protected] >

Hello,

please find 3 few patches related to cmake build (tested on windows with MSVC 2019):

- cmake_fix_deprecation.patch - cmake version 3.23.2 produce depreciation warning for old minimum version, co IMO it is time to increase expected cmake version

- cmake_fix_msvc.patch - there is no "/O3" options in current MSVC[1]

- cmake_git_svn.patch - I use git svn for accessing code, but cmake produce error because of missing svn executable. He is patch that fixed it + code for detecting svn revision (MYSVN_WC_REVISION) from git

[1] https://learn.microsoft.com/en-us/cpp/build/reference/o-options-optimize-code?view=msvc-160

Zdenko

_______________________________________________
sword-devel mailing list: [email protected]
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

_______________________________________________
sword-devel mailing list: [email protected]
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
cmake_fix_deprecation.patch (application/octet-stream, 749 B)
From 1b89a8dc8a61a8a98b47286b305642cd70b35cf5 Mon Sep 17 00:00:00 2001
From: Zdenko <[email protected]>
Date: Sun, 6 Nov 2022 21:30:51 +0100
Subject: cmake: fix Deprecation Warning - Compatibility with CMake < 2.8.12
 will be removed from a future version of


diff --git a/CMakeLists.txt b/CMakeLists.txt
index a15d7942..69ef1a82 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ include(FindSubversion)
 Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} MYSVN IGNORE_SVN_FAILURE)
 
 PROJECT(libsword CXX C)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
 SET(SWORD_VERSION 1.9.0)
 if(DEFINED MYSVN_WC_REVISION)
 	SET(SWORD_VERSION ${SWORD_VERSION}.${MYSVN_WC_REVISION})
cmake_git_svn.patch (application/octet-stream, 4.9 KB)
From e39d726a7064511c3969e38400884563aa3a519c Mon Sep 17 00:00:00 2001
From: Zdenko <[email protected]>
Date: Sun, 6 Nov 2022 22:07:47 +0100
Subject: cmake: fix build with git-svn


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69ef1a82..88f5febc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,17 @@
 
 CMAKE_POLICY(SET CMP0010 NEW)
 include(FindSubversion)
-Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} MYSVN IGNORE_SVN_FAILURE)
+if(Subversion_FOUND)
+	Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} MYSVN IGNORE_SVN_FAILURE)
+else()
+	include(FindGit)
+	if(GIT_FOUND)
+		INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/VersionFromVCS.cmake")
+		get_source_info_git(${CMAKE_CURRENT_SOURCE_DIR} MYSVN_WC_REVISION repository)
+		message("revision is ${MYSVN_WC_REVISION}")
+	endif(GIT_FOUND)
+endif(Subversion_FOUND)
+
 
 PROJECT(libsword CXX C)
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
diff --git a/cmake/VersionFromVCS.cmake b/cmake/VersionFromVCS.cmake
new file mode 100644
index 00000000..c5cdc144
--- /dev/null
+++ b/cmake/VersionFromVCS.cmake
@@ -0,0 +1,97 @@
+# Source: https://raw.githubusercontent.com/llvm-mirror/llvm/master/cmake/modules/VersionFromVCS.cmake
+# Licence: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
+
+# Adds version control information to the variable VERS. For
+# determining the Version Control System used (if any) it inspects the
+# existence of certain subdirectories under SOURCE_DIR (if provided as an
+# extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR).
+
+function(get_source_info_svn path revision repository)
+  # If svn is a bat file, find_program(Subversion) doesn't find it.
+  # Explicitly search for that here; Subversion_SVN_EXECUTABLE will override
+  # the find_program call in FindSubversion.cmake.
+  find_program(Subversion_SVN_EXECUTABLE NAMES svn svn.bat)
+  find_package(Subversion)
+
+  # Subversion module does not work with symlinks, see PR8437.
+  get_filename_component(realpath ${path} REALPATH)
+  if(Subversion_FOUND)
+    subversion_wc_info(${realpath} Project)
+    if(Project_WC_REVISION)
+      set(${revision} ${Project_WC_REVISION} PARENT_SCOPE)
+    endif()
+    if(Project_WC_URL)
+      set(${repository} ${Project_WC_URL} PARENT_SCOPE)
+    endif()
+  endif()
+endfunction()
+
+function(get_source_info_git path revision repository)
+  find_package(Git)
+  if(GIT_FOUND)
+    execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
+      WORKING_DIRECTORY ${path}
+      RESULT_VARIABLE git_result
+      OUTPUT_VARIABLE git_output
+      ERROR_QUIET)
+    if(git_result EQUAL 0)
+      string(STRIP "${git_output}" git_output)
+      get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path})
+      if(EXISTS "${git_dir}/svn/refs")
+        execute_process(COMMAND ${GIT_EXECUTABLE} svn info
+          WORKING_DIRECTORY ${path}
+          RESULT_VARIABLE git_result
+          OUTPUT_VARIABLE git_output)
+        if(git_result EQUAL 0)
+          string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
+            "\\2" git_svn_rev "${git_output}")
+          set(${revision} ${git_svn_rev} PARENT_SCOPE)
+          string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
+            "\\2" git_url "${git_output}")
+          set(${repository} ${git_url} PARENT_SCOPE)
+        endif()
+      else()
+        execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
+          WORKING_DIRECTORY ${path}
+          RESULT_VARIABLE git_result
+          OUTPUT_VARIABLE git_output)
+        if(git_result EQUAL 0)
+          string(STRIP "${git_output}" git_output)
+          set(${revision} ${git_output} PARENT_SCOPE)
+        endif()
+        execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref --symbolic-full-name @{upstream}
+          WORKING_DIRECTORY ${path}
+          RESULT_VARIABLE git_result
+          OUTPUT_VARIABLE git_output
+          ERROR_QUIET)
+        if(git_result EQUAL 0)
+          string(REPLACE "/" ";" branch ${git_output})
+          list(GET branch 0 remote)
+        else()
+          set(remote "origin")
+        endif()
+        execute_process(COMMAND ${GIT_EXECUTABLE} remote get-url ${remote}
+          WORKING_DIRECTORY ${path}
+          RESULT_VARIABLE git_result
+          OUTPUT_VARIABLE git_output
+          ERROR_QUIET)
+        if(git_result EQUAL 0)
+          string(STRIP "${git_output}" git_output)
+          set(${repository} ${git_output} PARENT_SCOPE)
+        else()
+          set(${repository} ${path} PARENT_SCOPE)
+        endif()
+      endif()
+    endif()
+  endif()
+endfunction()
+
+function(get_source_info path revision repository)
+  if(EXISTS "${path}/.svn")
+    get_source_info_svn("${path}" revision_info repository_info)
+  else()
+    get_source_info_git("${path}" revision_info repository_info)
+  endif()
+  set(${repository} "${repository_info}" PARENT_SCOPE)
+  set(${revision} "${revision_info}" PARENT_SCOPE)
+endfunction()
cmake_fix_msvc.patch (application/octet-stream, 1.3 KB)
From b2bdd8772f02c3a95119155f058cea1474c61478 Mon Sep 17 00:00:00 2001
From: Zdenko <[email protected]>
Date: Sun, 6 Nov 2022 21:29:22 +0100
Subject: cmake: fix "cl : command line warning D9002: ignoring unknown option
 '/O3'"


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 676353b5..a15d7942 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -174,11 +174,11 @@ ENDIF(SWORD_ENABLE_PROFILEFN STREQUAL "Yes")
 
 IF(MSVC)
 	SET(CMAKE_C_FLAGS_DEBUG            "/D /O0 /DDEBUG ${CMAKE_C_FLAGS}")
-	SET(CMAKE_C_FLAGS_RELEASE          "/O3 /DNDEBUG ${CMAKE_C_FLAGS}")
-	SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "/O3 /D /DDEBUG ${CMAKE_C_FLAGS}")
+	SET(CMAKE_C_FLAGS_RELEASE          "/O2 /DNDEBUG ${CMAKE_C_FLAGS}")
+	SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "/O2 /D /DDEBUG ${CMAKE_C_FLAGS}")
 	SET(CMAKE_CXX_FLAGS_DEBUG          "/D /O0 /DDEBUG ${CMAKE_CXX_FLAGS}")
-	SET(CMAKE_CXX_FLAGS_RELEASE        "/O3 ${CMAKE_CXX_FLAGS}")
-	SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O3 /D /DDEBUG ${CMAKE_CXX_FLAGS}")
+	SET(CMAKE_CXX_FLAGS_RELEASE        "/O2 ${CMAKE_CXX_FLAGS}")
+	SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /D /DDEBUG ${CMAKE_CXX_FLAGS}")
 ELSE(MSVC)
 	SET(CMAKE_C_FLAGS_DEBUG            "-g3 -Wall -O0 ${CMAKE_C_FLAGS}")
 	SET(CMAKE_C_FLAGS_RELEASE          "-O3 ${CMAKE_C_FLAGS}")
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.