Merged
Conversation
This is the CMakeLists.txt and supporting file that allow using CMake to
build FSON and install to the user's CMake registry. After building and
installing, (with a possible CMAKE_INSTALL_PREFIX=...), the user can
simply add
find_package(FSON)
target_link_libraries(mytarget FSON::FSON)
and everything will Just Work™.
Note, this only deals with building the library and does not yet build
the tests.
[FetchContent]: https://cmake.org/cmake/help/latest/module/FetchContent.html
After taking some more time to review the Meson build, I deduced how to include the tests with the CMake build. We have to add [zofu][zofu], and we need to tell CMake how to build it. The building of zofu could be replaced by the appropriate CMake import details if it gets a CMake build. [zofu]: https://github.com/acroucher/zofu
I tested with CMake 2.8 but it does not support the features necessary to handle configuring and installing as implemented. However, CMake 2 is an outdated version and the general recommendation is to use CMake 3.
The way the tests are written does not clearly indicate the generation of the source depends on the zofu-driver. This information can probably be indicated in a clearer way, but my suspicion is this would require zofu to use CMake. Or it might not.
Testing on RHEL 6 with GFortran 4.7.3 revealed that old GFortrans cannot
build zofu. As such, we need a means to disable building the tests.
However, we want to default to building the tests.
To toggle test building on or off use
cmake3 -DENABLE_TESTS:BOOL=ON ..
I was able to give an overview of Make (probably not really recommended) and CMake. I primarily wanted to incorporate notes on disabling the tests under CMake for use with GFortran 4.7. I do not have enough knowledge about Meson to explain that method other than saying "run meson".
We may need to incorporate FSON into another package that also wants to use ENABLE_TESTS. It's safer to "scope" the option.
Older version of CMake (at least as old as 3.6.1) did not have support for Fortran_COMPILER_ID generator expressions. The common work around was to do string comparisons.
Fortran modules are compiler specific. This means we should install the modules under a directory tagged with the compiler. CMake can handle tracking the transient dependencies so this should not cause problems if two different compilers are required.
Add CMake Build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.