CMake additional Debug Options -
when compiling code debug symbols, want enable compile-time , run-time checks, so:
gfortran -c -o hello.o -g -o0 -wall -fcheck-all -fbacktrace hello.f90
(yes, it's fortran, assume it'd work other languages same.)
if wanted compile same intel fortran compiler, command this:
ifort -c -o hello.o -g -o0 -warn -check -traceback hello.f90
the way compile in cmake have found far this:
if(${cmake_fortran_compiler_id} matches "gnu") set(cmake_fortran_flags_debug "${cmake_fortran_flags_debug} -wall -fcheck=all -fbacktrace") elseif(${cmake_fortran_compiler_id} matches "intel") set(cmake_fortran_flags_debug "${cmake_fortran_flags_debug} -warn -check -traceback") else() message(warning "unable determine compiler id: ${cmake_fortran_compiler_id}") endif(${cmake_fortran_compiler_id} matches "gnu")
but introduces hardcoded flags wanted avoid when starting use cmake. there way add compiler switches based on do, "enable compile time warnings" or "enable runtime checks"?
cmake warning api: coming soon.
the discussion proposes commands add_compile_warnings
or target_compile_warnings
, following model of add_compile_options
, target_compile_definitions
, warning levels such as:
- all (compiler specific "all", e.g. /wall or -wall);
- default;
- none;
- everything (all possible warnings compiler, if there no such option use maximum level plus warnings explicitly).
you may study proposed api , perhaps expose unsatisfied needs in discussion.
Comments
Post a Comment