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

Implement option for using non-prefixed environment variables #576

Open
awvwgk opened this issue Sep 23, 2021 · 2 comments
Open

Implement option for using non-prefixed environment variables #576

awvwgk opened this issue Sep 23, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@awvwgk
Copy link
Member

awvwgk commented Sep 23, 2021

Description

For integration in packaging systems like conda-build or spack or to seamlessly work with environment modules fpm could allow an option to use non-prefixed environment variables.

  • --compiler, FPM_FC, FC to set Fortran compiler
  • --c-compiler, FPM_CC, CC to set C compiler
  • --archiver, FPM_AR, AR to set archiver
  • --flag, FPM_FFLAGS, FFLAGS to set Fortran compiler flags
  • --c-flag, FPM_CFLAGS, CFLAGS to set C compiler flags
  • --link-flag, FPM_LDFLAGS, LDFLAGS to set linker flags

The non-prefixed environment variables will not be used by default to avoid picking up environment variables by accident, i.e. using the non-prefixed variables is always opt-in.

Possible Solution

Use command line flag --env or similar to activate usage of compiler variables. Always provide an option to show to show where a particular default originated from.

Additional Information

Follow-up from #549

@awvwgk awvwgk added the enhancement New feature or request label Sep 23, 2021
@awvwgk awvwgk self-assigned this Sep 23, 2021
@LKedward
Copy link
Member

Comment from @urbanjost :

One other change that I was hoping would come out of the discussions was an option to set the variable prefix so that it could be a user-defined value, even a blank character, so you could set compiler-specific values or even not have a prefix (and so use FC, AR, ...). So I could set INTEL_FFLAGS and GFORTRAN_FFLAGS and ... and switch to different sets of them just by setting FPM_PRE. No one liked that? It would give you a back door to use the default names and if you are using environment variables would let you have compiler-specific sets of them.


This use case of different compiler flags is a compelling reason to do this IMO.

@urbanjost
Copy link
Contributor

I think the proposed PR #608 satisfied the original post without introducing some of the perils associated with using environment variables as an opt-in is required, and easily allows setting groups of variables for specific compilers. It also allows for user-defined names for groups of variables for the case where you want multiple choices for the same compiler. All new variable names are required to begin with FPM_ so they are easier to identify and list as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants