option(with_sfdp "sfdp layout engine." ON )
option(with_smyrna "SMYRNA large graph viewer (disabled by default - experimental)" OFF)
option(use_sanitizers "enables using address and undefined behavior sanitizer" OFF)
+option(with_cxx_tests "enables building the C++ tests" OFF)
if (enable_ltdl)
add_definitions(-DENABLE_LTDL)
include(package_info)
include(CPack)
+# ==================================== Test ====================================
+Include(CTest)
+
# ======================= Specify subdirectories to build ======================
add_subdirectory(lib)
add_subdirectory(plugin)
add_subdirectory(cmd)
+if (with_cxx_tests)
+ add_subdirectory(tests)
+endif()
MATH(EXPR GRAPHVIZ_PLUGIN_VERSION "${GRAPHVIZ_PLUGIN_VERSION}+1")
set(GVPLUGIN_VERSION "${GRAPHVIZ_PLUGIN_VERSION}")
--- /dev/null
+cmake_minimum_required (VERSION 3.12 FATAL_ERROR)
+
+find_package(Catch2 REQUIRED)
+
+enable_testing()
+
+if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
+ add_compile_options(-Wextra)
+endif()
+
+# for convenience, make a library that depends on everything so each
+# separate test can be as small as possible
+add_library(test_common STATIC
+ catch2_main.cpp
+ )
+set_target_properties(test_common PROPERTIES CXX_STANDARD 20)
+set_target_properties(test_common PROPERTIES CXX_STANDARD_REQUIRED ON)
+target_link_libraries(test_common PUBLIC Catch2::Catch2)
+
+macro(create_test testname)
+ add_executable(test_${testname} test_${testname}.cpp)
+ set_target_properties(test_${testname} PROPERTIES CXX_STANDARD 20)
+ set_target_properties(test_${testname} PROPERTIES CXX_STANDARD_REQUIRED ON)
+ add_test(NAME test_${testname} COMMAND test_${testname})
+ target_link_libraries(test_${testname} PRIVATE
+ test_common
+ )
+endmacro()
+
+create_test(simple)