Closed apthorpe closed 4 years ago
Wow, thanks for this big contribution - really great work. From the brief look I've had, it looks fine. Just noticed the build is failing though, but I am not sure if it is because of this PR, it might be that the Travis setup is just too old now. Let me have a look at the CI and I'll get back to this after.
So it seems your comment is pretty accurate:
# Libraries
# This may require CMake 3.14 or later
install(TARGETS ${TOAST_LIB_NAME})
Locally, I have cmake version 3.14 and all works fine, but on the build and other systems with cmake < 3.14 (I tested 3.10 and the build is 3.12 I think) it fails because of that line (120).
I guess my question to you is do you think versions of cmake older than 3.14 are worth supporting?
I know some people who use fortran will have problems updating systems (and cmake) so this requirement may cause issues. Cmake 3.12 is still quite recent (2017) for the fortran community - is there a workaround to support older cmake versions?
Let me test against an older version and see if I can reduce the CMake version requirement
I tested against a fresh build of CMake 3.10.3 on Linux and resolved a few issues. The first was that prior to CMake 3.13 or 3.14 install(TARGETS ...)
must be invoked in the subdirectory where the target is defined. I had the TOAST library install()
line in the top-level CMakeLists.txt
; moving it to toast/CMakeLists.txt
fixed the first issue.
The second issue is that the install()
command didn't specify the directories where executables, libraries, etc. should be installed. Those directories are defined by invoking include(GNUInstallDirs)
but they are only used by default in later versions of CMake. Explicitly setting RUNTIME DESTINATION
, LIBRARY DESTINATION
, and ARCHIVE DESTINATION
in the install()
command solved the second problem. Hopefully those two changes reduce dependencies to something more manageable.
All looks fine now. Thanks for the effort, really appreciate it.
This PR adds installation and packaging support to TOAST, provides convenience scripts for integrating TOAST with CMake-based projects (
FindTOAST.cmake
,BuildTOAST.cmake
,TOASThelper.cmake
), and adds TOAST unit tests and examples to a CTest test plan.make test
will run all tests; tests expected to fail (example1
,example2
) are marked asWILL_FAIL
.make install
should install the TOAST library andtoast.mod
module file in a standard location. CPack will create installers and archives based on the platform and installed packaging tools. A.zip
archive is produced for all platforms and illustrates the installation directory tree structure.None of the original source code has been changed; this should only affect build infrastructure.
It is likely that the project metadata needs to be changed; see
CPACK_*
variables set at the top ofCMakeLists.txt
. This info is used for constructing packages and includes version, authorship, and licensing information.The included version of
BuildTOAST.cmake
does not take advantage of the new installation support. A revised, simplified version will be suggested if this PR is accepted; see https://gitlab.com/apthorpe/sofire2/-/blob/42-improve-unit-test-integration/cmake/BuildTOAST.cmake for more detailsFindTOAST.cmake
can be used to detect a previously-installed version of TOAST and set the location of the library and.mod
file. UsingFindTOAST.cmake
andBuildTOAST.cmake
, it's possible to use an existing installation if it's detected, then fall back to retrieving and installing a fresh copy without requiring the including project to use git submodules.Finally,
TOASThelper.cmake
provides the CMake functionadd_toast_unit_test()
which simplifies compilation and running of TOAST-based unit tests. Example use:Full documentation of the function arguments is provided in the body of
TOASThelper.cmake