This PR migrates CLN to a new Find script and adds the possibility to install CLN if not found in the system.
Also, it does a bit of cleanup.
if(ABC_DIR)
list(APPEND CMAKE_PREFIX_PATH "${ABC_DIR}")
endif()
-if(CADICAL_DIR)
- list(APPEND CMAKE_PREFIX_PATH "${CADICAL_DIR}")
-endif()
-if(CRYPTOMINISAT_DIR)
- list(APPEND CMAKE_PREFIX_PATH "${CRYPTOMINISAT_DIR}")
-endif()
if(GLPK_DIR)
list(APPEND CMAKE_PREFIX_PATH "${GLPK_DIR}")
endif()
-if(GMP_DIR)
- list(APPEND CMAKE_PREFIX_PATH "${GMP_DIR}")
-endif()
-if(KISSAT_DIR)
- list(APPEND CMAKE_PREFIX_PATH "${KISSAT_DIR}")
-endif()
-if(POLY_DIR)
- list(APPEND CMAKE_PREFIX_PATH "${POLY_DIR}")
-endif()
-if(SYMFPU_DIR)
- list(APPEND CMAKE_PREFIX_PATH "${SYMFPU_DIR}")
-endif()
# By default the contrib/get-* scripts install dependencies to deps/install.
list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/deps/install")
# check the intalled system version. If the user provides a directory we
# immediately fail if the dependency was not found at the specified location.
set(ABC_DIR "" CACHE STRING "Set ABC install directory")
-set(CADICAL_DIR "" CACHE STRING "Set CaDiCaL install directory")
-set(CRYPTOMINISAT_DIR "" CACHE STRING "Set CryptoMiniSat install directory")
set(GLPK_DIR "" CACHE STRING "Set GLPK install directory")
-set(GMP_DIR "" CACHE STRING "Set GMP install directory")
-set(KISSAT_DIR "" CACHE STRING "Set Kissat install directory")
-set(POLY_DIR "" CACHE STRING "Set LibPoly install directory")
-set(SYMFPU_DIR "" CACHE STRING "Set SymFPU install directory")
# Prepend binaries with prefix on make install
set(PROGRAM_PREFIX "" CACHE STRING "Program prefix on make install")
find_package(PythonInterp 3 REQUIRED)
endif()
-find_package(GMP REQUIRED)
+find_package(GMP 6.2 REQUIRED)
if(ENABLE_ASAN)
# -fsanitize=address requires CMAKE_REQUIRED_FLAGS to be explicitely set,
if(ABC_DIR)
print_config("ABC dir " ${ABC_DIR})
endif()
-if(CADICAL_DIR)
- print_config("CADICAL dir " ${CADICAL_DIR})
-endif()
-if(CRYPTOMINISAT_DIR)
- print_config("CRYPTOMINISAT dir " ${CRYPTOMINISAT_DIR})
-endif()
if(GLPK_DIR)
print_config("GLPK dir " ${GLPK_DIR})
endif()
-if(GMP_DIR)
- print_config("GMP dir " ${GMP_DIR})
-endif()
-if(KISSAT_DIR)
- print_config("KISSAT dir " ${KISSAT_DIR})
-endif()
-if(POLY_DIR)
- print_config("LibPoly dir " ${POLY_DIR})
-endif()
-if(SYMFPU_DIR)
- print_config("SYMFPU dir " ${SYMFPU_DIR})
-endif()
-print_config("asdf" "")
message("")
print_config("CPPLAGS (-D...)" "${CVC4_DEFINITIONS}")
print_config("CXXFLAGS " "${CMAKE_CXX_FLAGS}")
# Download antlr generator jar
ExternalProject_Add(
ANTLR3-EP-jar
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://www.antlr3.org/download/antlr-${ANTLR3_VERSION}-complete.jar
URL_HASH SHA1=5cab59d859caa6598e28131d30dd2e89806db57f
DOWNLOAD_NO_EXTRACT ON
# Download config guess
ExternalProject_Add(
ANTLR3-EP-config.guess
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL "http://git.savannah.gnu.org/gitweb/?p=config.git\\\;a=blob_plain\\\;f=config.guess\\\;hb=HEAD"
DOWNLOAD_NAME config.guess
DOWNLOAD_NO_EXTRACT ON
# Download, build and install antlr3 runtime
ExternalProject_Add(
ANTLR3-EP-runtime
+ ${COMMON_EP_CONFIG}
DEPENDS ANTLR3-EP-config.guess
- PREFIX ${DEPS_PREFIX}
URL https://www.antlr3.org/download/C/libantlr3c-3.4.tar.gz
URL_HASH SHA1=faa9ab43ab4d3774f015471c3f011cc247df6a18
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
<SOURCE_DIR>/../config.guess <SOURCE_DIR>/config.guess
- COMMAND sed "s/avr32 \\\\/avr32 | aarch64 \\\\/"
- <SOURCE_DIR>/config.sub > <SOURCE_DIR>/config.sub.new
- COMMAND ${CMAKE_COMMAND} -E copy
- <SOURCE_DIR>/config.sub.new <SOURCE_DIR>/config.sub
+ COMMAND sed -i.orig "s/avr | avr32/avr | aarch64 | avr32/"
+ <SOURCE_DIR>/config.sub
COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR>/include include/
COMMAND <SOURCE_DIR>/configure
--with-pic
# CLN_INCLUDE_DIR - the CLN include directory
# CLN_LIBRARIES - Libraries needed to use CLN
+include(deps-helper)
+
find_path(CLN_INCLUDE_DIR NAMES cln/cln.h)
find_library(CLN_LIBRARIES NAMES cln)
+set(CLN_FOUND_SYSTEM FALSE)
+if(CLN_INCLUDE_DIR AND CLN_LIBRARIES)
+ set(CLN_FOUND_SYSTEM TRUE)
+
+ file(STRINGS ${CLN_INCLUDE_DIR}/cln/version.h CLN_VERSION
+ REGEX "^#define[\t ]+CL_VERSION .*"
+ )
+ string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CLN_VERSION "${CLN_VERSION}")
+
+ check_system_version("CLN")
+endif()
+
+if(NOT CLN_FOUND_SYSTEM)
+ include(ExternalProject)
+
+ fail_if_cross_compiling("Windows" "" "CLN" "autoconf fails")
+ fail_if_cross_compiling("" "arm" "CLN" "syntax error in configure")
+
+ set(CLN_VERSION "1.3.6")
+ string(REPLACE "." "-" CLN_TAG ${CLN_VERSION})
-if(CLN_INCLUDE_DIR)
- file(STRINGS
- "${CLN_INCLUDE_DIR}/cln/version.h" version_info
- REGEX "^#define[ \t]+CL_VERSION_.*")
- string(REGEX REPLACE
- "^.*_MAJOR[ \t]+([0-9]+).*" "\\1" version_major "${version_info}")
- string(REGEX REPLACE
- "^.*_MINOR[ \t]+([0-9]+).*" "\\1" version_minor "${version_info}")
- string(REGEX REPLACE
- "^.*_PATCHLEVEL[ \t]+([0-9]+).*" "\\1" version_patch "${version_info}")
- set(CLN_VERSION ${version_major}.${version_minor}.${version_patch})
-
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(CLN
- REQUIRED_VARS CLN_INCLUDE_DIR CLN_LIBRARIES
- VERSION_VAR CLN_VERSION)
- mark_as_advanced(CLN_INCLUDE_DIR CLN_LIBRARIES)
+ find_program(AUTORECONF autoreconf)
+ if(NOT AUTORECONF)
+ message(SEND_ERROR "Can not build CLN, missing binary for autoreconf")
+ endif()
+
+ ExternalProject_Add(
+ CLN-EP
+ ${COMMON_EP_CONFIG}
+ URL "https://www.ginac.de/CLN/cln.git/?p=cln.git\\\;a=snapshot\\\;h=cln_${CLN_TAG}\\\;sf=tgz"
+ URL_HASH SHA1=71d02b90ef0575f06b7bafb8690f73e8064d8228
+ DOWNLOAD_NAME cln.tgz
+ CONFIGURE_COMMAND cd <SOURCE_DIR> && ./autogen.sh && autoreconf -iv
+ COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-shared
+ --enable-static --with-pic
+ BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libcln.a
+ )
+
+ add_dependencies(CLN-EP GMP)
+
+ set(CLN_INCLUDE_DIR "${DEPS_BASE}/include/")
+ set(CLN_LIBRARIES "${DEPS_BASE}/lib/libcln.a")
endif()
-if(CLN_LIBRARIES)
- message(STATUS "Found CLN libs: ${CLN_LIBRARIES}")
+
+set(CLN_FOUND TRUE)
+
+add_library(CLN STATIC IMPORTED GLOBAL)
+set_target_properties(CLN PROPERTIES IMPORTED_LOCATION "${CLN_LIBRARIES}")
+set_target_properties(
+ CLN PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CLN_INCLUDE_DIR}"
+)
+
+mark_as_advanced(AUTORECONF)
+mark_as_advanced(CLN_FOUND)
+mark_as_advanced(CLN_FOUND_SYSTEM)
+mark_as_advanced(CLN_INCLUDE_DIR)
+mark_as_advanced(CLN_LIBRARIES)
+
+if(CLN_FOUND_SYSTEM)
+ message(STATUS "Found CLN ${CLN_VERSION}: ${CLN_LIBRARIES}")
+else()
+ message(STATUS "Building CLN ${CLN_VERSION}: ${CLN_LIBRARIES}")
+ add_dependencies(CLN CLN-EP)
endif()
ExternalProject_Add(
CaDiCaL-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
BUILD_IN_SOURCE ON
URL https://github.com/arminbiere/cadical/archive/refs/tags/rel-${CaDiCaL_VERSION}.tar.gz
URL_HASH SHA1=9de1176737b74440921ba86395fe5edbb3b131eb
ExternalProject_Add(
CryptoMiniSat-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://github.com/msoos/cryptominisat/archive/refs/tags/${CryptoMiniSat_VERSION}.tar.gz
URL_HASH SHA1=f79dfa1ffc6c9c75b3a33f76d3a89a3df2b3f4c2
PATCH_COMMAND
# declare some release, version, tag, commit
set(Dummy_VERSION "1.2.3")
# do whatever is necessary
- # - set the proper install prefix
+ # - use some common config
# - prefer URL to GIT (to avoid rebuilds)
# - only build / install static versions if possible
# - pass ${TOOLCHAIN_PREFIX}
ExternalProject_Add(
Dummy-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://dummy.org/download/dummy-${Dummy_VERSION}.tar.bz2
URL_HASH SHA1=abc123
CMAKE_ARGS
getversionpart(PATCH "${GMP_INCLUDE_DIR}/gmp.h" "VERSION_PATCHLEVEL")
set(GMP_VERSION
"${MAJOR}.${MINOR}.${PATCH}"
- PARENT_SCOPE
)
check_system_version("GMP")
ExternalProject_Add(
GMP-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2
URL_HASH SHA1=2dcf34d4a432dbe6cce1475a835d20fe44f75822
CONFIGURE_COMMAND
ExternalProject_Add(
GTest-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://github.com/google/googletest/archive/refs/tags/release-${GTest_VERSION}.tar.gz
URL_HASH SHA1=9c89be7df9c5e8cb0bc20b3c4b39bf7e82686770
DOWNLOAD_NAME gtest.tar.gz
ExternalProject_Add(
Kissat-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
BUILD_IN_SOURCE ON
URL http://fmv.jku.at/kissat/kissat-${Kissat_VERSION}.tar.xz
URL_HASH SHA1=5125efa17d383c7e7c1e6d803e3422b17cebcedb
find_library(Poly_LIBRARIES NAMES poly)
find_library(PolyXX_LIBRARIES NAMES polyxx)
-set(Dummy_FOUND_SYSTEM FALSE)
+set(Poly_FOUND_SYSTEM FALSE)
if(Poly_INCLUDE_DIR
AND Poly_LIBRARIES
AND PolyXX_LIBRARIES
ExternalProject_Add(
Poly-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://github.com/SRI-CSL/libpoly/archive/${Poly_VERSION}.tar.gz
URL_HASH SHA1=2e79d5220d3ecbb40811463fcf12c5ddbd4b9f30
DOWNLOAD_NAME libpoly.tar.gz
ExternalProject_Add(
SymFPU-EP
- PREFIX ${DEPS_PREFIX}
+ ${COMMON_EP_CONFIG}
URL https://github.com/martin-cs/symfpu/archive/${SymFPU_COMMIT}.tar.gz
URL_HASH SHA1=9e00045130b93e3c2a46ce73a1b5b6451340dc46
CONFIGURE_COMMAND ""
# (and similar) to exist when target property is set.
file(MAKE_DIRECTORY "${DEPS_BASE}/include/")
+set(COMMON_EP_CONFIG
+ PREFIX ${DEPS_PREFIX}
+ LOG_DOWNLOAD ON
+ LOG_UPDATE ON
+ LOG_CONFIGURE ON
+ LOG_BUILD ON
+ LOG_INSTALL ON
+)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.14")
+ set(COMMON_EP_CONFIG ${COMMON_EP_CONFIG}
+ LOG_PATCH ON
+ LOG_MERGED_STDOUTERR ON
+ LOG_OUTPUT_ON_FAILURE ON
+ )
+endif()
+
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
--- /dev/null
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index f91e3e8..6205689 100755
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -38,7 +38,7 @@ set(poly_SOURCES
+ )
+
+ if (NOT HAVE_OPEN_MEMSTREAM)
+- set(poly_SOURCES "utils/open_memstream.c ${poly_SOURCES}")
++ set(poly_SOURCES utils/open_memstream.c ${poly_SOURCES})
+ endif()
+
+ set(polyxx_SOURCES
shift
done
-#--------------------------------------------------------------------------#
-# Automatically set up dependencies based on configure options
-#--------------------------------------------------------------------------#
-
-if [ "$arm64" == "ON" ]; then
- echo "Setting up dependencies for ARM 64-bit build"
- contrib/get-gmp-dev --host=aarch64-linux-gnu || exit 1
-elif [ "$win64" == "ON" ]; then
- echo "Setting up dependencies for Windows 64-bit build"
- contrib/get-gmp-dev --host=x86_64-w64-mingw32 || exit 1
-fi
-
#--------------------------------------------------------------------------#
if [ $werror != default ]; then
target_link_libraries(cvc4 PRIVATE CaDiCaL)
endif()
if(USE_CLN)
- target_link_libraries(cvc4 PRIVATE ${CLN_LIBRARIES})
- target_include_directories(cvc4 PRIVATE $<BUILD_INTERFACE:${CLN_INCLUDE_DIR}>)
+ target_link_libraries(cvc4 PRIVATE CLN)
endif()
if(USE_CRYPTOMINISAT)
target_link_libraries(cvc4 PRIVATE CryptoMiniSat)
--kinds-header "${PROJECT_SOURCE_DIR}/src/api/cvc4cppkind.h"
--kinds-file-prefix "${CMAKE_CURRENT_BINARY_DIR}/cvc4kinds"
DEPENDS
- genkinds.py
+ "${CMAKE_CURRENT_BINARY_DIR}/genkinds.py"
COMMENT
"Generate cvc4kinds.{pxd,pyx}"
)
get_target_property(LIBCVC4_INCLUDES cvc4 INCLUDE_DIRECTORIES)
target_include_directories(main PRIVATE ${LIBCVC4_INCLUDES})
if(USE_CLN)
- target_link_libraries(main ${CLN_LIBRARIES})
- target_include_directories(main PRIVATE $<BUILD_INTERFACE:${CLN_INCLUDE_DIR}>)
+ target_link_libraries(main PUBLIC CLN)
endif()
-target_link_libraries(main GMP)
+target_link_libraries(main PUBLIC GMP)
# main-test library is only used for linking against api and unit tests so
# that we don't have to include all object files of main into each api/unit
# test. Do not link against main-test in any other case.
add_library(main-test driver_unified.cpp $<TARGET_OBJECTS:main>)
target_compile_definitions(main-test PRIVATE -D__BUILDING_CVC4DRIVER)
-target_link_libraries(main-test cvc4 cvc4parser)
+target_link_libraries(main-test PUBLIC cvc4 cvc4parser)
if(USE_CLN)
- target_link_libraries(main-test ${CLN_LIBRARIES})
- target_include_directories(main-test PRIVATE $<BUILD_INTERFACE:${CLN_INCLUDE_DIR}>)
+ target_link_libraries(main-test PUBLIC CLN)
endif()
-target_link_libraries(main-test GMP)
+target_link_libraries(main-test PUBLIC GMP)
#-----------------------------------------------------------------------------#
# cvc4 binary configuration
PROPERTIES
OUTPUT_NAME cvc4
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
-target_link_libraries(cvc4-bin cvc4 cvc4parser)
+target_link_libraries(cvc4-bin PUBLIC cvc4 cvc4parser)
if(USE_CLN)
- target_link_libraries(cvc4-bin ${CLN_LIBRARIES})
- target_include_directories(cvc4-bin PRIVATE $<BUILD_INTERFACE:${CLN_INCLUDE_DIR}>)
+ target_link_libraries(cvc4-bin PUBLIC CLN)
endif()
-target_link_libraries(cvc4-bin GMP)
+target_link_libraries(cvc4-bin PUBLIC GMP)
if(PROGRAM_PREFIX)
install(PROGRAMS
$<TARGET_FILE:cvc4-bin>
endif()
if(USE_EDITLINE)
- target_link_libraries(cvc4-bin ${Editline_LIBRARIES})
- target_link_libraries(main-test ${Editline_LIBRARIES})
- target_include_directories(main PRIVATE ${Editline_INCLUDE_DIRS})
+ target_link_libraries(cvc4-bin PUBLIC ${Editline_LIBRARIES})
+ target_link_libraries(main-test PUBLIC ${Editline_LIBRARIES})
+ target_include_directories(main PUBLIC ${Editline_INCLUDE_DIRS})
endif()
#-----------------------------------------------------------------------------#
macro(cvc4_add_api_test name)
set(test_bin_dir ${CMAKE_BINARY_DIR}/bin/test/api/)
add_executable(${name} ${name}.cpp)
- target_link_libraries(${name} main-test)
+ target_link_libraries(${name} PUBLIC main-test)
target_compile_definitions(${name} PRIVATE ${CVC4_API_TEST_FLAGS})
if(USE_CLN)
- target_link_libraries(${name} ${CLN_LIBRARIES})
- target_include_directories(${name} PRIVATE $<BUILD_INTERFACE:${CLN_INCLUDE_DIR}>)
+ target_link_libraries(${name} PRIVATE CLN)
endif()
- target_link_libraries(${name} GMP)
+ target_link_libraries(${name} PRIVATE GMP)
set_target_properties(${name}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${test_bin_dir})
add_test(api/${name} ${test_bin_dir}/${name})
add_executable(${name} ${test_src})
target_compile_definitions(${name} PRIVATE ${CVC4_UNIT_TEST_FLAGS_BLACK})
gtest_add_tests(TARGET ${name})
- target_link_libraries(${name} main-test)
- target_link_libraries(${name} GTest::Main)
- target_link_libraries(${name} GTest::GTest)
+ target_link_libraries(${name} PUBLIC main-test)
+ target_link_libraries(${name} PUBLIC GTest::Main)
+ target_link_libraries(${name} PUBLIC GTest::GTest)
if(USE_CLN)
- target_link_libraries(${name} ${CLN_LIBRARIES})
- target_include_directories(${name} PRIVATE $<BUILD_INTERFACE:${CLN_INCLUDE_DIR}>)
+ target_link_libraries(${name} PUBLIC CLN)
endif()
if(USE_POLY)
- target_link_libraries(${name} Polyxx)
+ target_link_libraries(${name} PUBLIC Polyxx)
endif()
- target_link_libraries(${name} GMP)
+ target_link_libraries(${name} PUBLIC GMP)
if(${is_white})
target_compile_options(${name} PRIVATE -fno-access-control)
endif()