Use separate CMake project for CVC4 examples. (#3196)
authorMathias Preiner <mathias.preiner@gmail.com>
Wed, 25 Sep 2019 16:47:12 +0000 (09:47 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2019 16:47:12 +0000 (09:47 -0700)
50 files changed:
.travis.yml
CMakeLists.txt
cmake/CVC4Config.cmake.in
examples/CMakeLists.txt
examples/README [deleted file]
examples/README.md [new file with mode: 0644]
examples/SimpleVC.java
examples/api/CMakeLists.txt
examples/api/bitvectors-new.cpp
examples/api/bitvectors.cpp
examples/api/bitvectors_and_arrays-new.cpp
examples/api/bitvectors_and_arrays.cpp
examples/api/combination-new.cpp
examples/api/combination.cpp
examples/api/datatypes-new.cpp
examples/api/datatypes.cpp
examples/api/extract-new.cpp
examples/api/extract.cpp
examples/api/helloworld-new.cpp
examples/api/helloworld.cpp
examples/api/java/CMakeLists.txt
examples/api/linear_arith-new.cpp
examples/api/linear_arith.cpp
examples/api/sets-new.cpp
examples/api/sets.cpp
examples/api/strings-new.cpp
examples/api/strings.cpp
examples/hashsmt/CMakeLists.txt
examples/hashsmt/sha1_collision.cpp
examples/hashsmt/sha1_inversion.cpp
examples/hashsmt/word.cpp
examples/hashsmt/word.h
examples/nra-translate/CMakeLists.txt
examples/nra-translate/normalize.cpp
examples/nra-translate/smt2info.cpp
examples/nra-translate/smt2todreal.cpp
examples/nra-translate/smt2toisat.cpp
examples/nra-translate/smt2tomathematica.cpp
examples/nra-translate/smt2toqepcad.cpp
examples/nra-translate/smt2toredlog.cpp
examples/sets-translate/CMakeLists.txt
examples/sets-translate/sets_translate.cpp
examples/simple_vc_cxx.cpp
examples/simple_vc_quant_cxx.cpp
examples/translator.cpp
src/CMakeLists.txt
src/bindings/java/CMakeLists.txt
src/main/CMakeLists.txt
src/parser/CMakeLists.txt
test/CMakeLists.txt

index d4de3576c0297fde5748b4d947b657ffaac01be4..64dd17c75b25d5ccc713f7beaf67d3d0d03e3b6c 100644 (file)
@@ -59,7 +59,13 @@ script:
    makeCheck() {
      cd build
      make -j2 check ARGS='-LE regress[1-4]' CVC4_REGRESSION_ARGS='--no-early-exit' || error "BUILD/UNIT/SYSTEM/REGRESSION TEST FAILED"
-     ctest -j2 -L example || error "RUNNING EXAMPLES FAILED"
+   }
+   makeExamples() {
+     cd examples
+     mkdir build
+     cd build
+     cmake .. -DCMAKE_PREFIX_PATH=$(pwd)/../../build/install/lib/cmake
+     ctest -j2 --output-on-failure || error "RUNNING EXAMPLES FAILED"
    }
    makeInstallCheck() {
      cd build
@@ -78,7 +84,7 @@ script:
    [ -n "$TRAVIS_CVC4" ] && [ -n "$TRAVIS_WITH_LFSC" ] && run contrib/get-lfsc-checker
    [ -n "$TRAVIS_CVC4" ] && run configureCVC4
    [ -n "$TRAVIS_CVC4" ] && run makeCheck
-   [ -z "$CVC4_SYMFPU_BUILD" ] && run makeInstallCheck
+   [ -z "$CVC4_SYMFPU_BUILD" ] && run makeInstallCheck && run makeExamples
    [ -z "$TRAVIS_CVC4" ] && error "Unknown Travis-CI configuration"
    echo "travis_fold:end:load_script"
  - echo; echo "${green}EVERYTHING SEEMED TO PASS!${normal}"
index b6bc5b45208cfa833f49c5da65f6e3769ad49907..706ef51f2f0d369078cd796fde53369e9bb6981b 100644 (file)
@@ -31,6 +31,14 @@ set(CMAKE_CXX_STANDARD 11)
 # plugins.
 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
+#-----------------------------------------------------------------------------#
+
+set(INCLUDE_INSTALL_DIR include)
+set(LIBRARY_INSTALL_DIR lib)
+set(RUNTIME_INSTALL_DIR bin)
+
+#-----------------------------------------------------------------------------#
+
 # Embed the installation prefix as an RPATH in the executable such that the
 # linker can find our libraries (such as libcvc4parser) when executing the cvc4
 # binary. This is for example useful when installing CVC4 with a custom prefix
@@ -40,7 +48,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 #
 # More information on RPATH in CMake:
 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
-set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIR}")
 
 #-----------------------------------------------------------------------------#
 
@@ -450,7 +458,6 @@ if(ENABLE_PROOFS)
 endif()
 
 add_subdirectory(doc)
-add_subdirectory(examples EXCLUDE_FROM_ALL)  # excluded from all target
 add_subdirectory(src)
 add_subdirectory(test)
 
@@ -468,12 +475,13 @@ include(CMakePackageConfigHelpers)
 install(EXPORT cvc4-targets
   FILE CVC4Targets.cmake
   NAMESPACE CVC4::
-  DESTINATION lib/cmake/CVC4)
+  DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4)
 
 configure_package_config_file(
   ${CMAKE_SOURCE_DIR}/cmake/CVC4Config.cmake.in
   ${CMAKE_BINARY_DIR}/cmake/CVC4Config.cmake
-  INSTALL_DESTINATION lib/cmake/CVC4
+  INSTALL_DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4
+  PATH_VARS LIBRARY_INSTALL_DIR
 )
 
 write_basic_package_version_file(
@@ -485,7 +493,7 @@ write_basic_package_version_file(
 install(FILES
   ${CMAKE_BINARY_DIR}/cmake/CVC4Config.cmake
   ${CMAKE_BINARY_DIR}/CVC4ConfigVersion.cmake
-  DESTINATION lib/cmake/CVC4
+  DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4
 )
 
 
index f2eec75c6588d2bf2e014d473919f45497b804b5..86fbffff586636fb20fb528cc8d45b6bcbbfd780 100644 (file)
@@ -3,3 +3,8 @@
 if(NOT TARGET CVC4::cvc4)
   include(${CMAKE_CURRENT_LIST_DIR}/CVC4Targets.cmake)
 endif()
+
+if(NOT TARGET CVC4::cvc4jar)
+  set_and_check(CVC4_JNI_PATH "@PACKAGE_LIBRARY_INSTALL_DIR@")
+  include(${CMAKE_CURRENT_LIST_DIR}/CVC4JavaTargets.cmake)
+endif()
index f81c68236cfa21c17d5750f61f45e4b956175d85..43f4109a3047d1f0360222d842f291222685a816 100644 (file)
@@ -1,40 +1,30 @@
-include_directories(${PROJECT_SOURCE_DIR}/src)
-include_directories(${PROJECT_SOURCE_DIR}/src/include)
-include_directories(${CMAKE_BINARY_DIR}/src)
+cmake_minimum_required(VERSION 3.2)
+
+project(cvc4-examples)
+
+enable_testing()
+
+# Find CVC4 package. If CVC4 is not installed into the default system location
+# use `cmake .. -DCMAKE_PREFIX_PATH=path/to/lib/cmake` to specify the location
+# of CVC4Config.cmake.
+find_package(CVC4)
 
 # Some of the examples require boost. Enable these examples if boost is
 # installed.
 find_package(Boost 1.50.0)
 
-set(EXAMPLES_BIN_DIR ${CMAKE_BINARY_DIR}/bin/examples)
-
-# Create target examples.
-#
-# Only builds the examples, but does not run them. To run and build all
-# examples, use target runexamples (below).
-# Use macro cvc4_add_example to add examples.
-add_custom_target(examples)
-
-# Create target runexamples.
-# Builds and runs all examples.
-add_custom_target(runexamples
-  COMMAND ctest --output-on-failure -L "example" -j${NTHREADS} $$ARGS
-  DEPENDS examples)
+set(EXAMPLES_BIN_DIR ${CMAKE_BINARY_DIR}/bin)
 
 # Add example target and create test to run example with ctest.
 #
 # > name: The name of the example
 # > src_files: The list of source files passed as string "src1 src2 ..."
 #              (alternative: "src1;src2;...").  If empty, <name>.cpp is assumed.
-# > libs: The list of libraries to link the example against, passed as either
-#           - a list variable: set(<list name> <libs1> <libs2> ...) and pass
-#                              as "${<list name>}"
-#           - a string: pass as "lib1 lib2 ..." (alternative: "lib1;lib2;...")
 # > output_dir: Determines the examples subdirectory and is empty (passed as
 #               empty string) for the examples root directory (this)
 # > ARGN: Any additional arguments passed to the macro are interpreted as
 #         as arguments to the test executable.
-macro(cvc4_add_example name src_files libs output_dir)
+macro(cvc4_add_example name src_files output_dir)
   # The build target is created without the path prefix (not supported),
   # e.g., for '<output_dir>/myexample.cpp'
   #   we create build target 'myexample'
@@ -45,56 +35,52 @@ macro(cvc4_add_example name src_files libs output_dir)
   else()
     string(REPLACE " " ";" src_files_list "${src_files}")
   endif()
-  add_executable(${name} EXCLUDE_FROM_ALL ${src_files_list})
-  string(REPLACE " " ";" libs_list "${libs_list}")
-  target_link_libraries(${name} ${libs})
-  add_dependencies(examples ${name})
-  # The test target is prefixed with test identifier 'example/' and the path,
+
+  add_executable(${name} ${src_files_list})
+  target_link_libraries(${name} CVC4::cvc4 CVC4::cvc4parser)
+
+  # The test target is prefixed with the path,
   # e.g., for '<output_dir>/myexample.cpp'
-  #   we create test target 'example/<output_dir>/myexample'
-  #   and run it with 'ctest -R "example/<output_dir>/myunittest"'.
+  #   we create test target '<output_dir>/myexample'
+  #   and run it with 'ctest -R "<output_dir>/myexample"'.
   set(example_bin_dir ${EXAMPLES_BIN_DIR}/${output_dir})
   if("${output_dir}" STREQUAL "")
-    set(example_test example/${name})
+    set(example_test ${name})
   else()
-    set(example_test example/${output_dir}/${name})
+    set(example_test ${output_dir}/${name})
   endif()
   set_target_properties(${name}
     PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${example_bin_dir})
   add_test(${example_test} ${example_bin_dir}/${name} ${ARGN})
-  set_tests_properties(${example_test} PROPERTIES LABELS "example")
 endmacro()
 
-set(EXAMPLES_LINK_LIBS cvc4 cvc4parser)
-cvc4_add_example(simple_vc_cxx "" "${EXAMPLES_LINK_LIBS}" "")
-cvc4_add_example(simple_vc_quant_cxx "" "${EXAMPLES_LINK_LIBS}" "")
-cvc4_add_example(translator "" "${EXAMPLES_LINK_LIBS}" ""
+cvc4_add_example(simple_vc_cxx "" "")
+cvc4_add_example(simple_vc_quant_cxx "" "")
+cvc4_add_example(translator "" ""
     # argument to binary (for testing)
     ${CMAKE_CURRENT_SOURCE_DIR}/translator-example-input.smt2)
 
-if(BUILD_BINDINGS_JAVA)
+add_subdirectory(api)
+add_subdirectory(hashsmt)
+add_subdirectory(nra-translate)
+add_subdirectory(sets-translate)
+
+if(TARGET CVC4::cvc4jar)
   find_package(Java REQUIRED)
-  set(EXAMPLES_JAVA_CLASSPATH "${CMAKE_BINARY_DIR}/src/bindings/java/CVC4.jar")
-  add_custom_target(SimpleVCjava
-    COMMAND
-      ${Java_JAVAC_EXECUTABLE}
-        -cp ${EXAMPLES_JAVA_CLASSPATH} ${CMAKE_CURRENT_SOURCE_DIR}/SimpleVC.java
-        -d ${CMAKE_BINARY_DIR}/bin/examples
-    DEPENDS cvc4jar)
-  add_dependencies(examples SimpleVCjava)
+  include(UseJava)
+
+  get_target_property(CVC4_JAR CVC4::cvc4jar JAR_FILE)
+
+  add_jar(SimpleVC SimpleVC.java INCLUDE_JARS "${CVC4_JAR}")
+
   add_test(
-    NAME example/SimpleVCjava
+    NAME java/SimpleVC
     COMMAND
       ${Java_JAVA_EXECUTABLE}
-        -Djava.library.path=${CMAKE_BINARY_DIR}/src/bindings/java/
-        -cp "${EXAMPLES_JAVA_CLASSPATH}:${CMAKE_BINARY_DIR}/bin/examples/"
+        -cp "${CVC4_JAR}:${CMAKE_BINARY_DIR}/SimpleVC.jar"
+        -Djava.library.path=${CVC4_JNI_PATH}
         SimpleVC
   )
-  set_tests_properties(example/SimpleVCjava PROPERTIES LABELS "example")
-endif()
-
-add_subdirectory(api)
-add_subdirectory(hashsmt)
-add_subdirectory(nra-translate)
-add_subdirectory(sets-translate)
 
+  add_subdirectory(api/java)
+endif()
diff --git a/examples/README b/examples/README
deleted file mode 100644 (file)
index cc3c23f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-Examples
---------
-
-This directory contains usage examples of CVC4's different language
-bindings, library APIs, and also tutorial examples from the tutorials
-available at http://cvc4.cs.stanford.edu/wiki/Tutorials
-
-### SimpleVC*, simple_vc*
-
-These are examples of how to use CVC4 with each of its library
-interfaces (APIs) and language bindings.  They are essentially "hello
-world" examples, and do not fully demonstrate the interfaces, but
-function as a starting point to using simple expressions and solving
-functionality through each library.
-
-### Targeted examples
-
-The "api" directory contains some more specifically-targeted
-examples (for bitvectors, for arithmetic, etc.).  The "api/java"
-directory contains the same examples in Java.
-
-### Building Examples
-
-The examples provided in this directory are not built by default.
-
-    make examples                      # build all examples
-    make runexamples                   # build and run all examples
-    make <example>                     # build examples/<subdir>/<example>.<ext>
-    ctest example//<subdir>/<example>  # run examples/<subdir>/<example>.<ext>
-
-The examples binaries are built into `<build_dir>/bin/examples`.
diff --git a/examples/README.md b/examples/README.md
new file mode 100644 (file)
index 0000000..1883471
--- /dev/null
@@ -0,0 +1,46 @@
+# CVC4 API Examples
+
+This directory contains usage examples of CVC4's different language
+bindings, library APIs, and also tutorial examples from the tutorials
+available at http://cvc4.cs.stanford.edu/wiki/Tutorials
+
+## Building Examples
+
+The examples provided in this directory are not built by default.
+
+```
+  mkdir <build_dir>
+  cd <build_dir>
+  cmake ..
+  make               # use -jN for parallel build with N threads
+
+  ctest              # run all examples
+  ctest -R <example> # run specific example '<example>'
+
+  # Or just run the binaries in directory <build_dir>/bin/, for example:
+  bin/api/bitvectors
+```
+
+**Note:** If you installed CVC4 in a non-standard location you have to
+additionally specify `CMAKE_PREFIX_PATH` to point to the location of
+`CVC4Config.cmake` (usually `<your-install-prefix>/lib/cmake`) as follows:
+
+```
+  cmake .. -DCMAKE_PREFIX_PATH=<your-install-prefix>/lib/cmake
+```
+
+The examples binaries are built into `<build_dir>/bin`.
+
+## SimpleVC*, simple_vc*
+
+These are examples of how to use CVC4 with each of its library
+interfaces (APIs) and language bindings.  They are essentially "hello
+world" examples, and do not fully demonstrate the interfaces, but
+function as a starting point to using simple expressions and solving
+functionality through each library.
+
+## Targeted examples
+
+The "api" directory contains some more specifically-targeted
+examples (for bitvectors, for arithmetic, etc.).  The "api/java"
+directory contains the same examples in Java.
index 125b4f8481054475d383d88cd1b226814557bda0..c84b040a3af82fbb34f2dc0137c26c265e5da4cd 100644 (file)
  ** following:
  **
  **   java \
- **     -classpath path/to/CVC4.jar \
- **     -Djava.library.path=/dir/containing/java/CVC4.so \
+ **     -cp path/to/CVC4.jar:SimpleVC.jar \
+ **     -Djava.library.path=/dir/containing/libcvc4jni.so \
  **     SimpleVC
  **
- ** For example, if you are building CVC4 without specifying your own
- ** build directory, the build process puts everything in builds/, and
- ** you can run this example (after building it with "make") like this:
- **
- **   java \
- **     -classpath builds/examples:builds/src/bindings/CVC4.jar \
- **     -Djava.library.path=builds/src/bindings/java/.libs \
- **     SimpleVC
  **/
 
 import edu.nyu.acsys.CVC4.*;
index c78c504663793b4b81053a41cad51f8d151f7764..b121c8833972ed254a5b5f184e6eb469388d36ff 100644 (file)
@@ -19,12 +19,6 @@ set(CVC4_EXAMPLES_API
   strings-new
 )
 
-set(EXAMPLES_API_LINK_LIBS cvc4 cvc4parser)
 foreach(example ${CVC4_EXAMPLES_API})
-  cvc4_add_example(${example}
-    "" "${EXAMPLES_API_LINK_LIBS}" "api")
+  cvc4_add_example(${example} "" "api")
 endforeach()
-
-if(BUILD_BINDINGS_JAVA)
-  add_subdirectory(java)
-endif()
index d0c26f13441f88687a7dc64e110038e40b9a693b..58912a1bb3ec1722250889113d29af6ab9d32d17 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace std;
 using namespace CVC4::api;
index 59257976d114a806e6b988573d3a8fe0306f9c5f..259eb48ff5014c96a6d6e1a6ad0e16c8b7502260 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 955a83cffdf366bf5fd9c42cfff6a80d8cd2e9af..44b5aa018ce51a522ed5b4cb13069bf427879bed 100644 (file)
@@ -17,8 +17,7 @@
 #include <iostream>
 #include <cmath>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace std;
 using namespace CVC4::api;
index 983da71db682443e1529fd2bf39e65e0ce6b730d..1820712bdff20d0478eb356acba44e7bafb48fab 100644 (file)
@@ -16,8 +16,8 @@
 
 #include <iostream>
 #include <cmath>
-// #include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index e78e8919f61eb5a6bca933de7b780b751ccaa235..5284a01193f7ea79fcd96a783a3619baa6dcbdf2 100644 (file)
@@ -18,8 +18,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace std;
 using namespace CVC4::api;
index 0d8ae04949746a966233df97266b13cdd8ef1581..646e6b17a20244c69f243f1394c0fde8761b8d3e 100644 (file)
@@ -18,8 +18,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 08918fc87cc45cd49a6594818d1694bfa28d2b83..8c62577252166f79bf2859abf5a0cdff085f207a 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace CVC4::api;
 
index 3bf1df12f15ca082a9c5272d98f65eef94e12bef..dabc1228f1a9d4906c1cf85d1ea0bbe52ed3cd01 100644 (file)
@@ -15,9 +15,8 @@
  **/
 
 #include <iostream>
-#include "options/language.h" // for use with make examples
-#include "smt/smt_engine.h" // for use with make examples
-//#include <cvc4/cvc4.h> // To follow the wiki
+
+#include <cvc4/cvc4.h>
 
 using namespace CVC4;
 
index cb7d96fa5083f6f56ac53a7f67c7d8e4aa1054fb..0cb885b2c03959eb92125bd23b601bbf288a77a0 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace std;
 using namespace CVC4::api;
index c9240363e5c7bf3339f0a5a3ab2886e36963c5c7..a008ec718d8709659322c48c327278bdbb3afef7 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index a7fbe22e95dbe76e1a5e8fc675bc9c416fcdde98..ab869f03cea5691551fd5eed3dba87b70ed56c10 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace CVC4::api;
 
index 1235c4c5554ca025b4697dd80ce76f19287e03e4..befeaa7bdb0ef44104a0177ba6bd09d51a7b4b8e 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace CVC4;
 int main() {
index dd7d6566f5b5dfce2fdae83f933b15322d9a15e7..2b364c3d1614a612f4032e513e02d3197a8f7622 100644 (file)
@@ -1,6 +1,3 @@
-set(EXAMPLES_API_JAVA_BIN_DIR ${EXAMPLES_BIN_DIR}/api/java) 
-file(MAKE_DIRECTORY ${EXAMPLES_API_JAVA_BIN_DIR})
-
 set(EXAMPLES_API_JAVA
   BitVectors
   BitVectorsAndArrays
@@ -19,22 +16,19 @@ set(EXAMPLES_API_JAVA
 )
 
 foreach(example ${EXAMPLES_API_JAVA})
-  add_custom_target(${example}
-    COMMAND
-      ${Java_JAVAC_EXECUTABLE}
-        -cp ${EXAMPLES_JAVA_CLASSPATH} ${CMAKE_CURRENT_SOURCE_DIR}/${example}.java
-        -d ${EXAMPLES_API_JAVA_BIN_DIR}
-    DEPENDS cvc4jar)
-  add_dependencies(examples ${example})
-  set(example_test example/api/java/${example})
+  add_jar(${example} ${example}.java
+          INCLUDE_JARS "${CVC4_JAR}"
+          OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin/api/java")
+
+  set(EXAMPLE_TEST_NAME api/java/${example})
+
   add_test(
-    NAME ${example_test}
+    NAME ${EXAMPLE_TEST_NAME}
     COMMAND
       ${Java_JAVA_EXECUTABLE}
-        -Djava.library.path=${CMAKE_BINARY_DIR}/src/bindings/java/
-        -cp "${EXAMPLES_JAVA_CLASSPATH}:${CMAKE_BINARY_DIR}/bin/examples/api/java/"
+        -cp "${CVC4_JAR}:${CMAKE_BINARY_DIR}/bin/api/java/${example}.jar"
+        -Djava.library.path=${CVC4_JNI_PATH}
         ${example}
   )
-  set_tests_properties(${example_test} PROPERTIES SKIP_RETURN_CODE 77)
-  set_tests_properties(${example_test} PROPERTIES LABELS "example")
+  set_tests_properties(${EXAMPLE_TEST_NAME} PROPERTIES SKIP_RETURN_CODE 77)
 endforeach()
index 2edcaf71e6f7e31473e766f1347c418b422ff44d..a4ff9a2cc74bdb0899a81816e75922c03aa96c29 100644 (file)
@@ -17,8 +17,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include "cvc4/api/cvc4cpp.h"
 
 using namespace std;
 using namespace CVC4::api;
index 83a0064c93365049403fea262efa40d26f8ff39e..f1c8b861cb42d00360a4f82d6bb8a3335faa3bc0 100644 (file)
@@ -17,8 +17,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 60df7a82fbf316f360ad313f2f87338ec040284e..2ca3db9d2f089df8b04d0b122ce8a0b937a95df8 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace std;
 using namespace CVC4::api;
index 3110c01e31aebb562614b323ff5f1c2c0e06091e..9fb342431aa1977fba82525cf5ce2979c76760c1 100644 (file)
@@ -16,9 +16,8 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
-#include "options/set_language.h"
+#include <cvc4/cvc4.h>
+#include <cvc4/options/set_language.h>
 
 using namespace std;
 using namespace CVC4;
index 42630dc0ec30359fad31c25bd5a6ed9d4564b68e..e83ab89ff9797a6a248c3da9e74c0a81a6daa12e 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-// #include "cvc4/api/cvc4cpp.h" // use this after CVC4 is properly installed
-#include "api/cvc4cpp.h"
+#include <cvc4/api/cvc4cpp.h>
 
 using namespace CVC4::api;
 
index 96f4dd400e2051a77bd7e4465123488427aa26bd..661ae0e77fd272be2eccec067e83812345e266b8 100644 (file)
@@ -16,9 +16,8 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
-#include "options/set_language.h"
+#include <cvc4/cvc4.h>
+#include <cvc4/options/set_language.h>
 
 using namespace CVC4;
 
index ff696b40392fb48b51faf1988cb1fe50de3f4ab2..39e503a815590a0b73f799089f9f8035e063fca0 100644 (file)
@@ -1,13 +1,11 @@
-include_directories(.)
-
-set(EXAMPLES_HASHSMT_LINK_LIBS cvc4)
-
 if(Boost_FOUND)
    cvc4_add_example(sha1_inversion
-     "sha1_inversion.cpp word.cpp" "${EXAMPLES_HASHSMT_LINK_LIBS}" "hashsmt"
-     "a" "sha1_inversion.outfile")  # arguments to binary (for testing)
+     "sha1_inversion.cpp word.cpp" "hashsmt"
+     # arguments to binary (for testing)
+     "a" "sha1_inversion.outfile")
 endif()
 
 cvc4_add_example(sha1_collision
-  "sha1_collision.cpp word.cpp" "${EXAMPLES_HASHSMT_LINK_LIBS}" "hashsmt"
-  "1" "1" "sha1_collision.outfile")  # arguments to binary (for testing)
+  "sha1_collision.cpp word.cpp" "hashsmt"
+  # arguments to binary (for testing)
+  "1" "1" "sha1_collision.outfile")
index e26b2623bd967df29e573df43cbe154600079278..ea93db14446993f2b6733066bcb8491af4b904c1 100644 (file)
 #include <sstream>
 #include <string>
 
-#include "expr/expr_iomanip.h"
-#include "options/language.h"
-#include "options/set_language.h"
+#include <cvc4/cvc4.h>
+#include <cvc4/expr/expr_iomanip.h>
+#include <cvc4/options/set_language.h>
 #include "sha1.hpp"
-#include "smt/command.h"
 #include "word.h"
 
 using namespace std;
index 667c3c4e0eb25beade2e444a68b065de152a5097..b53f4b149c980401f28ac2d5d4587c79460da6a3 100644 (file)
 #include <string>
 #include <vector>
 
-#include "expr/expr_iomanip.h"
-#include "options/language.h"
-#include "options/set_language.h"
+#include <cvc4/cvc4.h>
+#include <cvc4/expr/expr_iomanip.h>
+#include <cvc4/options/set_language.h>
+
 #include "sha1.hpp"
-#include "smt/command.h"
 #include "word.h"
 
 using namespace std;
index 189eaf485a1bb19847da696aa7c5f66aab9fedd0..b26e3b4d30d8f097b8b8e533fa8f2c4ae89ab849 100644 (file)
 
 #include <vector>
 
-#include "expr/expr.h"
-#include "expr/expr_iomanip.h"
-#include "options/language.h"
-#include "options/options.h"
+#include <cvc4/cvc4.h>
+#include <cvc4/expr/expr_iomanip.h>
+#include <cvc4/options/language.h>
+#include <cvc4/options/options.h>
 
 using namespace std;
 using namespace hashsmt;
index cbe53d54957ca673769334bd37c31f24364f3a6d..ad08a63ae78936226ad2fcc5faeb882d9d15b6e0 100644 (file)
@@ -28,9 +28,7 @@
 #include <string>
 #include <iostream>
 
-#include "expr/expr.h"
-#include "expr/expr_manager.h"
-#include "options/options.h"
+#include <cvc4/cvc4.h>
 
 namespace hashsmt {
 
index b719ac2a46f634a4cc19d58babbedf2688ebe307..e83825e2480528fd9092bc8217418c5f55615de8 100644 (file)
@@ -10,10 +10,8 @@ set(CVC4_EXAMPLES_NRA_TRANSLATE
   smt2toredlog
 )
 
-set(EXAMPLES_NRA_TRANSLATE_LINK_LIBS cvc4 cvc4parser)
 foreach(example ${CVC4_EXAMPLES_NRA_TRANSLATE})
-  cvc4_add_example(${example}
-    "" "${EXAMPLES_NRA_TRANSLATE_LINK_LIBS}" "nra-translate"
+  cvc4_add_example(${example} "" "nra-translate"
     # arguments to binary (for testing)
     # input file is required by all tests
     ${CMAKE_CURRENT_SOURCE_DIR}/nra-translate-example-input.smt2
index 3ca09c5bf6a5c4d62c6c86eb33bd4f07ccb979f5..2ad1ea84e6a84f163f299cc5f48210bb17e0ea28 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "expr/expr_iomanip.h"
-#include "options/language.h"
-#include "options/options.h"
-#include "options/set_language.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "smt/smt_engine.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
+#include <cvc4/expr/expr_iomanip.h>
+#include <cvc4/options/set_language.h>
 
 using namespace std;
 using namespace CVC4;
index 513b52a3926880cdd686157a58eedacb14b04955..dfbde05f5096337486e61e09a238440f55dac51e 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "options/options.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 11f5ad4f8149e10e92aa422eda5235d30e0f2c9f..8ea3cf8624d632934d1814bb285ee24f401bac5b 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "expr/expr_iomanip.h"
-#include "options/options.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "smt/smt_engine.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
+#include <cvc4/expr/expr_iomanip.h>
+#include <cvc4/options/set_language.h>
 
 using namespace std;
 using namespace CVC4;
index 5992cd0dc614523c2183f5c4b11a7231b2ff817c..34745ad037ea9cf65921164a0c3a34304c33419e 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "options/options.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "smt/smt_engine.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 8f0764e92f5476c8ccb7fc0364d2d700f9e1c78c..c5c2f3af41ac542adeef0ac23828262360eff07c 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "options/options.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 28e699b6fafc0e4ddbc44093827ad9622d4f3168..cdc2e08782c28d560a2e623a69c87135a4d7093a 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "options/options.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 0629b5d1c250cd874d23d950f45a83a73c60de7c..654a6a038d918d8f1b9f502c73d36bf6c07518b8 100644 (file)
 #include <typeinfo>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "options/options.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "smt/smt_engine.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index 1c34d3aafc6d6f4820b199018bcd00786df4c33a..5487a2fcf923e4acd01212f1672ea2c32bc37a9b 100644 (file)
@@ -1,12 +1,11 @@
 if(Boost_FOUND)
-  set(EXAMPLES_SETS_TRANSLATE_LINK_LIBS cvc4 cvc4parser)
   cvc4_add_example(sets2arrays
-    "sets_translate.cpp" "${EXAMPLES_SETS_TRANSLATE_LINK_LIBS}" "sets-translate"
+    "sets_translate.cpp" "sets-translate"
     # argument to binary (for testing)
     ${CMAKE_CURRENT_SOURCE_DIR}/sets-translate-example-input.smt2)
 
   cvc4_add_example(sets2axioms
-    "sets_translate.cpp" "${EXAMPLES_SETS_TRANSLATE_LINK_LIBS}" "sets-translate"
+    "sets_translate.cpp" "sets-translate"
     # argument to binary (for testing)
     ${CMAKE_CURRENT_SOURCE_DIR}/sets-translate-example-input.smt2)
   target_compile_definitions(sets2axioms PRIVATE -DENABLE_AXIOMS)
index f7513a401b3d542944b311f085414bdab89acbd1..0d263cb974daf5fb90b223a72eff4d2b0a269cc9 100644 (file)
 #include <unordered_map>
 #include <vector>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "options/language.h"
-#include "options/options.h"
-#include "options/set_language.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "theory/logic_info.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
+#include <cvc4/options/set_language.h>
 
 using namespace std;
 using namespace CVC4;
index ad18ae5b7c31496bce40b867bf8e1f021ece015d..25a05a1a76f8f6e3fac0a974087d6bccae028146 100644 (file)
@@ -18,8 +18,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index a8bbfe29aa67bd984e04e52ca1ca1bf75b0a6ce8..11bbe01e06eaa710d767df315755106ff76b6ff0 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <iostream>
 
-//#include <cvc4/cvc4.h> // use this after CVC4 is properly installed
-#include "smt/smt_engine.h"
+#include <cvc4/cvc4.h>
 
 using namespace std;
 using namespace CVC4;
index b8b8fde38e09c81eefa621c92f62cf8ed2513d9a..7417060705f70304241031eabdaf12c521220f61 100644 (file)
 #include <getopt.h>
 #include <iostream>
 
-#include "api/cvc4cpp.h"
-#include "expr/expr.h"
-#include "expr/expr_iomanip.h"
-#include "options/language.h"
-#include "options/options.h"
-#include "options/set_language.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "smt/smt_engine.h"
+#include <cvc4/api/cvc4cpp.h>
+#include <cvc4/cvc4.h>
+#include <cvc4/expr/expr_iomanip.h>
+#include <cvc4/options/set_language.h>
 
 using namespace std;
 using namespace CVC4;
index d062e99c0a687b42ad2e4b9d9992980b1715b858..7289f650bf6942a54b7c077dd8b1eed40cccc87b 100644 (file)
@@ -761,8 +761,8 @@ target_include_directories(cvc4
 
 install(TARGETS cvc4
   EXPORT cvc4-targets
-  LIBRARY DESTINATION lib
-  ARCHIVE DESTINATION lib)
+  LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
+  ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
 
 set_target_properties(cvc4 PROPERTIES SOVERSION ${CVC4_SOVERSION})
 target_compile_definitions(cvc4
@@ -842,27 +842,27 @@ install(FILES
           api/cvc4cpp.h
           api/cvc4cppkind.h
         DESTINATION
-          include/cvc4/api)
+          ${INCLUDE_INSTALL_DIR}/cvc4/api)
 install(FILES
           base/configuration.h
           base/exception.h
           base/listener.h
           base/modal_exception.h
         DESTINATION
-          include/cvc4/base)
+          ${INCLUDE_INSTALL_DIR}/cvc4/base)
 install(FILES
           context/cdhashmap_forward.h
           context/cdhashset_forward.h
           context/cdinsert_hashmap_forward.h
           context/cdlist_forward.h
         DESTINATION
-          include/cvc4/context)
+          ${INCLUDE_INSTALL_DIR}/cvc4/context)
 install(FILES
           include/cvc4.h
           include/cvc4_public.h
           include/cvc4parser_public.h
         DESTINATION
-          include/cvc4)
+          ${INCLUDE_INSTALL_DIR}/cvc4)
 install(FILES
           expr/array.h
           expr/array_store_all.h
@@ -881,7 +881,7 @@ install(FILES
           ${CMAKE_CURRENT_BINARY_DIR}/expr/kind.h
           ${CMAKE_CURRENT_BINARY_DIR}/expr/expr_manager.h
         DESTINATION
-          include/cvc4/expr)
+          ${INCLUDE_INSTALL_DIR}/cvc4/expr)
 install(FILES
           options/argument_extender.h
           options/arith_heuristic_pivot_rule.h
@@ -898,38 +898,38 @@ install(FILES
           options/sygus_out_mode.h
           options/theoryof_mode.h
         DESTINATION
-          include/cvc4/options)
+          ${INCLUDE_INSTALL_DIR}/cvc4/options)
 install(FILES
           parser/input.h
           parser/parser.h
           parser/parser_builder.h
           parser/parser_exception.h
         DESTINATION
-          include/cvc4/parser)
+          ${INCLUDE_INSTALL_DIR}/cvc4/parser)
 install(FILES
           printer/sygus_print_callback.h
         DESTINATION
-          include/cvc4/printer)
+          ${INCLUDE_INSTALL_DIR}/cvc4/printer)
 install(FILES
           proof/unsat_core.h
         DESTINATION
-          include/cvc4/proof)
+          ${INCLUDE_INSTALL_DIR}/cvc4/proof)
 install(FILES
           smt/command.h
           smt/logic_exception.h
           smt/smt_engine.h
         DESTINATION
-          include/cvc4/smt)
+          ${INCLUDE_INSTALL_DIR}/cvc4/smt)
 install(FILES
           smt_util/lemma_channels.h
           smt_util/lemma_input_channel.h
           smt_util/lemma_output_channel.h
         DESTINATION
-          include/cvc4/smt_util)
+          ${INCLUDE_INSTALL_DIR}/cvc4/smt_util)
 install(FILES
           theory/logic_info.h
         DESTINATION
-          include/cvc4/theory)
+          ${INCLUDE_INSTALL_DIR}/cvc4/theory)
 install(FILES
           util/abstract_value.h
           util/bitvector.h
@@ -955,7 +955,7 @@ install(FILES
           ${CMAKE_CURRENT_BINARY_DIR}/util/integer.h
           ${CMAKE_CURRENT_BINARY_DIR}/util/rational.h
         DESTINATION
-          include/cvc4/util)
+          ${INCLUDE_INSTALL_DIR}/cvc4/util)
 
 # Fix include paths for all public headers.
 # Note: This is a temporary fix until the new C++ API is in place.
