fortran-lang / stdlib

Fortran Standard Library
https://stdlib.fortran-lang.org
MIT License
1.06k stars 164 forks source link

CMake compiler options for build configurations #387

Open awvwgk opened 3 years ago

awvwgk commented 3 years ago

The CMake build files currently set options using the add_compile_options function, which adds the respective argument independently from the actual build configuration (we call it profile in fpm).

For context: The CMake build configuration is found in CMAKE_BUILD_TYPE and is empty by default (NoConfig), other common profiles are Debug, RelWithDebInfo, Release, and MinSizeRel, but one can basically use any name. The global compiler options are taken from CMAKE_Fortran_FLAGS and the build configuration specific ones from CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} (with the value of CMAKE_BUILD_TYPE as uppercase...).

As I understood @milancurcic the current options set with add_compile_options are the debug / development profile, but they are currently added for all build configurations. Instead we should try to set those options to the CMAKE_Fortran_FLAGS_DEBUG variable.

milancurcic commented 3 years ago

Yes, what I meant in that comment was that we could do this, not that we currently do it.