summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--cmake/FindCxxTest.cmake45
-rwxr-xr-xconfigure.sh8
-rw-r--r--test/unit/CMakeLists.txt12
4 files changed, 62 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 654e5f3f2..86007b39a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,6 +90,7 @@ set(ABC_DIR "" CACHE STRING "Set ABC install directory")
set(ANTLR_DIR "" CACHE STRING "Set ANTLR3 install directory")
set(CADICAL_DIR "" CACHE STRING "Set CaDiCaL install directory")
set(CRYPTOMINISAT_DIR "" CACHE STRING "Set CryptoMiniSat install directory")
+set(CXXTEST_DIR "" CACHE STRING "Set CxxTest install directory")
set(GLPK_DIR "" CACHE STRING "Set GLPK install directory")
set(GMP_DIR "" CACHE STRING "Set GMP install directory")
set(LFSC_DIR "" CACHE STRING "Set LFSC install directory")
@@ -330,10 +331,6 @@ if(ENABLE_TRACING)
add_definitions(-DCVC4_TRACING)
endif()
-if(ENABLE_UNIT_TESTING)
- find_package(CxxTest REQUIRED)
-endif()
-
if(ENABLE_STATISTICS)
add_definitions(-DCVC4_STATISTICS_ON)
endif()
diff --git a/cmake/FindCxxTest.cmake b/cmake/FindCxxTest.cmake
new file mode 100644
index 000000000..cd7aed70d
--- /dev/null
+++ b/cmake/FindCxxTest.cmake
@@ -0,0 +1,45 @@
+# Find CxxTest
+# CxxTest_FOUND - system has CxxTest lib
+# CxxTest_INCLUDE_DIR - the CxxTest include directory
+# CxxTest_TESTGEN_EXECUTABLE - CxxTest excecutable
+# CxxTest_TESTGEN_INTERPRETER - Python/Perl interpreter for running executable
+
+find_package(PythonInterp QUIET)
+find_package(Perl QUIET)
+
+find_path(CxxTest_INCLUDE_DIR cxxtest/TestSuite.h
+ PATHS ${CxxTest_HOME}
+ NO_DEFAULT_PATH)
+find_program(CxxTest_PYTHON_TESTGEN_EXECUTABLE
+ NAMES cxxtestgen cxxtestgen.py
+ PATHS ${CxxTest_HOME}/bin
+ NO_DEFAULT_PATH)
+find_program(CxxTest_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl
+ PATHS ${CxxTest_HOME}/bin
+ NO_DEFAULT_PATH)
+
+if(NOT CxxTest_HOME)
+ find_path(CxxTest_INCLUDE_DIR cxxtest/TestSuite.h)
+ find_program(CxxTest_PYTHON_TESTGEN_EXECUTABLE NAMES cxxtestgen cxxtestgen.py)
+ find_program(CxxTest_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl)
+endif()
+
+if(PYTHONINTERP_FOUND AND CxxTest_PYTHON_TESTGEN_EXECUTABLE)
+ set(CxxTest_TESTGEN_EXECUTABLE ${CxxTest_PYTHON_TESTGEN_EXECUTABLE})
+ set(CxxTest_TESTGEN_INTERPRETER ${PYTHON_EXECUTABLE})
+elseif(PERL_FOUND AND CxxTest_PERL_TESTGEN_EXECUTABLE)
+ set(CxxTest_TESTGEN_EXECUTABLE ${CxxTest_PERL_TESTGEN_EXECUTABLE})
+ set(CxxTest_TESTGEN_INTERPRETER ${PERL_EXECUTABLE})
+elseif(NOT PYTHONINTERP_FOUND AND NOT PERL_FOUND AND CxxTest_FIND_REQUIRED)
+ message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest.")
+endif()
+
+if(NOT DEFINED CxxTest_TESTGEN_ARGS)
+ set(CxxTest_TESTGEN_ARGS --error-printer)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ CxxTest DEFAULT_MSG CxxTest_INCLUDE_DIR CxxTest_TESTGEN_EXECUTABLE)
+
+mark_as_advanced(CxxTest_INCLUDE_DIR CxxTest_TESTGEN_EXECUTABLE)
diff --git a/configure.sh b/configure.sh
index 0740ce396..1cc104c94 100755
--- a/configure.sh
+++ b/configure.sh
@@ -65,7 +65,7 @@ Optional Path to Optional Packages:
--antlr-dir=PATH path to ANTLR C headers and libraries
--cadical-dir=PATH path to top level of CaDiCaL source tree
--cryptominisat-dir=PATH path to top level of CryptoMiniSat source tree
- --cxxtest-dir=DIR path to CxxTest installation
+ --cxxtest-dir=PATH path to CxxTest installation
--glpk-dir=PATH path to top level of GLPK installation
--gmp-dir=PATH path to top level of GMP installation
--lfsc-dir=PATH path to top level of LFSC source tree
@@ -139,6 +139,7 @@ abc_dir=default
antlr_dir=default
cadical_dir=default
cryptominisat_dir=default
+cxxtest_dir=default
glpk_dir=default
gmp_dir=default
lfsc_dir=default
@@ -288,6 +289,9 @@ do
--cryptominisat-dir) die "missing argument to $1 (try -h)" ;;
--cryptominisat-dir=*) cryptominisat_dir=${1##*=} ;;
+ --cxxtest-dir) die "missing argument to $1 (try -h)" ;;
+ --cxxtest-dir=*) cxxtest_dir=${1##*=} ;;
+
--glpk-dir) die "missing argument to $1 (try -h)" ;;
--glpk-dir=*) glpk_dir=${1##*=} ;;
@@ -395,6 +399,8 @@ cmake_opts=""
&& cmake_opts="$cmake_opts -DCADICAL_DIR=$cadical_dir"
[ "$cryptominisat_dir" != default ] \
&& cmake_opts="$cmake_opts -DCRYPTOMINISAT_DIR=$cryptominisat_dir"
+[ "$cxxtest_dir" != default ] \
+ && cmake_opts="$cmake_opts -DCXXTEST_DIR=$cxxtest_dir"
[ "$glpk_dir" != default ] \
&& cmake_opts="$cmake_opts -DGLPK_DIR=$glpk_dir"
[ "$gmp_dir" != default ] \
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 4bcb97c8e..d362870c1 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -1,3 +1,9 @@
+# Note: We use our custom CxxTest finder here to specify custom directories and
+# fail if it is not found in the specified directory (similar to the other
+# custom finder modules).
+set(CxxTest_HOME ${CXXTEST_DIR})
+find_package(CxxTest REQUIRED)
+
include_directories(.)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/src/include)
@@ -33,9 +39,9 @@ macro(cvc4_add_unit_test is_white name output_dir)
OUTPUT ${test_src}
DEPENDS ${test_header}
COMMAND
- ${CXXTEST_TESTGEN_INTERPRETER}
- ${CXXTEST_TESTGEN_EXECUTABLE}
- ${CXXTEST_TESTGEN_ARGS} -o ${test_src} ${test_header}
+ ${CxxTest_TESTGEN_INTERPRETER}
+ ${CxxTest_TESTGEN_EXECUTABLE}
+ ${CxxTest_TESTGEN_ARGS} -o ${test_src} ${test_header}
)
set_source_files_properties(${test_src} PROPERTIES GENERATED true)
# The build target is created without the path prefix (not supported),
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback