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

Allow packages to use project() #582

Open
masterleinad opened this issue May 19, 2023 · 4 comments
Open

Allow packages to use project() #582

masterleinad opened this issue May 19, 2023 · 4 comments

Comments

@masterleinad
Copy link
Contributor

masterleinad commented May 19, 2023

trilinos/Trilinos#11779 explores using Kokkos as a native CMake project within Trilinos' TriBITS build system. In the process, I noticed that tribits_package_postprocess doesn't work properly if the package uses project(), see https://github.com/trilinos/Trilinos/pull/11779/files#r1196855222, since

if (${PACKAGE_NAME}_SOURCE_DIR STREQUAL ${PROJECT_NAME}_SOURCE_DIR)

would report that the code is executed at the top level instead of at the package level and then set ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS in the same scope instead of in the parent scope.
Using $(CMAKE_PROJECT_NAME}_SOURCE_DIR) instead of $(PROJECT_NAME}_SOURCE_DIR) fixes this for me.
Note that there might be more cases where it would be more appropriate to check for CMAKE_PROJECT_NAME instead of PROJECT_NAME but this appears sufficient for my case.

@bartlettroscoe
Copy link
Member

I will take care of this when I extend the TriBITS example/test case TribitsExampleProject2/packages/packages1/ to use a raw CMake build system to be TriBITS-compliant for an internal build with calling no TriBITS code.

bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 14, 2023
…ject (TriBITSPub#582)

Now we can update TriBITS and the raw Package1 build system for it to work as
a TriBITS package but without calling any TriBITS macros or functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 18, 2023
This makes the documentation ad code a little more clear.

As part of this, I renamed the function
`tribits_write_package_client_export_files_install_targets()` to `
tribits_write_package_client_export_files_export_and_install_targets()`.  That
makes it a little more clear what these functions are doing.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 18, 2023
NOTE: This does not pass all of the existing tests yet but the new tests pass.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 18, 2023
…w CMake (TriBITSPub#582)

This raw CMake build mode for Package1 uses no TriBITS macros, functions, or
other functionality at all.

The only change to TriBITS-proper were:

* Skip check for not calling tribits_package_postprocess() if the
  `<Package>::all_libs` target is already defined.

* Build up the list of package libraries target for the `<Project>_libs`
  target from `<Package>::all_libs` instead of `<Package>_libs`.

This seems to pass all of the TriBITS tests.
bartlettroscoe added a commit that referenced this issue Jul 26, 2023
…stall_targets() (#582)

Don't know how this was allowed to merge given that the build of the docs was
broken by the renaming of
`tribits_write_package_client_export_files_install_targets()` to
`tribits_write_package_client_export_files_export_and_install_targets()`.

But this fixes that.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…stall_targets() (TriBITSPub#582)

Don't know how this was allowed to merge given that the build of the docs was
broken by the renaming of
`tribits_write_package_client_export_files_install_targets()` to
`tribits_write_package_client_export_files_export_and_install_targets()`.

But this fixes that.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…stall_targets() (TriBITSPub#582)

Don't know how this was allowed to merge given that the build of the docs was
broken by the renaming of
`tribits_write_package_client_export_files_install_targets()` to
`tribits_write_package_client_export_files_export_and_install_targets()`.

But this fixes that.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…ject (TriBITSPub#582)

Now we can update TriBITS and the raw Package1 build system for it to work as
a TriBITS package but without calling any TriBITS macros or functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
This makes the documentation ad code a little more clear.

As part of this, I renamed the function
`tribits_write_package_client_export_files_install_targets()` to `
tribits_write_package_client_export_files_export_and_install_targets()`.  That
makes it a little more clear what these functions are doing.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
NOTE: This does not pass all of the existing tests yet but the new tests pass.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…w CMake (TriBITSPub#582)

This raw CMake build mode for Package1 uses no TriBITS macros, functions, or
other functionality at all.

The only change to TriBITS-proper were:

* Skip check for not calling tribits_package_postprocess() if the
  `<Package>::all_libs` target is already defined.

* Build up the list of package libraries target for the `<Project>_libs`
  target from `<Package>::all_libs` instead of `<Package>_libs`.

This seems to pass all of the TriBITS tests.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…ject (TriBITSPub#582)

Now we can update TriBITS and the raw Package1 build system for it to work as
a TriBITS package but without calling any TriBITS macros or functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
This makes the documentation ad code a little more clear.

As part of this, I renamed the function
`tribits_write_package_client_export_files_install_targets()` to `
tribits_write_package_client_export_files_export_and_install_targets()`.  That
makes it a little more clear what these functions are doing.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
NOTE: This does not pass all of the existing tests yet but the new tests pass.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…w CMake (TriBITSPub#582)

This raw CMake build mode for Package1 uses no TriBITS macros, functions, or
other functionality at all.

The only change to TriBITS-proper were:

* Skip check for not calling tribits_package_postprocess() if the
  `<Package>::all_libs` target is already defined.

* Build up the list of package libraries target for the `<Project>_libs`
  target from `<Package>::all_libs` instead of `<Package>_libs`.

This seems to pass all of the TriBITS tests.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
…ject (TriBITSPub#582)

Now we can update TriBITS and the raw Package1 build system for it to work as
a TriBITS package but without calling any TriBITS macros or functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
This makes the documentation ad code a little more clear.

As part of this, I renamed the function
`tribits_write_package_client_export_files_install_targets()` to `
tribits_write_package_client_export_files_export_and_install_targets()`.  That
makes it a little more clear what these functions are doing.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2023
Allow TriBITS package TribitsExampleProject/Package1 to use 100% raw CMake and
update TriBITS to allow that.

This raw CMake build mode for Package1 uses no TriBITS macros, functions, or
other functionality at all.

The only changes to TriBITS-proper needed to allow this were:

* Skip check for not calling tribits_package_postprocess() if the
  `<Package>::all_libs` target is already defined.

* Build up the list of package libraries target for the `<Project>_libs`
  target from `<Package>::all_libs` instead of `<Package>_libs` (since the
  latter does not exist for a raw CMake package).

This seems to pass all of the TriBITS tests.

NOTE: This commit does **not** yet contain the changes to TriBITS to allow
calling project() in the package's CMakeLists.txt files and still use TriBITS
macros in the package's CMakeLists.txt files.  Those changes will come later
as we add an example that calls some TriBITS functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 28, 2023
…ject (TriBITSPub#582)

Now we can update TriBITS and the raw Package1 build system for it to work as
a TriBITS package but without calling any TriBITS macros or functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 28, 2023
This makes the documentation ad code a little more clear.

As part of this, I renamed the function
`tribits_write_package_client_export_files_install_targets()` to `
tribits_write_package_client_export_files_export_and_install_targets()`.  That
makes it a little more clear what these functions are doing.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 28, 2023
Allow TriBITS package TribitsExampleProject/Package1 to use 100% raw CMake and
update TriBITS to allow that.

This raw CMake build mode for Package1 uses no TriBITS macros, functions, or
other functionality at all.

The only changes to TriBITS-proper needed to allow this were:

* Skip check for not calling tribits_package_postprocess() if the
  `<Package>::all_libs` target is already defined.

* Build up the list of package libraries target for the `<Project>_libs`
  target from `<Package>::all_libs` instead of `<Package>_libs` (since the
  latter does not exist for a raw CMake package).

This seems to pass all of the TriBITS tests.

NOTE: This commit does **not** yet contain the changes to TriBITS to allow
calling project() in the package's CMakeLists.txt files and still use TriBITS
macros in the package's CMakeLists.txt files.  Those changes will come later
as we add an example that calls some TriBITS functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Aug 4, 2023
…ject (TriBITSPub#582)

Now we can update TriBITS and the raw Package1 build system for it to work as
a TriBITS package but without calling any TriBITS macros or functions.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Aug 4, 2023
This makes the documentation ad code a little more clear.

As part of this, I renamed the function
`tribits_write_package_client_export_files_install_targets()` to `
tribits_write_package_client_export_files_export_and_install_targets()`.  That
makes it a little more clear what these functions are doing.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 8, 2023
…riBITSPub#582)

Makes it more clear what is needed for an internal package and an external
package.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 8, 2023
…riBITSPub#582)

This will allow me to exclude parts that I don't want to show in the
developers guide.

NOTE: The only reas the test file TribitsExampleProject2_Tests.cmake is
updated is because I took 'a' out of 'in a raw'.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 8, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 12, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 14, 2023
…riBITSPub#582)

This will allow me to exclude parts that I don't want to show in the
developers guide.

NOTE: The only reas the test file TribitsExampleProject2_Tests.cmake is
updated is because I took 'a' out of 'in a raw'.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 14, 2023
…ub#582)

This change was made several years ago but we forgot to update this
documentation.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 14, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 14, 2023
Several things were done here:

* Added new section "How to implement a TriBITS-compliant internal package
  using raw CMake"

* Added new section "How to implement a TriBITS-compliant external package
  using raw CMake"

* Added subsection on example project TribitsExampleProject2 under the "Example
  TriBITS Projects" section.

* Added generation of reduced versions of the package1/CMakeLists.raw.cmake
  file for different cases.  (But will only trigger a re-make if the generated
  files change.)

* Added make dependencies on generated *.cmake files

* generate-guide.sh: Added time to 'make' command and discard STDOUT for 'cd
-' command (makes output look better)
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 19, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 19, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 19, 2023
…riBITSPub#582)

Now just calls tribits_set_cache_var_and_default() then mark_as_advanced().

Suggested by @KyleFromKitware
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 19, 2023
…iBITSPub#582)

This commit exposes the bug described in:

  https://gitlab.kitware.com/cmake/cmake/-/issues/25157

and provides the suggested print statements by Brad King.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 21, 2023
…riBITSPub#582)

This will allow me to exclude parts that I don't want to show in the
developers guide.

NOTE: The only reas the test file TribitsExampleProject2_Tests.cmake is
updated is because I took 'a' out of 'in a raw'.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 21, 2023
…ub#582)

This change was made several years ago but we forgot to update this
documentation.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 21, 2023
Several things were done here:

* Added new section "How to implement a TriBITS-compliant internal package
  using raw CMake"

* Added new section "How to implement a TriBITS-compliant external package
  using raw CMake"

* Added subsection on example project TribitsExampleProject2 under the "Example
  TriBITS Projects" section.

* Added generation of reduced versions of the package1/CMakeLists.raw.cmake
  file for different cases.  (But will only trigger a re-make if the generated
  files change.)

* Added make dependencies on generated *.cmake files

* generate-guide.sh: Added time to 'make' command and discard STDOUT for 'cd
-' command (makes output look better)
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 21, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 21, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Sep 21, 2023
…riBITSPub#582)

Now just calls tribits_set_cache_var_and_default() then mark_as_advanced().

Suggested by @KyleFromKitware
bartlettroscoe added a commit that referenced this issue Sep 21, 2023
Allow 100% raw CMake to be used in a TriBITS-compliant package (#582)
@bartlettroscoe
Copy link
Member

bartlettroscoe commented Sep 22, 2023

@masterleinad, would you be willing to review the documentation and examples on how to use 100% raw CMake to create a TriBITS-compliant internal and external package:

?

Specifically, can you please review the documentation and examples at:

?

bartlettroscoe added a commit to bartlettroscoe/Trilinos that referenced this issue Sep 23, 2023
…bits

This brings in the following TriBITS PRs:

* TriBITSPub/TriBITS#591: Allow 100% raw CMake to be used in a
  TriBITS-compliant package (TriBITSPub/TriBITS#582)

* TriBITSPub/TriBITS#588: gitdist: Pass in '-c color.status=always' when
  --dist-no-color is not added

* TriBITSPub/TriBITS#590: Fix: gitdist: dist-repo-status: Display tag or SHA1
  instead of 'HEAD'

* TriBITSPub/TriBITS#587: gitdist: dist-repo-status: Display tag or SHA1
  instead of 'HEAD'

* TriBITSPub/TriBITS#586: More cleanup of packaging support
  (trilinos#11976)

This goes back to TriBITS commits from June 2023.
@masterleinad
Copy link
Contributor Author

@masterleinad, would you be willing to review the documentation and examples on how to use 100% raw CMake to create a TriBITS-compliant internal and external package [...]

See #591 (reference) for some quick feedback.

bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Oct 9, 2023
This improves the message as suggested by @masterleinad in the review of PR
configured "within a TriBITS project" but is not really being configured "with
TriBITS".  (Package1 is being configured with 100% raw CMake, it just happens
to be configured under a TriBITS project.)
@bartlettroscoe
Copy link
Member

When using raw CMake inside of this package, this is a resolved issue as of the merge of PR:

However, if using TriBITS functions inside of the package, then some more work would need to be done (to differentiate the TriBITS project name and base source and binary directories from the most recent call to project()).

So, this should address the Kokkos use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Review
Development

No branches or pull requests

2 participants