Skip to content

Conversation

JorgeG94
Copy link
Contributor

@JorgeG94 JorgeG94 commented Jul 4, 2025

This makes the code easier to consume inside another cmake project.

@jeffhammond
Copy link
Owner

You're not detecting MPICH except via Cray compiler. Is that prudent?

@JorgeG94
Copy link
Contributor Author

JorgeG94 commented Jul 4, 2025

You're not detecting MPICH except via Cray compiler. Is that prudent?

Oh good point, that should be simple to address thanks.

@JorgeG94
Copy link
Contributor Author

JorgeG94 commented Jul 4, 2025

You're not detecting MPICH except via Cray compiler. Is that prudent?

oh actually those flags are based on the make.inc.xyz files so I didn't try to do any fancy detecting; I'll try to get it to work so that it does pick it up!

@ivan-pi
Copy link
Contributor

ivan-pi commented Jul 11, 2025

I get the error:

[ 63%] Building Fortran object CMakeFiles/vapaa.dir/source/mpi_win_c.F90.o
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7203
Warning: The licence for XYZ expires soon (within a month)
[NAG Fortran Compiler normal termination]
[ 65%] Building C object CMakeFiles/vapaa.dir/source/cfi_util.c.o
In file included from /xyz/vapaa/source/cfi_util.c:11:0:
/xyz/vapaa/source/cfi_util.h:5:10: fatal error: ISO_Fortran_binding.h: No such file or directory
 #include "ISO_Fortran_binding.h"
          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

The location of the header has to be passed manually to the C compiler in case of NAG; see my comment here (#49 (comment)).

Assuming a variable NAG_ROOT exists:

~/vapaa/build> ls $NAG_ROOT
bin  lib  license.dat  man
~/vapaa/build> ls $NAG_ROOT/lib/ISO_*
/opt/nag/7.2/lib/ISO_Fortran_binding.h

@JorgeG94
Copy link
Contributor Author

I need to get access to this compiler so I can test myself. Thank this is easy to address

@ivan-pi
Copy link
Contributor

ivan-pi commented Jul 11, 2025

I managed to bypass the error with this ugly CMake logic,

...
elseif(CMake_Fortran_COMPILER_ID MATCHES "NAG")
...
    # Get the full path to the NAG Fortran compiler
    get_filename_component(NAGFOR_PATH "${CMAKE_Fortran_COMPILER}" REALPATH)
    # Go up two directories to reach $NAG_ROOT (assuming $NAG_ROOT/bin/nagfor)
    get_filename_component(NAG_ROOT "${NAGFOR_PATH}" DIRECTORY) # bin/
    get_filename_component(NAG_ROOT "${NAG_ROOT}" DIRECTORY)    # $NAG_ROOT/
    message(STATUS "NAG HOME is in ${NAG_ROOT}")
    include_directories(${NAG_ROOT}/lib)

Probably some cleaner CMake commands exist.

Edit: with these changes it builds 🎉

[100%] Linking Fortran static library lib/libvapaa.a
[100%] Built target vapaa

target_compile_options(${vapa_lib} PRIVATE -Wall -Wextra -fPIE)
target_compile_definitions(${vapa_lib} PRIVATE -DHAVE_CFI ${FLAG_MPI})
target_link_libraries(${vapa_lib} PRIVATE MPI::MPI_C)
set(WARNFLAGS "-Wall -Wextra -fPIE")
Copy link
Contributor

Choose a reason for hiding this comment

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

-Wall -Wextra aren't valid for the Intel compilers AFAIK.

Choose a reason for hiding this comment

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

I would not add extra warning flags. People can add them if they want, or we can use them in CI, but otherwise any non-standard flags are often just causing trouble when building on strange systems. (All HPC systems are strange snowflakes.) Even -fPIE should be handled automatically by cmake if it's building a shared library.

For example, I will want to cross-build this library on a x86-64 musl host for mingw 32-bit Windows. The respective mechanisms for shared libraries are different there, but since cmake already knows how to do that, just using the standard cmake mechanisms is best.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, warn flags in CI are good. We shouldn't enable in release builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I shall fix this up :) I can probably create a small CI that runs on GIthub actions too

@jeffhammond
Copy link
Owner

I need to get access to this compiler so I can test myself. Thank this is easy to address

I have access but it will be a while before I have time to test. I'm on vacation until August.

@JorgeG94
Copy link
Contributor Author

I need to get access to this compiler so I can test myself. Thank this is easy to address

I have access but it will be a while before I have time to test. I'm on vacation until August.

Enjoy your holiday!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants