KhronosGroup / OpenCL-CLHPP

Khronos OpenCL-CLHPP
Apache License 2.0
375 stars 130 forks source link

Default values for options BUILD_EXAMPLES and BUILD_DOCS #283

Open mfep opened 10 months ago

mfep commented 10 months ago

The following describes a discrepancy in the CMake scripts of the OpenCL-CLHPP project:

bashbaug commented 10 months ago

I'm starting to think the best option is to simply change the default for BUILD_EXAMPLES and BUILD_DOCS from enabled to disabled. I can't think of a clever way to set things up that would have better defaults and still retain full configurability.

If we did something simlilar to what we do for testing, like...

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR BUILD_EXAMPLES)

... we could also keep building the examples or the docs by default when this project is the root project, but we also wouldn't have any mechanism to disable building the samples or the docs when this project is the root project, either, and I think this type of configurability is important.

Is there a way to set the default for the option to enabled when this project is the root project, and disabled otherwise, but still allow explicitly enabling and disabling the option in both cases? I'm aware of CMakeDependentOption but this doesn't seem to do what I'd like to do since it hides the option vs. changing the default when the dependencies are not satisfied.