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

Add CMake build mode flags to hdf5lib.settings #4816

Conversation

derobins
Copy link
Member

@derobins derobins commented Sep 7, 2024

Flags from the CMake build mode (e.g., optimization) are not a part of
CMAKE__FLAGS and were not exported to the libhdf5.settings file. This
has been fixed and the C, Fortran, and C++ build mode flags are now exported to
the file.

This also affects the text output of H5check_version() and the libhdf5.settings
string stored in the library (for those who use strings(1), etc. to get
build info from the binary).

The build mode flags for things like optimization are not added
to CMAKE_C_FLAGS and were not exported to the libhdf5.settings
file. This change corrects that.

Also removes -Og from the developer mode flags since that's already
set via the debug flags the developer mode is based on.
@derobins derobins added Merge - To 1.14 Priority - 2. Medium ⏹ It would be nice to have this in the next release Component - C Library Core C library issues (usually in the src directory) Component - Build CMake, Autotools Type - Improvement Improvements that don't add a new feature or functionality labels Sep 7, 2024
# that collect debugging information
set (CMAKE_C_FLAGS_DEVELOPER "${CMAKE_C_FLAGS_DEBUG} -Og" CACHE STRING
# Set CMake C flags based off of Debug build flags
set (CMAKE_C_FLAGS_DEVELOPER "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING
Copy link
Member Author

Choose a reason for hiding this comment

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

This is already set in the debug flags

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is CMAKE_C_FLAGS_DEBUG, which will only capture the debug flags that are added by default by CMake, or explicitly added at configure time by the user. Not the flags that we add separately in the library's configuration.

Copy link
Collaborator

@jhendersonHDF jhendersonHDF Sep 9, 2024

Choose a reason for hiding this comment

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

That said, some compilers don't have -Og, so this does need to be refactored at some point, but I still find it useful.

# H5build_settings.c
#-----------------------------------------------------------------------------
set (HDF5_BUILD_MODE_C_FLAGS "")
set (HDF5_BUILD_MODE_Fortran_FLAGS "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the Fortran and CXX flags be set in the HDFFortranCompilerFlags.cmake and HDFCXXCompilerFlags.cmake files?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do that

Copy link
Contributor

@mattjala mattjala left a comment

Choose a reason for hiding this comment

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

Move CXX/Fortran flag setting to correct cmake files

byrnHDF added a commit to byrnHDF/hdf5 that referenced this pull request Oct 18, 2024
@lrknox lrknox closed this in 6122828 Oct 25, 2024
brtnfld pushed a commit to brtnfld/hdf5 that referenced this pull request Oct 31, 2024
* Split CMake HDFCompileFlags into specific compiler files

* Separate out CXX Flags

* Add Fortran compiler specific files

* Merge in HDFGroup#4816 changes and close HDFGroup#4816

* fix hanging endif

---------

Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
brtnfld pushed a commit to brtnfld/hdf5 that referenced this pull request Nov 4, 2024
* Split CMake HDFCompileFlags into specific compiler files

* Separate out CXX Flags

* Add Fortran compiler specific files

* Merge in HDFGroup#4816 changes and close HDFGroup#4816

* fix hanging endif

---------

Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Component - C Library Core C library issues (usually in the src directory) Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
Status: Merges Complete
Development

Successfully merging this pull request may close these issues.

4 participants