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

EPIC: Refactoring TriBITS Core and TriBITS-based CMake projects to conform to modern CMake #411

Open
bartlettroscoe opened this issue Aug 30, 2021 · 3 comments
Labels
component: core type: enhancement type: refactor Changes are mostly just a refactoring

Comments

@bartlettroscoe
Copy link
Member

bartlettroscoe commented Aug 30, 2021

Blocked by::

Description

An initial version of TriBITS was created back in 2008 when CMake was on version 2.6.z (prior to 2.8, when CMake was still using even numbers for releases). There was a lot missing in those early versions of CMake needed to create a portable, scalable, build system for something like Trilinos. Therefore, a lot of features had to be added to TriBITS in those early days and in the next few years to address development, testing, and deployment challenges of Trilinos and other projects. That CMake build system was split out of Trilinos and named "TriBITS" around 2011 as part of the CASL project and was reused in several other projects (where it is still used today) and the majority of the development work for what is now TriBITS was completed by around 2014 (around the time that CMake 3.0 was released).

Around CMake 3.0 (which was not released until 2014), great improvements started to be made in CMake and the idioms for its usage, and the usage of CMake steadily improved across the computational and scientific and engineering community. In the 12 years since TriBITS was first created and especially in the last 7 years since CMake 3.0 and future releases of CMake 3.Y have come out, a lot of the functionality that was added to TriBITS has since been added to CMake proper and has been slowly adopted by the larger software development community using CMake. While reading the book "Professional CMake: 10th Edition", I have come to realize just how much of the functionality that we had to add to TriBITS ourselves has now been added to CMake proper. (And reading that book one realizes just how much functionality has been added to CMake in general since CMake 3.0 to address so many difficult cross-platform issues.)

It is in the best interest of Trilinos and all of the projects that use TriBITS to refactor their CMake build systems (and TriBITS itself) to switch over to the newer native CMake implementations of these features and to remove these features from TriBITS. In this process, TriBITS should be reduced the its smallest useful essence that provides value and does not stand in the way of adopting future CMake features as those are added in future CMake releases.

However, these changes need to be made incrementally against the develop branch of Trilinos and the master branch of TriBITS with frequent topic branch and frequent integrations to smooth the transitions with Trilinos developers and users.

