Skip to content

Only fetch GoogleTest when DLAF_BUILD_TESTING is ON - #1366

Open
mohitt31 wants to merge 1 commit into
eth-cscs:masterfrom
mohitt31:fix-gtest-fetchcontent-issue-26
Open

Only fetch GoogleTest when DLAF_BUILD_TESTING is ON#1366
mohitt31 wants to merge 1 commit into
eth-cscs:masterfrom
mohitt31:fix-gtest-fetchcontent-issue-26

Conversation

@mohitt31

@mohitt31 mohitt31 commented Aug 11, 2026

Copy link
Copy Markdown

Closes #26.

external/CMakeLists.txt was unconditionally running FetchContent_Declare/FetchContent_MakeAvailable for GoogleTest during CMake configure, regardless of whether tests were going to be built. This meant every configure (including -DDLAF_BUILD_TESTING=OFF builds, e.g. library-only installs) cloned GoogleTest from GitHub and configured it, even though nothing would ever use it.

Change: wrap the GoogleTest FetchContent block in if(DLAF_BUILD_TESTING) ... endif(), matching the existing option already used to gate add_subdirectory(test) in the top-level CMakeLists.txt.

Verified locally (isolated CMake harness, since I don't have the full DLAF dependency stack available):

  • -DDLAF_BUILD_TESTING=OFF: configure completes, no _deps/googletest-* directories are created.
  • -DDLAF_BUILD_TESTING=ON: configure completes and GoogleTest is fetched/configured exactly as before (_deps/googletest-src, -build, -subbuild all present).

external/CMakeLists.txt unconditionally ran FetchContent for
GoogleTest during CMake configure, regardless of DLAF_BUILD_TESTING.
Wrap the fetch in if(DLAF_BUILD_TESTING) so library-only configures
(-DDLAF_BUILD_TESTING=OFF) don't clone and configure GoogleTest for
nothing.

Closes eth-cscs#26.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

GTest library is always fetched even if it is not used

1 participant