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

CMake examples targets #2429

Merged
merged 2 commits into from
Oct 7, 2021
Merged

CMake examples targets #2429

merged 2 commits into from
Oct 7, 2021

Conversation

bendudson
Copy link
Contributor

If BOUT_BUILD_EXAMPLES is Off, add the examples subdirectory but with the EXCLUDE_FROM_ALL option. That enables examples to be built after the library is built, and specific examples can be built by using the --target argument to cmake.

If BOUT_BUILD_EXAMPLES is Off, add the examples subdirectory
but with the EXCLUDE_FROM_ALL option. That enables examples
to be built after the library is built, and specific examples
can be built by using the `--target` argument to `cmake`.
@ZedThree
Copy link
Member

Ah sorry, I think my earlier comment was misleading -- you can build individual examples with --target but you would still need to configure with BOUT_BUILD_EXAMPLES=on.

dschwoerer
dschwoerer previously approved these changes Sep 30, 2021
Copy link
Contributor

@dschwoerer dschwoerer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@bendudson
Copy link
Contributor Author

I think this may be a little more complicated than I initially thought. There are I think three scenarios to cover:

  1. BOUT-dev is being included as a sub-module of a model, so we just want the library and are not interested in examples
  2. We are first compiling the library, then later may want to compile one or more examples (I think this should be the default)
  3. We want to build executables for all examples. I don't think this will happen often, but should be an option at least for testing if all examples can build

Previously the BOUT_BUILD_EXAMPLES switch chose between (1) and (3); this PR changes it to choosing between (2) and (3).

What about:
BOUT_CONFIGURE_EXAMPLES is On by default, and adds the examples to the cmake build. Turning it Off also turns BOUT_BUILD_EXAMPLES to Off. This switches between (1) and (2 or 3)
BOUT_BUILD_EXAMPLES is Off by default. It controls whether EXCLUDE_FROM_ALL is used when adding the examples. It switches between (2) and (3)
?

@ZedThree
Copy link
Member

ZedThree commented Oct 2, 2021 via email

CMake switch BOUT_BUILD_EXAMPLES now controls whether the examples
directory is added. It is ON by default, and adds the examples
with the EXCLUDE_FROM_ALL flag.

To actually build all examples, this adds a build-all-examples target,
and examples are added to it. Specific examples can be built by using
specific targets or cd'ing into their directory (in the build directory)
and running "make".

If BOUT_BUILD_EXAMPLES is turned OFF, then the examples are not copied
into the build directory. This could be used if BOUT++ is a sub-module
of another project.
@ZedThree ZedThree merged commit 26d8341 into next Oct 7, 2021
@ZedThree ZedThree deleted the cmake-examples-targets branch October 7, 2021 15:54
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.

None yet

3 participants