cmake: Do not require --auto-download for already downloaded dependencies. (#6417)
authorMathias Preiner <mathias.preiner@gmail.com>
Thu, 22 Apr 2021 20:22:36 +0000 (13:22 -0700)
committerGitHub <noreply@github.com>
Thu, 22 Apr 2021 20:22:36 +0000 (20:22 +0000)
This will look for already downloaded dependencies in the build
directory and therefore will not require --auto-download if the
dependencies were already downloaded in a previous build.

CMakeLists.txt
cmake/FindANTLR3.cmake
cmake/FindCLN.cmake
cmake/FindCaDiCaL.cmake
cmake/FindCryptoMiniSat.cmake
cmake/FindGMP.cmake
cmake/FindGTest.cmake
cmake/FindKissat.cmake
cmake/FindPoly.cmake
cmake/FindSymFPU.cmake
cmake/deps-helper.cmake

index 77f9fb5666ca3f79d94b3d7b130bf59cc896d814..1c6ad160414c1f608b502ab0bf8afbac20a10c1f 100644 (file)
@@ -247,7 +247,7 @@ endif()
 # Only enable unit testing if assertions are enabled. Otherwise, unit tests
 # that expect AssertionException to be thrown will fail.
 if(NOT ENABLE_ASSERTIONS)
-  message(WARNING "Disabling unit tests since assertions are disabled.")
+  message(STATUS "Disabling unit tests since assertions are disabled.")
   set(ENABLE_UNIT_TESTING OFF)
 endif()
 
@@ -261,7 +261,7 @@ if(ENABLE_SHARED)
   set(BUILD_SHARED_LIBS ON)
   if(ENABLE_STATIC_BINARY)
     set(ENABLE_STATIC_BINARY OFF)
-    message(WARNING "Disabling static binary since shared build is enabled.")
+    message(STATUS "Disabling static binary since shared build is enabled.")
   endif()
 
   # Set visibility to default if unit tests are enabled
@@ -300,7 +300,7 @@ else()
   # Never build unit tests as static binaries, otherwise we'll end up with
   # ~300MB per unit test.
   if(ENABLE_UNIT_TESTING)
-    message(WARNING "Disabling unit tests since static build is enabled.")
+    message(STATUS "Disabling unit tests since static build is enabled.")
     set(ENABLE_UNIT_TESTING OFF)
   endif()
 
@@ -439,7 +439,7 @@ if(USE_CRYPTOMINISAT)
   if(THREADS_HAVE_PTHREAD_ARG)
     add_c_cxx_flag(-pthread)
   endif()
-  find_package(CryptoMiniSat REQUIRED)
+  find_package(CryptoMiniSat 5.8 REQUIRED)
   add_definitions(-DCVC5_USE_CRYPTOMINISAT)
 endif()
 
index 5429be99adec70249acd03e714591b4156cbd24d..3ed3c537676903506630f63fdd4808b269095d35 100644 (file)
@@ -34,7 +34,11 @@ if(ANTLR3_JAR AND ANTLR3_INCLUDE_DIR AND ANTLR3_RUNTIME)
 endif()
 
 if(NOT ANTLR3_FOUND_SYSTEM)
-    check_auto_download("ANTLR3" "")
+    check_ep_downloaded("ANTLR3-EP-jar")
+    if(NOT ANTLR3-EP-jar_DOWNLOADED)
+      check_auto_download("ANTLR3" "")
+    endif()
+
     include(ExternalProject)
 
     set(ANTLR3_VERSION "3.4")
index 5a2295c4be8ea48c3953d6140abe50a361f83063..b5b37ec59e86f112ea865e70f1102209f00d0e5e 100644 (file)
@@ -34,7 +34,11 @@ if(CLN_INCLUDE_DIR AND CLN_LIBRARIES)
 endif()
 
 if(NOT CLN_FOUND_SYSTEM)
-  check_auto_download("CLN" "--no-cln")
+  check_ep_downloaded("CLN-EP")
+  if(NOT CLN-EP_DOWNLOADED)
+    check_auto_download("CLN" "--no-cln")
+  endif()
+
   include(ExternalProject)
 
   fail_if_cross_compiling("Windows" "" "CLN" "autoconf fails")
index 82737a0ac9fad6599f0609873a6b5d691ec46a7b..7c70a066cfdddc0c24989aed34b6af1cacdb5ff5 100644 (file)
@@ -39,7 +39,11 @@ if(CaDiCaL_INCLUDE_DIR AND CaDiCaL_LIBRARIES)
 endif()
 
 if(NOT CaDiCaL_FOUND_SYSTEM)
-  check_auto_download("CaDiCaL" "--no-cadical")
+  check_ep_downloaded("CaDiCaL-EP")
+  if(NOT CaDiCaL-EP_DOWNLOADED)
+    check_auto_download("CaDiCaL" "--no-cadical")
+  endif()
+
   include(CheckSymbolExists)
   include(ExternalProject)
 
@@ -102,5 +106,4 @@ if(CaDiCaL_FOUND_SYSTEM)
   message(STATUS "Found CaDiCaL ${CaDiCaL_VERSION}: ${CaDiCaL_LIBRARIES}")
 else()
   message(STATUS "Building CaDiCaL ${CaDiCaL_VERSION}: ${CaDiCaL_LIBRARIES}")
-  add_dependencies(CaDiCaL CaDiCaL-EP)
 endif()
index 08cb6f6a12733f898a673755a4b3133773e0a1fa..9599f645fe2b2b44eb2bff8ce7e688adb4b42604 100644 (file)
@@ -22,6 +22,7 @@ find_package(cryptominisat5 ${CryptoMiniSat_FIND_VERSION} QUIET)
 
 set(CryptoMiniSat_FOUND_SYSTEM FALSE)
 if(cryptominisat5_FOUND)
+  set(CryptoMiniSat_VERSION ${cryptominisat5_VERSION})
   set(CryptoMiniSat_FOUND_SYSTEM TRUE)
   add_library(CryptoMiniSat INTERFACE IMPORTED GLOBAL)
   target_link_libraries(CryptoMiniSat INTERFACE cryptominisat5)
@@ -31,15 +32,18 @@ if(cryptominisat5_FOUND)
     CryptoMiniSat PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
                              "${CRYPTOMINISAT5_INCLUDE_DIRS}"
   )
