[CMake] Always compile source file in debug

Eric Noulard eric.noulard at gmail.com
Fri Sep 3 07:07:03 EDT 2010


2010/9/3 Belcourt, Kenneth <kbelco at sandia.gov>:
> Hi,
>
> Apologies if this has been answered before.  In an effort to ensure
> cross-platform consistent results, I need to force some (C++ and Fortran)
> source files to always be built debug.  Is there any easy syntax to do this?
>
> I build our libraries like this.
>
> SET(SRCS
>  ${EXEC_DIR}/AfterStep.f90
>  ${EXEC_DIR}/ArgCF_Connect.f90
>  ${EXEC_DIR}/ArgCF_Solve.f90
>  ...
> )
>
> ADD_LIBRARY(exec ${SRCS})

You may set some specific flags on specific sources using something like

set_source_files_properties(file1.f90 file2.f90
                                                  PROPERTIES
COMPILE_FLAGS ${CMAKE_FORTRAN_FLAGS_DEBUG})

but as far as I understand this does not replace default compile flags but add
extra flags for those particular source files...

Now if your "to be compiled with debug options" files may be contained in
separate libraries, may be you can create a sub-project which contains those
and enforce thsi subproject to be "CMAKE_BUILD_TYPE=Debug".


Curious to know, Why do you want to "some files" files to always be built debug
in the first place?

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list