Hello everybody,

I have a library for which almost all the files should be compiled (e.g. g95) with the same compilation flags (that I will call later flag_debug, flag_release ...) excepted a few ones for which I have to use slightly different compilation flags (called later flag1_debug, flag1_release ...).

As in both cases the flags are different from the default ones, I was told on the cmake list to create a personal Compiler/G95-Fortran.cmake file that was placed in my Src directory and that contains the following lines:

set(CMAKE_Fortran_FLAGS_INIT "")
set(CMAKE_Fortran_FLAGS_DEBUG_INIT flag_debug)
set(CMAKE_Fortran_FLAGS_RELEASE_INIT flag_release)
set(CMAKE_Fortran_MODDIR_FLAG "-fmod=")
set(CMAKE_Fortran_VERBOSE_FLAG "-v")

This file allowing to avoid the declaration of the flags in the CMakeLists.txt file. But, how to proceed for the few files for which I have to use different compiler flags ? In that case, I do not see any way to escape from writing specifically the flags in the CMakeLists.txt file with command such as:

if(CMAKE_BUILD_TYPE STREQUAL RELEASE)
set_source_files_properties(File1 PROPERTIES COMPILE_FLAGS flag1_release) set_source_files_properties(File2 PROPERTIES COMPILE_FLAGS flag1_release) ...
elseif(CMAKE_BUILD_TYPE STREQUAL DEBUG)
   set_source_files_properties(File1 PROPERTIES COMPILE_FLAGS flag1_debug)
set_source_files_properties(File2 PROPERTIES COMPILE_FLAGS flag1_debug) ...
...
endif()

would you have any idea about how to esacpe from this kind of implementation ? is that so ugly ?

thanks

Eric



--
Eric Pellegrini
Calcul Scientifique
Insitut Laue-Langevin
Grenoble, France

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to