Refactor CLN dependency & Cleanup (#6251)
authorGereon Kremer <gereon.kremer@cs.rwth-aachen.de>
Thu, 1 Apr 2021 18:20:53 +0000 (20:20 +0200)
committerGitHub <noreply@github.com>
Thu, 1 Apr 2021 18:20:53 +0000 (18:20 +0000)
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.

19 files changed:
CMakeLists.txt
cmake/FindANTLR3.cmake
cmake/FindCLN.cmake
cmake/FindCaDiCaL.cmake
cmake/FindCryptoMiniSat.cmake
cmake/FindDummy.cmake.template
cmake/FindGMP.cmake
cmake/FindGTest.cmake
cmake/FindKissat.cmake
cmake/FindPoly.cmake
cmake/FindSymFPU.cmake
cmake/deps-helper.cmake
cmake/deps-utils/Poly-patch-cmake.patch [new file with mode: 0644]
configure.sh
src/CMakeLists.txt
src/api/python/CMakeLists.txt
src/main/CMakeLists.txt
test/api/CMakeLists.txt
test/unit/CMakeLists.txt

index a8c1e2e0d65f0ad793ef155f4e9b0c52304e07b5..c6909d216e313649066cdf50e3f447f29455a8ea 100644 (file)
@@ -61,27 +61,9 @@ endif()
 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")
@@ -148,13 +130,7 @@ option(USE_PYTHON2            "Force Python 2 (deprecated)")
 # 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")
@@ -341,7 +317,7 @@ else()
   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,
@@ -686,28 +662,9 @@ message("")
 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}")
index 58ba1cf65f4499bbbc8f0f63587275a48a2dab70..76e5253fe24de107ed4a62288ede4bcd0a658b13 100644 (file)
@@ -38,7 +38,7 @@ if(NOT ANTLR3_FOUND_SYSTEM)
     # 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
@@ -53,7 +53,7 @@ if(NOT ANTLR3_FOUND_SYSTEM)
     # 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
@@ -72,16 +72,14 @@ if(NOT ANTLR3_FOUND_SYSTEM)
     # 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
index aeb84dceaca8f68c7108091c12d0f2acb0a97c0e..25ca903af9a3f3f19465fcdd66973795ba8743ba 100644 (file)
 # 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()
index b9894a16d3f849e66f8b983f184653aa66073440..c8490b8cabeabc4867bd74c68ecf74d1e0cd852f 100644 (file)
@@ -55,7 +55,7 @@ if(NOT CaDiCaL_FOUND_SYSTEM)
 
   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
index 31890779728f6b0aeb8ba244605e3346da731d2d..92b351ef236176a3fbde100e05a795a190f435ba 100644 (file)
@@ -38,7 +38,7 @@ if(NOT CryptoMiniSat_FOUND_SYSTEM)
 
   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
index ecb7f672bfc5e06c62732df225509938203db024..f339e4f0426bb12e61c9523865d644cbfd4c32e2 100644 (file)
@@ -55,13 +55,13 @@ if(NOT Dummy_FOUND_SYSTEM)
     # 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
index 7e81dfd191dd950916c1ecfebfcb5dd8716b2fcf..59262593ddd4a50920d0da54894969d9543d431d 100644 (file)
@@ -34,7 +34,6 @@ if(GMP_INCLUDE_DIR AND GMP_LIBRARIES)
   getversionpart(PATCH "${GMP_INCLUDE_DIR}/gmp.h" "VERSION_PATCHLEVEL")
   set(GMP_VERSION
       "${MAJOR}.${MINOR}.${PATCH}"
-      PARENT_SCOPE
   )
 
   check_system_version("GMP")
@@ -47,7 +46,7 @@ if(NOT GMP_FOUND_SYSTEM)
 
   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
index 786a51b356294b39173baefa1754c2c0567d1076..401f6d9a31bad8d3508f44c6b4743f6554fb5922 100644 (file)
@@ -29,7 +29,7 @@ if(NOT GTest_FOUND_SYSTEM)
 
     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
index e71a64eea5b1f4a8b410de4f69934a5509b029cc..f469f0197d3c5c4975cc38bb8185e2c2d63b74a2 100644 (file)
@@ -45,7 +45,7 @@ if(NOT Kissat_FOUND_SYSTEM)
 
   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
index 3556a9d63f9ad1af4d5ad26529aac468c012dc2f..1bbb9fa65d68fda4c93569a5d5246f20d3f656f0 100644 (file)
@@ -19,7 +19,7 @@ find_path(Poly_INCLUDE_DIR NAMES poly/poly.h)
 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
@@ -65,7 +65,7 @@ if(NOT Poly_FOUND_SYSTEM)
 
   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
index da8beac994a77fe570d7ab8737f4fee1cbf2854b..0a1d41c1a6c2a31fa25895960ab47080b4c4be7d 100644 (file)
@@ -26,7 +26,7 @@ else()
 
   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 ""
index 4b88d62ce20e4b2b22f7278bd6d09688363a3667..4de54e9eabe2f9ebdf438b087d1ccf254ac83f83 100644 (file)
@@ -6,6 +6,22 @@ set(DEPS_BASE "${CMAKE_BINARY_DIR}/deps")
 # (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
diff --git a/cmake/deps-utils/Poly-patch-cmake.patch b/cmake/deps-utils/Poly-patch-cmake.patch
new file mode 100644 (file)
index 0000000..fe8528f
--- /dev/null
@@ -0,0 +1,13 @@
+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
index 6e54caa096df586219bb8f0bee72cb6b1802a062..63d40403a913f3992eee4c6fb9553fc5c6410384 100755 (executable)
@@ -328,18 +328,6 @@ do
   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
index 2679f607242ed6cbf334561941d8bb22c1a78ef0..490d335a2401f31b9d6d5e3132550dbfdbeb4632 100644 (file)
@@ -1134,8 +1134,7 @@ if(USE_CADICAL)
   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)
index 62482a0ba424da7c3a723e8da54923e83e74c457..ec156e50e4e4b17217e7eb058c8e9957a0ec0d5a 100644 (file)
@@ -36,7 +36,7 @@ add_custom_target(
     --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}"
 )
index 2d2b08378ac272b9893ac706ab0741e497aec0b8..fd2d415b2dc064e0bb8173ab83f5c67752d7d06f 100644 (file)
@@ -41,22 +41,20 @@ add_dependencies(main cvc4 cvc4parser gen-tokens)
 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
@@ -67,12 +65,11 @@ set_target_properties(cvc4-bin
   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>
@@ -94,9 +91,9 @@ if(ENABLE_STATIC_BINARY)
 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()
 
 #-----------------------------------------------------------------------------#
index 1deea4a87de4354e52ee5f597aaaf195447f22a6..18c366a456c4c957c0e106681b6e8aa17981c9ba 100644 (file)
@@ -30,13 +30,12 @@ set(CVC4_API_TEST_FLAGS
 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})
index 7b82f334637fb3a9e8e97ab223b9f639d4e3c16d..0be0b80e1e80c0c1d2e2c22b4f92eca73d8738da 100644 (file)
@@ -37,18 +37,17 @@ macro(cvc4_add_unit_test is_white name output_dir)
   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()