]> granicus.if.org Git - fortune-mod/commitdiff
Extract the rinutils_bootstrap module.
authorShlomi Fish <shlomif@shlomifish.org>
Tue, 24 Nov 2020 13:01:43 +0000 (15:01 +0200)
committerShlomi Fish <shlomif@shlomifish.org>
Tue, 24 Nov 2020 13:01:43 +0000 (15:01 +0200)
See:

* https://github.com/shlomif/fc-solve/commit/396755081ef49d0bd4dccf7cd23a78f223301771

* https://github.com/shlomif/fortune-mod/commit/532435d33d4fe4480239bde35f6045d5c0d013ad

For streamlining the build process of co-developers.

This is Refactoring / code cleanup.

See:

* https://refactoring.com/catalog/extractMethod.html

* https://en.wikipedia.org/wiki/Code_refactoring

* https://www.refactoring.com/

* https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/

Some small optimisations may have slipped in as well.

fortune-mod/cmake/rinutils_bootstrap.cmake

index e9a93fb03323ba85cc7ca7e882a69eddc2996976..3879bce8501e8a9a1b70cadeb903fbcc86b2f6e4 100644 (file)
@@ -3,24 +3,23 @@ MACRO(RINUTILS_SET_UP_FLAGS)
     SET (rinutils_dir "rinutils")
     SET (rinutils_dir_absolute "${CMAKE_CURRENT_SOURCE_DIR}/${rinutils_dir}")
     SET (rinutils_inc_dir "${rinutils_dir_absolute}/rinutils/include")
-    IF (NOT EXISTS "${rinutils_inc_dir}")
-        EXECUTE_PROCESS(
-            COMMAND "git" "clone" "-b" "0.6.0" "https://github.com/shlomif/rinutils.git" "${rinutils_dir}"
-            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
-        )
+    SET (rinutils_git_tag "0.6.0")
+
+    find_package(Rinutils QUIET)
+    IF ("${Rinutils_FOUND}")
+        INCLUDE_DIRECTORIES(AFTER ${RINUTILS_INCLUDE_DIR} ${RINUTILS_INCLUDE_DIRS})
     ELSE ()
         IF (NOT EXISTS "${rinutils_inc_dir}")
+            EXECUTE_PROCESS(
+                COMMAND "git" "clone" "-b" "${rinutils_git_tag}" "https://github.com/shlomif/rinutils.git" "${rinutils_dir}"
+                WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+            )
+        ELSE ()
             EXECUTE_PROCESS(
                 COMMAND "git" "submodule" "update" "--init"
                 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
             )
         ENDIF ()
-    ENDIF ()
-
-    find_package(Rinutils QUIET)
-    IF ("${Rinutils_FOUND}")
-        INCLUDE_DIRECTORIES(AFTER ${RINUTILS_INCLUDE_DIR} ${RINUTILS_INCLUDE_DIRS})
-    ELSE ()
         IF (NOT EXISTS "${rinutils_inc_dir}")
             MESSAGE(FATAL_ERROR "Could not find rinutils anywhere - it should have been bundled in the releases' source tarball.\nYou can try installing it from a source release or from its repository: https://github.com/shlomif/rinutils\n\nAlso see: https://github.com/shlomif/fortune-mod/issues/44")
         ENDIF ()