Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not even add the testing executables when the tests are disabled. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dutow
Copy link

@dutow dutow commented Oct 6, 2017

The tests are currently targets excluded by the default target, so they aren't built.

But excluded targets are still generated, and created.

This has two results:

  • For IDE projects (like the visual studio generators), each test executable is added as a project, resulting in a long list. This is especially bad if you want to add boost-cmake using ADD_SUBDIRECTORY to your project: you most likely do not want to see those tests there. Maybe you want them on your CI, but definitely not during development.
  • These tests are also the reason why the "configure" phase of CMake takes minutes: by removing them, I reduced the project generation time of CMake to only a few seconds.

I simply reused the BUILD_TESTING option to not even include the test directories if it's not set. As you also used the off setting for some different behavior, I do not think this will be the correct/final solutions to it, but I do think that an option to disable them (and making that a default) would make the project more usable for end users.

I think this should be a more complex option to allow every possibility which was available previously, but for now, it'll do it for me:

* If I want to build the test suite, it'll build it
* If I don't need it (most of the time), it'll completely ignore test targets

Focus is on the second point, as most of the CMake configuration time was spent on the test targets. With this change, build file generation only takes a few seconds.
@pfultz2
Copy link
Member

pfultz2 commented Oct 6, 2017

Yea, we probably need a way to control whether tests are added or not, I am not sure the best way to do that yet.

One, I would like to be able to have tests be able to run without reconfiguring cmake if the dependencies are satisfied. The is probably only useful in a standalone build where the number of tests are small.

Secondly, I would like to be able to support partial checkouts of boost for building and testing. Someone only wants to test one library, so when BUILD_TESTING=Off, the tests are still added but the test dependencies are ignored if they dont exist.

We also need to support users who will use boost through add_subdirectory and is not concerned about running boost's test suite.

For IDE users, is there some property that can be set to better organize tests when they are shown in the IDE? For developers that are using Boost with tests and an IDE, there should be a better way its presented in the GUI.

@dutow
Copy link
Author

dutow commented Oct 6, 2017

The is probably only useful in a standalone build where the number of tests are small.

Yes, I am trying to use this as a subdirectory for building boost libraries in CMake projects, and the tests took far more time up than anything else. And anytime I changed any of my CMakeLists, it ran for several minutes again. In those projects, I am not interested in the results of the boost test suite. With this change, it's just a few seconds.

For IDE users, is there some property that can be set to better organize tests when they are shown in the IDE?

USE_FOLDERS and the FOLDER property. Supports even nested structures with the usual directory separators.

We also need to support users who will use boost through add_subdirectory and is not concerned about running boost's test suite.

This can be checked by using the PARENT_DIRECTORY property.

So maybe use this "do not add the tests by default" behavior if it's a subproject?

@ricejasonf
Copy link

I'm very interested in not running tests by default. Most libraries that I've used have an explicit target like make check for this.

My use case is for cross compiling.

Any progress on this?

@pfultz2
Copy link
Member

pfultz2 commented Apr 24, 2018

I'm very interested in not running tests by default. Most libraries that I've used have an explicit target like make check for this.

Thats the exactly how this works. However, the targets are still added, but not to the all target, which lets you run the tests without reconfiguring cmake(like what most projects do).

The issue:

  • it can be slow for MSVC to configure all the tests
  • All the tests fill up the IDE even when they aren't ran
  • Users may not want to run boost tests with their own tests when using integrated builds

Any progress on this?

I think the solution is to use an ENABLE_TESTS property perhaps with a default value from CMAKE_ENABLE_TESTS variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants