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

Non-library entities added to NC_FLIBS (CMakeLists.txt) #394

Open
jtfrey opened this issue Mar 14, 2023 · 1 comment
Open

Non-library entities added to NC_FLIBS (CMakeLists.txt) #394

jtfrey opened this issue Mar 14, 2023 · 1 comment
Assignees
Milestone

Comments

@jtfrey
Copy link

jtfrey commented Mar 14, 2023

Versions: 4.5.4, 4.6.0

The CMake build system creates the list of library dependencies in NC_FLIBS by looping over the link libraries associated with the netcdff target:

get_target_property(ALL_TLL_LIBS netcdff LINK_LIBRARIES)

FOREACH(_LIB ${ALL_TLL_LIBS})
   :

One item in the LINK_LIBRARIES list is the netcdff_c library — which is declared as an OBJECT library in fortran/CMakeLists.txt. An OBJECT library does not produce a STATIC or SHARED library, just a set of object files. Nevertheless, -lnetcdff_c gets added to NC_FLIBS and ends up in the nf-config script. For builds using MPI, an additional non-library dependency MPI::MPI_Fortran exists in LINK_LIBRARIES and gets added as -lMPI::MPI_Fortran to nf-config.

The result is that any build system using nf-config to generate a library dependency list includes these non-library components that cannot be resolved by the linker:

$ nf-config --flibs
-L/opt/shared/netcdf-fortran/4.5.4/lib -lnetcdff -lnetcdf -lnetcdf -lnetcdff_c

and

$ nf-config --flibs
-L/opt/shared/netcdf-fortran/4.5.4-openmpi/lib -lnetcdff -lnetcdf -lnetcdf -lnetcdff_c -lMPI::MPI_Fortran
@WardF
Copy link
Member

WardF commented Mar 17, 2023

Thanks; let me take a look at how to clean this up!

@WardF WardF self-assigned this Mar 17, 2023
@WardF WardF added this to the 4.6.1 milestone Mar 17, 2023
@WardF WardF modified the milestones: 4.6.1, 4.6.2 May 31, 2023
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

No branches or pull requests

2 participants