-
 endif()
 
 if(NOT CryptoMiniSat_FOUND_SYSTEM)
-  check_auto_download("CryptoMiniSat" "--no-cryptominisat")
-  include(ExternalProject)
-
   set(CryptoMiniSat_VERSION "5.8.0")
 
+  check_ep_downloaded("CryptoMiniSat-EP")
+  if(NOT CryptoMiniSat-EP_DOWNLOADED)
+    check_auto_download("CryptoMiniSat" "--no-cryptominisat")
+  endif()
+
+  include(ExternalProject)
+
   ExternalProject_Add(
     CryptoMiniSat-EP
     ${COMMON_EP_CONFIG}
index f5447f95db700373325799ef7de6f186f4960e08..c554197b920cdc5378377c9e30502ab2dc73ab94 100644 (file)
@@ -43,7 +43,11 @@ if(GMP_INCLUDE_DIR AND GMP_LIBRARIES)
 endif()
 
 if(NOT GMP_FOUND_SYSTEM)
-  check_auto_download("GMP" "")
+  check_ep_downloaded("GMP-EP")
+  if(NOT GMP-EP_DOWNLOADED)
+    check_auto_download("GMP" "")
+  endif()
+
   include(ExternalProject)
 
   set(GMP_VERSION "6.2.1")
index bc12e44ba8f25d4e30817cd4c1b1b3d8834fd7b6..d36829784805b1a562c7f92bbaaeeb777502bb77 100644 (file)
@@ -25,7 +25,11 @@ if(GTest_INCLUDE_DIR AND GTest_LIBRARIES AND GTest_MAIN_LIBRARIES)
 endif()
 
 if(NOT GTest_FOUND_SYSTEM)
-    check_auto_download("GTest" "")
+    check_ep_downloaded("GTest-EP")
+    if(NOT GTest-EP_DOWNLOADED)
+      check_auto_download("GTest" "")
+    endif()
+
     include(ExternalProject)
 
     set(GTest_VERSION "1.10.0")
index 62aa5eeec8ef0472db585f0e00aeed866162f50d..08b214961454133d474bf481804d1f7cb4b1e4e2 100644 (file)
@@ -39,7 +39,11 @@ if(Kissat_INCLUDE_DIR AND Kissat_LIBRARIES)
 endif()
 
 if(NOT Kissat_FOUND_SYSTEM)
-  check_auto_download("Kissat" "--no-kissat")
+  check_ep_downloaded("Kissat-EP")
+  if(NOT Kissat-EP_DOWNLOADED)
+    check_auto_download("Kissat" "--no-kissat")
+  endif()
+
   include(ExternalProject)
 
   fail_if_include_missing("sys/resource.h" "Kissat")
index 2030ca8067bdf86b7e19d86f9b170b05e5bad73e..0a5780585f2022f1bf069b7f112f306192f89b8c 100644 (file)
@@ -38,7 +38,11 @@ if(Poly_INCLUDE_DIR
 endif()
 
 if(NOT Poly_FOUND_SYSTEM)
-  check_auto_download("Poly" "--no-poly")
+  check_ep_downloaded("Poly-EP")
+  if(NOT Poly-EP_DOWNLOADED)
+    check_auto_download("Poly" "--no-poly")
+  endif()
+
   include(ExternalProject)
 
   set(Poly_VERSION "0.1.9")
index be5b1eacbc4136529b788d951b126fa4b7ec3107..5a2ac5111b777592a060bbad15d2953d15c67fce 100644 (file)
@@ -24,7 +24,11 @@ if(SymFPU_INCLUDE_DIR)
 endif()
 
 if(NOT SymFPU_FOUND_SYSTEM)
-  check_auto_download("SymFPU" "--no-symfpu")
+  check_ep_downloaded("SymFPU-EP")
+  if(NOT SymFPU-EP_DOWNLOADED)
+    check_auto_download("SymFPU" "--no-symfpu")
+  endif()
+
   include(ExternalProject)
   include(deps-helper)
 
index f044c270635fc562595bb50aa563ba3594ba0ff7..f37ccb1f2d082690fca427c4e77809c25a3003c2 100644 (file)
@@ -47,11 +47,11 @@ macro(check_auto_download name disable_option)
             set(depname "${name}")
         endif()
         if("${disable_option}" STREQUAL "")
-            message(FATAL_ERROR "Could not find the required dependency
+            message(FATAL_ERROR "Could not find the required dependency \
 ${depname} in the system. Please install it yourself or use --auto-download to \
 let us download and build it for you.")
         else()
-            message(FATAL_ERROR "Could not find the optional dependency
+            message(FATAL_ERROR "Could not find the optional dependency \
 ${depname} in the system. You can disable this dependency with \
 ${disable_option}, install it yourself or use --auto-download to let us \
 download and build it for you.")
@@ -59,6 +59,16 @@ download and build it for you.")
     endif()
 endmacro(check_auto_download)
 
+# Check if the given external project was already set up in a previous
+# configure call.
+macro(check_ep_downloaded name)
+  if(EXISTS "${DEPS_PREFIX}/src/${name}")
+    set(${name}_DOWNLOADED TRUE)
+  else()
+    set(${name}_DOWNLOADED FALSE)
+  endif()
+endmacro()
+
 macro(check_system_version name)
     # find_package sets this variable when called with a version
     # https://cmake.org/cmake/help/latest/command/find_package.html#version-selection