From 2aab6ea4c8455f80a2bb08bc88fdb919a79a010f Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Thu, 22 Apr 2021 13:22:36 -0700 Subject: [PATCH] cmake: Do not require --auto-download for already downloaded dependencies. (#6417) 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 | 8 ++++---- cmake/FindANTLR3.cmake | 6 +++++- cmake/FindCLN.cmake | 6 +++++- cmake/FindCaDiCaL.cmake | 7 +++++-- cmake/FindCryptoMiniSat.cmake | 12 ++++++++---- cmake/FindGMP.cmake | 6 +++++- cmake/FindGTest.cmake | 6 +++++- cmake/FindKissat.cmake | 6 +++++- cmake/FindPoly.cmake | 6 +++++- cmake/FindSymFPU.cmake | 6 +++++- cmake/deps-helper.cmake | 14 ++++++++++++-- 11 files changed, 64 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77f9fb566..1c6ad1604 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/FindANTLR3.cmake b/cmake/FindANTLR3.cmake index 5429be99a..3ed3c5376 100644 --- a/cmake/FindANTLR3.cmake +++ b/cmake/FindANTLR3.cmake @@ -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") diff --git a/cmake/FindCLN.cmake b/cmake/FindCLN.cmake index 5a2295c4b..b5b37ec59 100644 --- a/cmake/FindCLN.cmake +++ b/cmake/FindCLN.cmake @@ -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") diff --git a/cmake/FindCaDiCaL.cmake b/cmake/FindCaDiCaL.cmake index 82737a0ac..7c70a066c 100644 --- a/cmake/FindCaDiCaL.cmake +++ b/cmake/FindCaDiCaL.cmake @@ -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() diff --git a/cmake/FindCryptoMiniSat.cmake b/cmake/FindCryptoMiniSat.cmake index 08cb6f6a1..9599f645f 100644 --- a/cmake/FindCryptoMiniSat.cmake +++ b/cmake/FindCryptoMiniSat.cmake @@ -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} diff --git a/cmake/FindGMP.cmake b/cmake/FindGMP.cmake index f5447f95d..c554197b9 100644 --- a/cmake/FindGMP.cmake +++ b/cmake/FindGMP.cmake @@ -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") diff --git a/cmake/FindGTest.cmake b/cmake/FindGTest.cmake index bc12e44ba..d36829784 100644 --- a/cmake/FindGTest.cmake +++ b/cmake/FindGTest.cmake @@ -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") diff --git a/cmake/FindKissat.cmake b/cmake/FindKissat.cmake index 62aa5eeec..08b214961 100644 --- a/cmake/FindKissat.cmake +++ b/cmake/FindKissat.cmake @@ -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") diff --git a/cmake/FindPoly.cmake b/cmake/FindPoly.cmake index 2030ca806..0a5780585 100644 --- a/cmake/FindPoly.cmake +++ b/cmake/FindPoly.cmake @@ -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") diff --git a/cmake/FindSymFPU.cmake b/cmake/FindSymFPU.cmake index be5b1eacb..5a2ac5111 100644 --- a/cmake/FindSymFPU.cmake +++ b/cmake/FindSymFPU.cmake @@ -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) diff --git a/cmake/deps-helper.cmake b/cmake/deps-helper.cmake index f044c2706..f37ccb1f2 100644 --- a/cmake/deps-helper.cmake +++ b/cmake/deps-helper.cmake @@ -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 -- 2.30.2