Skip to content

Commit 45eb531

Browse files
CMakeLists: fix test procedure
1 parent ce47d6f commit 45eb531

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ if(BUILD_EXAMPLES)
1414
endif()
1515

1616
option(BUILD_TESTS "Build tests" ON)
17+
set(GOOGLE_TEST_DIR "" CACHE PATH "Path to GoogleTest source")
18+
1719
if(BUILD_TESTS)
18-
set(GOOGLE_TEST_DIR "" CACHE PATH "Path to GoogleTest source")
20+
enable_testing()
21+
22+
if(GOOGLE_TEST_DIR)
23+
add_subdirectory(${GOOGLE_TEST_DIR} googletest)
24+
else()
25+
find_package(GTest REQUIRED)
26+
endif()
27+
1928
add_subdirectory(test)
2029
endif()

test/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# test
22

3-
enable_testing()
4-
5-
if(GOOGLE_TEST_DIR)
6-
add_subdirectory(${GOOGLE_TEST_DIR} googletest)
7-
else()
8-
find_package(GTest REQUIRED)
9-
endif()
10-
113
add_executable(test_args test_args.cpp)
124
target_link_libraries(test_args pgm::args GTest::gtest_main)
135

0 commit comments

Comments
 (0)