summaryrefslogtreecommitdiff
path: root/test/unit/CMakeLists.txt
blob: fda403e84604d9ca598d70a897bc3a2d51e75e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#####################
## CMakeLists.txt
## Top contributors (to current version):
##   Aina Niemetz, Mathias Preiner, Alex Ozdemir
## This file is part of the CVC4 project.
## Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
## in the top-level source directory and their institutional affiliations.
## All rights reserved.  See the file COPYING in the top-level source
## directory for licensing information.
##
find_package(GTest REQUIRED)
include(GoogleTest)

include_directories(.)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/src/include)
include_directories(${CMAKE_BINARY_DIR}/src)

#-----------------------------------------------------------------------------#
# Add target 'units', builds and runs
# > unit tests

add_custom_target(build-units)
add_dependencies(build-tests build-units)

add_custom_target(units
  COMMAND ctest --output-on-failure -L "unit" -j${CTEST_NTHREADS} $$ARGS
  DEPENDS build-units)

set(CVC4_UNIT_TEST_FLAGS_BLACK
  -D__BUILDING_CVC4LIB_UNIT_TEST -D__BUILDING_CVC4PARSERLIB_UNIT_TEST
  -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS)

# Generate and add unit test.
macro(cvc4_add_unit_test is_white name output_dir)
  set(test_src ${CMAKE_CURRENT_LIST_DIR}/${name}.cpp)
  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::GTest)
  target_link_libraries(${name} GTest::Main)
  if(USE_LFSC)
    # We don't link against LFSC, because CVC4 is already linked against it.
    target_include_directories(${name} PRIVATE ${LFSC_INCLUDE_DIR})
  endif()
  if(USE_POLY)
    # We don't link against libpoly, because CVC4 is already linked against it.
    target_include_directories(${name} PRIVATE ${POLY_INCLUDE_DIR})
  endif()
  if(${is_white})
    target_compile_options(${name} PRIVATE -fno-access-control)
  endif()
  # Disable the Wunused-comparison warnings for the unit tests.
  check_cxx_compiler_flag("-Wno-unused-comparison" HAVE_FLAGWno_unused_comparison)
  if(HAVE_FLAGWno_unused_comparison)
    target_compile_options(${name} PRIVATE -Wno-unused-comparison)
  endif()
  add_dependencies(build-units ${name})
  # Generate into bin/test/unit/<output_dir>.
  set(test_bin_dir ${CMAKE_BINARY_DIR}/bin/test/unit/${output_dir})
  set_target_properties(${name}
    PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${test_bin_dir})
  # The test target is prefixed with test identifier 'unit/' and the path,
  # e.g., for '<output_dir>/myunittest.h'
  #   we create test target 'unit/<output_dir>/myunittest'
  #   and run it with 'ctest -R "example/<output_dir>/myunittest"'.
  if("${output_dir}" STREQUAL "")
    set(test_name unit/${name})
  else()
    set(test_name unit/${output_dir}/${name})
  endif()
  add_test(${test_name} ${test_bin_dir}/${name})
  set_tests_properties(${test_name} PROPERTIES LABELS "unit")
endmacro()

macro(cvc4_add_unit_test_black name output_dir)
  cvc4_add_unit_test(FALSE ${name} ${output_dir})
endmacro()
macro(cvc4_add_unit_test_white name output_dir)
  cvc4_add_unit_test(TRUE ${name} ${output_dir})
endmacro()

add_subdirectory(api)
add_subdirectory(base)
add_subdirectory(context)
add_subdirectory(expr)
add_subdirectory(main)
add_subdirectory(parser)
add_subdirectory(printer)
add_subdirectory(prop)
add_subdirectory(theory)
add_subdirectory(preprocessing)
add_subdirectory(util)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback