diff --git a/CMakeLists.txt b/CMakeLists.txt index ebb0b94..d609d02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,5 +7,10 @@ project(search_engine VERSION 1.0) add_subdirectory(lib) -include(FetchContent) -add_subdirectory(tests/unit-tests) +option(BUILD_TESTS "Build and enable tests" ON) + +if (BUILD_TESTS) + enable_testing() + include(FetchContent) + add_subdirectory(tests/unit-tests) +endif() diff --git a/build.py b/build.py index 3e20ce8..db28b79 100644 --- a/build.py +++ b/build.py @@ -25,7 +25,7 @@ def build_lib_cpp(path: str): old_path = os.getcwd() os.makedirs(path) os.chdir(path) - subprocess.run(["cmake", ".."]) + subprocess.run(["cmake", "..", "-DBUILD_TESTS=OFF"]) subprocess.run(["make"]) os.chdir(old_path) @@ -43,6 +43,7 @@ def build(setup_kwargs): extensions = [] + for lib in libs_names: ext = Extension( f"{lib}", diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 615cc92..34ca14c 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -19,4 +19,8 @@ add_executable( target_include_directories(LibUnitTests PRIVATE ${CMAKE_SOURCE_DIR}/lib/include/) -target_link_libraries(LibUnitTests PRIVATE gtest_main search_engine) \ No newline at end of file +target_link_libraries(LibUnitTests PRIVATE gtest_main search_engine) + +# Add command cmake test +include(GoogleTest) +gtest_discover_tests(LibUnitTests) \ No newline at end of file