index 3d1e0463ba9ff74da2741e203a8980b239643045..b68a353adbdbcd8825228d147579d1bc2cc3b203 100644 (file)
@@ -276,4 +276,13 @@ add_jar(cvc4jar
 add_dependencies(cvc4jar cvc4jni)
 install_jar(cvc4jar DESTINATION share/java/cvc4)
 install_jni_symlink(cvc4jar DESTINATION share/java/cvc4)
-install(TARGETS cvc4jni DESTINATION lib)
+install(TARGETS cvc4jni
+  EXPORT cvc4-targets
+  DESTINATION ${LIBRARY_INSTALL_DIR})
+
+install_jar_exports(
+  TARGETS cvc4jar
+  NAMESPACE CVC4::
+  FILE CVC4JavaTargets.cmake
+  DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4
+)
index 356b0e1992a3af3bc03d2f4d737f92d495e105de..96e0078ed0eae2a3e7e5e58a1688ed0373e4decf 100644 (file)
@@ -47,9 +47,12 @@ set_target_properties(cvc4-bin
 target_link_libraries(cvc4-bin cvc4 cvc4parser)
 if(PROGRAM_PREFIX)
   install(PROGRAMS
-    $<TARGET_FILE:cvc4-bin> DESTINATION bin RENAME ${PROGRAM_PREFIX}cvc4)
+    $<TARGET_FILE:cvc4-bin>
+    DESTINATION ${RUNTIME_INSTALL_DIR}
+    RENAME ${PROGRAM_PREFIX}cvc4)
 else()
-  install(TARGETS cvc4-bin DESTINATION bin)
+  install(TARGETS cvc4-bin
+    DESTINATION ${RUNTIME_INSTALL_DIR})
 endif()
 
 # In order to get a fully static executable we have to make sure that we also
index 78ab82cb4f6a15e9ee205b4ba3f9a362a67dd243..f2c1a6ef42de7f256ca08e0a62f1c5b8068ee884 100644 (file)
@@ -98,7 +98,7 @@ target_link_libraries(cvc4parser cvc4 ${ANTLR_LIBRARIES})
 target_include_directories(cvc4parser PRIVATE ${ANTLR_INCLUDE_DIR})
 install(TARGETS cvc4parser
   EXPORT cvc4-targets
-  DESTINATION lib)
+  DESTINATION ${LIBRARY_INSTALL_DIR})
 
 # The generated lexer/parser files define some functions as
 # __declspec(dllexport) via the ANTLR3_API macro, which leads to lots of
index cd67c136e9d4f385ee9131c0565f6ee4e2aa970c..447d4909f099495ef41238a2cdb794cb1a9bbbf4 100644 (file)
@@ -5,9 +5,6 @@
 # > system tests
 
 add_custom_target(build-tests)
-# Since examples are also built and run for testing, we have to add examples
-# to the build test dependencies.
-add_dependencies(build-tests examples)
 
 # Note: Do not add custom targets for running tests (regress, systemtests,
 # units) as dependencies to other run targets. This will result in executing