@@ -13,14 +13,20 @@ endif()
1313
1414message (STATUS "Building in ${CMAKE_BUILD_TYPE } mode" )
1515
16+ option (ENABLE_TESTING "Enable C++ and testing features" ON )
17+
1618enable_testing ()
1719
1820if (NOT DEFINED BLA_VENDOR)
1921 set (BLA_VENDOR OpenBLAS)
2022endif ()
2123message (STATUS "Using BLAS vendor: ${BLA_VENDOR} " )
2224find_package (BLAS REQUIRED )
23- find_package (GTest REQUIRED )
25+
26+ if (ENABLE_TESTING)
27+ find_package (GTest REQUIRED )
28+ endif ()
29+
2430
2531file (GLOB_RECURSE SRC_FILES src/*.c EXCLUDE "src/main.c" )
2632file (GLOB_RECURSE TEST_FILES test /*.cpp )
@@ -62,12 +68,14 @@ apply_target(${PROJECT_NAME})
6268target_link_libraries (${PROJECT_NAME } PRIVATE libcneuron )
6369
6470# Test executable
65- add_executable (tests ${TEST_FILES} )
66- apply_target (tests )
67- target_include_directories (tests PRIVATE ${CMAKE_SOURCE_DIR } /test )
68- target_link_libraries (tests PRIVATE libcneuron GTest::gtest_main )
71+ if (ENABLE_TESTING)
72+ add_executable (tests ${TEST_FILES} )
73+ apply_target (tests )
74+ target_include_directories (tests PRIVATE ${CMAKE_SOURCE_DIR } /test )
75+ target_link_libraries (tests PRIVATE libcneuron GTest::gtest_main )
76+ add_test (NAME tests COMMAND tests )
77+ endif ()
6978
70- add_test (NAME tests COMMAND tests )
7179
7280message (STATUS "Copying data and input.py to the build directory..." )
7381file (COPY ${CMAKE_SOURCE_DIR } /data ${CMAKE_SOURCE_DIR } /input.py DESTINATION ${CMAKE_BINARY_DIR } )
@@ -78,4 +86,5 @@ add_custom_target(run
7886 COMMAND ${CMAKE_COMMAND } -E echo "Building in: ${CMAKE_BUILD_TYPE } mode"
7987 COMMAND ${CMAKE_BINARY_DIR } /${PROJECT_NAME}
8088 DEPENDS ${PROJECT_NAME } tests
89+ $<$<BOOL :${ENABLE_TESTING} >:tests >
8190)
0 commit comments