Disable testing when using BUILD_TESTING#1682
Conversation
|
Seems reasonable, but can't you do this without introducing a redundant option (which already exists internally in CMake). This will probably not work, but something like: |
|
ping? |
That option only exists if you include This is also similar to the
|
|
I thought I'd fixed issues like this, but my logic for The normal/simplest/best way to do this for a project that uses CTest (which I think we should look at using later) would be: if(PYBIND11_MASTER_PROJECT)
include(CTest) # defines BUILD_TESTING
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
endif()The downside is that you can't build the tests if this is not the master project, but in general that's not a good idea and probably not really supported anyway. |
CMake uses this variable to enable/disable tests in their CTest module(which is why the variable name is highlighted by github as a special value).
More importantly, it allows pybind to be installed directly with cget with
cget install pybind11/pybindsince cget also setsBUILD_TESTINGtoOffwhen not testing a package.It will still default to
Onwhen pybind is not a master project, andOffwhen it is not.