Skip to content

Commit 1556567

Browse files
committed
cmake: only build tst fixtures when ENABLE_TESTS is on
The tst_base fixture library links GTest::gtest, but that imported target only exists when find_package(GTest) runs, which is guarded by ENABLE_TESTS. add_subdirectory(tst) was unconditional, so a -no-tests build failed at generate time with 'Target tst_base links to GTest::gtest but the target was not found'. Guard add_subdirectory(tst) with ENABLE_TESTS. This is safe because every consumer of tst/tst_base/tst_integrated_fixture lives in a test/cpp directory that is itself gated by ENABLE_TESTS. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent 0db7e18 commit 1556567

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ if (NOT USE_SYSTEM_OPENSTA)
255255
endif()
256256
add_subdirectory(dbSta)
257257
add_subdirectory(rsz)
258-
add_subdirectory(tst)
258+
if(ENABLE_TESTS)
259+
# tst provides gtest-based fixture libraries used only by test targets, and
260+
# links GTest::gtest, which only exists when ENABLE_TESTS is on.
261+
add_subdirectory(tst)
262+
endif()
259263
add_subdirectory(stt)
260264
add_subdirectory(gpl)
261265
add_subdirectory(dpl)

0 commit comments

Comments
 (0)