This epic will list some of the areas where TriBITS, Trilinos, and other projects using TriBITS should be refactored to use native modern CMake features and idoms:

  • Switch from using deprecated find_package(PythonInterp) to find_package(Python3) to accommodate python3 installations (see Switch from find_package(PythonInterp) to find_package(Python3) #610). [Major break in backward comparability]

  • Use the standard CMake FortranCInterface.cmake module to handle Fortran/C name mangling. (This will replace a module copied into TriBITS back in 2007 that does this manually at configure time.) [Minor break in backward comparability]

  • Require standard install locations defined by the standard GNUInstallDirs.cmake module and vars CMAKE_INSTALL_<XXX> for BINDIR, LIBDIR, LIBDIR, INCLUDEDIR and replace TriBITS-defined locations <Project>_INSTALL_INCLUDE_DIR, <Project>_INSTALL_LIB_DIR, <Project>_INSTALL_RUNTIME_DIR. (NOTE: GNUInstallDirs.cmake has no equivalent for <Project>_INSTALL_EXAMPLE_DIR.) [Minor break in backward comparability]

  • Replace and remove old TriBITS General Utility Macros and Functions that have native implementations in newer versions of raw CMake. (E.g., append_string_var() => string(APPEND ...), append_string_var_with_sep() => string(JOIN ...), concat_strings() => string(CONCAT ...), join() => string(JOIN ...), multiline_set() => string(CONCAT ...), etc.)

  • Revise how RPATH is handled with TriBITS according to new RPATH variables and target properties for more flexibility and to better support relocatable installs (i.e. set set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN${relBinToLibDir}) by default) . (Or, strip out RPATH handling altogether from TriBITS and leave raw CMake behavior for projects to deal with themselves.) [Minor break in backward comparability]

  • Use correct CamelCase for CMAKE_BULD_TYPE (see Allow CamelCase names for CMAKE_BUILD_TYPE ‘Debug’, ‘Release’ and empty '' #131) [Minor break in backward comparability]

  • Support multi-configuration generators (e.g. Ninja and Visual Code), which requires not relying on CMAKE_BULD_TYPE and instead using generator expressions

  • TriBITS stop setting/manipulating compiler options:

  • Switch deprecated code macros to the deprecation macros with the GenerateExportHeader.cmake module and the generate_export_header() function. [Minor break in backward comparability]

  • Switch from manual include guards to include_guard().

  • Move numerous checks for things like time.h, stdinit.h, inittypes.h, checks for isnan(), isinf(), etc., checks for doxygen, out of TriBITS env probing (individual projects or even individual packages should be doing that). [Minor break in backward comparability]

  • Consider switching to using find_package(MPI) (and the standard CMake FindMPI.cmake module) [Major break in backward comparability?]

  • ???

Completed refactorings

Child Issues

@bartlettroscoe bartlettroscoe changed the title EPIC: Refactoring TriBITS and TriBITS-based CMake projects to confirm to modern CMake standards EPIC: Refactoring TriBITS Core and TriBITS-based CMake projects to conform to modern CMake standards Aug 30, 2021
@bartlettroscoe bartlettroscoe changed the title EPIC: Refactoring TriBITS Core and TriBITS-based CMake projects to conform to modern CMake standards EPIC: Refactoring TriBITS Core and TriBITS-based CMake projects to conform to modern CMake Aug 31, 2021
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Oct 22, 2021
…riBITSPub#411)

I just noticed that CMake 3.17 suppports string(APPEND ...).  The more that we
can remove from TriBITS the better.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Oct 23, 2021
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Oct 23, 2021
…riBITSPub#411)

I just noticed that CMake 3.17 suppports string(APPEND ...).  The more that we
can remove from TriBITS the better.
bartlettroscoe added a commit to bartlettroscoe/Trilinos that referenced this issue Feb 21, 2023
All of the major systems at SNL and LLNL should have CMake 3.23+ installed.

This allows the elimination of a lot of technical debt in TriBITS (see
TriBITSPub/TriBITS#411).
bartlettroscoe added a commit to bartlettroscoe/Trilinos that referenced this issue Feb 23, 2023
All of the major systems at SNL and LLNL should have CMake 3.23+ installed.

This allows the elimination of a lot of technical debt in TriBITS (see
TriBITSPub/TriBITS#411).
bartlettroscoe added a commit to bartlettroscoe/Trilinos that referenced this issue Feb 23, 2023
All of the major systems at SNL and LLNL should have CMake 3.23+ installed.

This allows the elimination of a lot of technical debt in TriBITS (see
TriBITSPub/TriBITS#411).
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 25, 2023
This is part of allowing TriBITS to take advantage of newer CMake features and
replacing some older TriBITS code that now has (better or compatiable) native
implementations in CMake (many years later).

The min version of CMake 3.23 is chosen due to Trilinos (see
trilinos/Trilinos#10355).

Some non-obvious changes made were:

* For some reason, find_file() wiht CMake 3.23 (and using CMak 3.23 default
  policies) adds on an extra '/' before the file name.  This messed up the
  test checks but I fixed that by putting in '[/]*' in the regex to account
  for that.

* Updated the GitHub Actions testing jobs to all be CMake 3.23+.  (I updated
  the patch versions as well to the most recent patch releases as of right
  now.  CMake 3.25 is still the most recent release of CMake as CMake 3.26 is
  still in release candidate testing.)

* Add checks for setting CTEST_RESOURCE_SPEC_FILE in CTestTestfile.cmake now
  that CMake is >= 3.18.

* Removed constant ${PROJECT_NAME}_CTEST_USE_NEW_AAO_FEATURES since it is
  hard-coded since CMake is 3.17+.

* Removed some documentation discussing older versions of CMakew (which are no
  longer supported).

* install-cmake.py: Changed the default version of CMake to install from 3.17
  to 3.23.

* install-cmake.py: Removed patch for CMake 3.17

* Removed documentation for Kitware fork of Ninja version < 1.10 since Ninja
  1.10 has been out for many years.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 25, 2023
This is part of allowing TriBITS to take advantage of newer CMake features and
replacing some older TriBITS code that now has (better or compatiable) native
implementations in CMake (many years later).

The min version of CMake 3.23 is chosen due to Trilinos (see
trilinos/Trilinos#10355).

Some non-obvious changes made were:

* For some reason, find_file() wiht CMake 3.23 (and using CMak 3.23 default
  policies) adds on an extra '/' before the file name.  This messed up the
  test checks but I fixed that by putting in '[/]*' in the regex to account
  for that.

* Updated the GitHub Actions testing jobs to all be CMake 3.23+.  (I updated
  the patch versions as well to the most recent patch releases as of right
  now.  CMake 3.25 is still the most recent release of CMake as CMake 3.26 is
  still in release candidate testing.)

* Add checks for setting CTEST_RESOURCE_SPEC_FILE in CTestTestfile.cmake now
  that CMake is >= 3.18.

* Removed constant ${PROJECT_NAME}_CTEST_USE_NEW_AAO_FEATURES since it is
  hard-coded since CMake is 3.17+.

* Removed some documentation discussing older versions of CMakew (which are no
  longer supported).

* install-cmake.py: Changed the default version of CMake to install from 3.17
  to 3.23.

* install-cmake.py: Removed patch for CMake 3.17

* Removed documentation for Kitware fork of Ninja version < 1.10 since Ninja
  1.10 has been out for many years.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 25, 2023
This is part of allowing TriBITS to take advantage of newer CMake features and
replacing some older TriBITS code that now has (better or compatiable) native
implementations in CMake (many years later).

The min version of CMake 3.23 is chosen due to Trilinos (see
trilinos/Trilinos#10355).

Some non-obvious changes made were:

* For some reason, find_file() wiht CMake 3.23 (and using CMak 3.23 default
  policies) adds on an extra '/' before the file name.  This messed up the
  test checks but I fixed that by putting in '[/]*' in the regex to account
  for that.

* Updated the GitHub Actions testing jobs to all be CMake 3.23+.  (I updated
  the patch versions as well to the most recent patch releases as of right
  now.  CMake 3.25 is still the most recent release of CMake as CMake 3.26 is
  still in release candidate testing.)

* Add checks for setting CTEST_RESOURCE_SPEC_FILE in CTestTestfile.cmake now
  that CMake is >= 3.18.

* Removed constant ${PROJECT_NAME}_CTEST_USE_NEW_AAO_FEATURES since it is
  hard-coded since CMake is 3.17+.

* Removed some documentation discussing older versions of CMakew (which are no
  longer supported).

* install-cmake.py: Changed the default version of CMake to install from 3.17
  to 3.23.

* install-cmake.py: Removed patch for CMake 3.17

* Removed documentation for Kitware fork of Ninja version < 1.10 since Ninja
  1.10 has been out for many years.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 25, 2023
This is the first step in allowing TriBITS to take advantage of newer CMake
features and replacing some older TriBITS code that now has (better or
compatible) native implementations in CMake (many years after the TriBITS
support was created).

The min version of CMake 3.23 is chosen due to Trilinos changing its min
version to 3.23 (see trilinos/Trilinos#10355).

Some non-obvious changes made in this commit were:

* For some reason, find_file() with CMake 3.23 (and using CMake 3.23 default
  policies) adds on an extra '/' before the file name in the found path.  This
  messed up some of the test checks in TriBITS but I fixed that by putting
  '[/]*' in the regex to account for that extra '/'.

* Updated the GitHub Actions testing jobs to all be CMake 3.23+.  (I updated
  the patch versions of the different versions as well to the most recent
  patch releases for those minor versions as of right now.  CMake 3.25 is
  still the most recent release of CMake as CMake 3.26 is still in release
  candidate testing.  Therefore, CMake 3.26.2 is still the most current
  release of CMake.)

* Added checks for setting CTEST_RESOURCE_SPEC_FILE in CTestTestfile.cmake now
  that CMake is >= 3.18.

* Removed constant ${PROJECT_NAME}_CTEST_USE_NEW_AAO_FEATURES since it is
  hard-coded now that CMake is 3.17+ is required.

* Removed some documentation discussing older versions of CMake (which are no
  longer supported by TriBITS).

* install-cmake.py: Changed the default version of CMake to install from 3.17
  to 3.23.

* install-cmake.py: Removed patch for CMake 3.17

* Removed documentation for the Kitware fork of Ninja versions < 1.10 since
  Ninja 1.10 has been out for several years with Fortran support.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 25, 2023
This is part of allowing TriBITS to take advantage of newer CMake features and
replacing some older TriBITS code that now has (better or compatible) native
implementations in CMake (often many years after the TriBITS support was
created).  This allows unconditionally using CMake features up to version 3.23
(where we were limited unconditionally using features up to CMake version
3.17).

The min version of CMake 3.23 is chosen due to Trilinos changing its min
version to 3.23 (see trilinos/Trilinos#10355).

Some non-obvious changes made in this commit were:

* For some reason, find_file() with CMake 3.23 (and using CMake 3.23 default
  policies) adds on an extra '/' before the file name in the found path.  This
  messed up some of the test checks in TriBITS but I fixed that by putting
  '[/]*' in the regex to account for that extra '/'.

* Updated the GitHub Actions testing jobs to all be CMake 3.23+.  (I updated
  the patch versions of the different versions as well to the most recent
  patch releases for those minor versions as of right now.  CMake 3.25 is
  still the most recent release of CMake as CMake 3.26 is still in release
  candidate testing.  Therefore, CMake 3.26.2 is still the most current
  release of CMake.)

* Added checks for setting CTEST_RESOURCE_SPEC_FILE in CTestTestfile.cmake now
  that CMake is >= 3.18.

* Removed constant ${PROJECT_NAME}_CTEST_USE_NEW_AAO_FEATURES since it is
  hard-coded now that CMake is 3.17+ is required.

* Removed some documentation discussing older versions of CMake (which are no
  longer supported by TriBITS).

* install-cmake.py: Changed the default version of CMake to install from 3.17
  to 3.23.

* install-cmake.py: Removed patch for CMake 3.17

* Removed documentation for the Kitware fork of Ninja versions < 1.10 since
  Ninja 1.10 has been out for several years with Fortran support.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Feb 28, 2023
…SPub#411)

This replaces '[/]*/' which will match one or more '/' chars in a row with
'/?/' which will match one or two '/' in a row (which is what I wanted).

This addreses review feedback from @KyleFromKitware in PR TriBITSPub#565.
@bartlettroscoe bartlettroscoe added the type: refactor Changes are mostly just a refactoring label Mar 28, 2023
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jun 26, 2023
This checks that the timing in the correct format is printed (but can't check
the actual times). This will allow for trying to use updated CMake feature to
get the raw seconds.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jun 27, 2023
This checks that the timing in the correct format is printed (but can't check
the actual times). This will allow for trying to use updated CMake feature to
get the raw seconds.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jun 27, 2023
This checks that the timing in the correct format is printed (but can't check
the actual times). This will allow for trying to use updated CMake feature to
get the raw seconds.
bartlettroscoe added a commit that referenced this issue Jun 27, 2023
This checks that the timing in the correct format is printed (but can't check
the actual times). This will allow for trying to use updated CMake feature to
get the raw seconds.
bartlettroscoe added a commit that referenced this issue Jun 27, 2023
This checks that the timing in the correct format is printed (but can't check
the actual times). This will allow for trying to use updated CMake feature to
get the raw seconds.
@bartlettroscoe
Copy link
Member Author

FYI, the non-usage of the standard CMake FindMPI.cmake is an issue that should be addressed as well. See:

@bartlettroscoe
Copy link
Member Author

FYI: It is amazing the shockwaves that have been produced in switching Trilinos to just use GNUInstallDirs.cmake by default on even just the local the Trilinos user community. See:

SIDENOTE: It is amazing how much of a shockwave this one seemingly small non-backward compatible change to adopt one modern CMake practice has made on even just the local the Trilinos user community. This does not bode well for all of the changes to switch to modern CMake listed above ☹️.

@bartlettroscoe
Copy link
Member Author

bartlettroscoe commented Jul 26, 2024

CC: @sebrowne, @ccober6

NOTE: The TriBITS module TribitsFindPythonInterp.cmake (created by Bill Spotz back in the day?) currently calls find_package(PythonInterp) which uses the module FindPythonInterp.cmake. According to:

the FindPythonInterp.cmake module has been deprecated since CMake 3.12! This should be updated to use FindPython.cmake or FindPython3.cmake.

See:

bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Jul 26, 2024
This was missed on the upgrade of CMake 3.17 to 3.23.  See commit:

  45b514c "Update CMake min version from 3.17 to 3.23 (TriBITSPub#411)"
  Author: Roscoe A. Bartlett <[email protected]>
  Date:   Sat Feb 25 07:01:29 2023 -0700 (1 year, 5 months ago)

CMake 3.23 was already required by TriBITS so this just makes it consistent.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Aug 1, 2024
This was missed on the upgrade of CMake 3.17 to 3.23.  See commit:

  45b514c "Update CMake min version from 3.17 to 3.23 (TriBITSPub#411)"
  Author: Roscoe A. Bartlett <[email protected]>
  Date:   Sat Feb 25 07:01:29 2023 -0700 (1 year, 5 months ago)

CMake 3.23 was already required by TriBITS so this just makes it consistent.
bartlettroscoe added a commit to bartlettroscoe/TriBITS that referenced this issue Aug 1, 2024
This was missed on the upgrade of CMake 3.17 to 3.23.  See commit:

  45b514c "Update CMake min version from 3.17 to 3.23 (TriBITSPub#411)"
  Author: Roscoe A. Bartlett <[email protected]>
  Date:   Sat Feb 25 07:01:29 2023 -0700 (1 year, 5 months ago)

CMake 3.23 was already required by TriBITS so this just makes it consistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core type: enhancement type: refactor Changes are mostly just a refactoring
Projects
Status: In Progress
Status: ToDo
Development

No branches or pull requests

1 participant