Re: [CMake] Actual effect of set_source_files_properties with COMPILE_FLAGS - solved

2012-01-11 Thread pellegrini

Hello everybody,

that's finally OK. Indeed; everything was OK. I did not pay attention 
that the flag was actually here. I was simply not looking
in the right place. Perhaps new glasses or some rest should be my first 
resolution for 2012 !!!


sorry for the inconvenience

Eric

pellegrini a écrit :

Hello everybody,

I work on a Fortran library that for historical reasons should be 
maintained with intel fortran compiler, g95 and gfortran

on Linux, Windows and MacOS platoform. Everything everywhere :o  !

My library is made of 50 files. Among those files, most of them will 
have to be compiled with a set of flags that
does not match the CMake default ones. But, for a few of them (4 
actually) there are some slight variations. For instance,
with g95, 46 files has to compiled with -std=f2003 while the 4 others 
ones should have this flag unset.


The strategy I decided to adopt is the following:
   - use of a macro to set the standard flags (see attached file 
set_compiler_flags.cmake)
   - use of set_source_files_properties(${SOURCES} PROPERTIES 
COMPILE_FLAGS -std=f2003)

 to set the -std=f2003 flag for all the files.
   - use of set_source_files_properties(file1.f90 PROPERTIES 
COMPILE_FLAGS ) to switch off the -std=f2003

 flag for the files for which that flag should not be set.

does it look reasonable to you ?

Now my problem. When cmaking my project, I get in one subdirectories 
of CMakeFiles a file flags.make that contains the compiler flags. From 
that file,  it seems that the set_source_files_properties commands 
were correctly executed (guessing that the comment for Custom flags is 
not an actual comment). But when using nmake in verbose mode, the 
custom flags do not appear in the g95 command line. The only ones 
displayed are the one set in my set_compiler_flags macro. Is that just 
a bug on the display or is there something wrong with my settings ?


thanks a lot

Eric




--

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



--
Eric Pellegrini
Calcul Scientifique
Institut 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


[CMake] Actual effect of set_source_files_properties with COMPILE_FLAGS

2012-01-10 Thread pellegrini

Hello everybody,

I work on a Fortran library that for historical reasons should be 
maintained with intel fortran compiler, g95 and gfortran

on Linux, Windows and MacOS platoform. Everything everywhere :o  !

My library is made of 50 files. Among those files, most of them will 
have to be compiled with a set of flags that
does not match the CMake default ones. But, for a few of them (4 
actually) there are some slight variations. For instance,
with g95, 46 files has to compiled with -std=f2003 while the 4 others 
ones should have this flag unset.


The strategy I decided to adopt is the following:
   - use of a macro to set the standard flags (see attached file 
set_compiler_flags.cmake)
   - use of set_source_files_properties(${SOURCES} PROPERTIES 
COMPILE_FLAGS -std=f2003)

 to set the -std=f2003 flag for all the files.
   - use of set_source_files_properties(file1.f90 PROPERTIES 
COMPILE_FLAGS ) to switch off the -std=f2003

 flag for the files for which that flag should not be set.

does it look reasonable to you ?

Now my problem. When cmaking my project, I get in one subdirectories of 
CMakeFiles a file flags.make that contains the compiler flags. From that 
file,  it seems that the set_source_files_properties commands were 
correctly executed (guessing that the comment for Custom flags is not an 
actual comment). But when using nmake in verbose mode, the custom flags 
do not appear in the g95 command line. The only ones displayed are the 
one set in my set_compiler_flags macro. Is that just a bug on the 
display or is there something wrong with my settings ?


thanks a lot

Eric


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

macro(set_compiler_flags)

get_filename_component(COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME_WE)

if(COMPILER_NAME STREQUAL ifort)

if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -debug:full /check /traceback 
/nologo)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE /O2 /nologo /Qvec-report0)
endif()
elseif(APPLE)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -g -warn)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O -warn -vec-report0)
endif()
else()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -g -warn)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O -warn -vec-report0)
endif()
endif()

elseif(COMPILER_NAME STREQUAL g95)

if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -O0 -ftrace=full)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O3 -funroll-loops -msse2)
endif()
elseif(APPLE)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -g -Wall)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O)
endif()
else()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -g -Wall)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O)
endif()
endif()

elseif(COMPILER_NAME STREQUAL gfortran)

if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -O0 -ftrace=full)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O3 -funroll-loops -msse2)
endif()
elseif(APPLE)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -g -Wall -m32)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O -m32)
endif()
else()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_Fortran_FLAGS_DEBUG -g -Wall)
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_Fortran_FLAGS_RELEASE -O)
endif()
endif()

endif()

endmacro()# CMAKE generated file: DO NOT EDIT!
# Generated by NMake Makefiles Generator, CMake Version 2.8

# Custom flags: 
CMakeFiles/crysfml_common.dir/CFML_GlobalDeps_Windows.f90.obj_FLAGS = -std=f2003

# Custom flags: CMakeFiles/crysfml_common.dir/CFML_Atom_Mod.f90.obj_FLAGS = 
-std=f2003

# Custom flags: CMakeFiles/crysfml_common.dir/CFML_Bonds_Table.f90.obj_FLAGS = 
-O0

# Custom flags: CMakeFiles/crysfml_common.dir/CFML_Chem_Scatt.f90.obj_FLAGS = 
-O0

# Custom flags: CMakeFiles/crysfml_common.dir/CFML_Conf_Calc.f90.obj_FLAGS = 
-std=f2003

# Custom