Skip to content

Including CTest in the top-level CMakeLists.txt sets BUILD_TESTING=ON for parent projects #2513

Closed
@globberwops

Description

@globberwops

What is the issue you have?

BUILD_TESTING is unset in the main project.
nlohmann_json is included in a main project using FetchContent.
JSON_BuildTests=OFF is set in the main project.
nlohmann_json's top-level CMakeLists.txt includes CTest regardless.
BUILD_TESTING=ON is now set in the main project.

Please describe the steps to reproduce the issue.

message(STATUS "before BUILD_TESTING := ${BUILD_TESTING}") # prints ""
include(FetchContent)
FetchContent_Declare(
  nlohmann_json
  GIT_REPOSITORY https://github.com/nlohmann/json.git
  GIT_TAG develop)
set(JSON_BuildTests OFF)
FetchContent_MakeAvailable(nlohmann_json)
message(STATUS "after BUILD_TESTING := ${BUILD_TESTING}") # prints ON

What is the expected behavior?

CTest should only be included if nlohmann_json is the main project.

And what is the actual behavior instead?

CTest is included although nlohmann_json is added as subproject.

Which version of the library did you use?

  • latest release version 3.9.1
  • other release - please state the version: ___
  • the develop branch

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions