diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a4c4450..3e592320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,11 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") set(PK_IS_MAIN TRUE) option(PK_BUILD_SHARED_LIB "Build shared library" OFF) option(PK_BUILD_STATIC_LIB "Build static library" OFF) + + include(CTest) + if (BUILD_TESTING) + add_subdirectory(tests/) + endif() else() set(PK_IS_MAIN FALSE) option(PK_BUILD_SHARED_LIB "Build shared library" OFF) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..bff5517c --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) + +function(pkpy_add_test pyfile) + get_filename_component(test_name ${pyfile} NAME_WE) + add_test( + NAME ${test_name} + COMMAND $ ${pyfile} + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/.. + ) + message("Added test " ${test_name}) +endfunction() + +file(GLOB PK_PYTHON_TESTCASES_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR}/.. "*.py") + +foreach(pyfile ${PK_PYTHON_TESTCASES_FILES}) + pkpy_add_test(${pyfile}) +endforeach()