[Cmake] problem with too eager SET_SOURCE_FILES_PROPERTIES

Ian Scott ian.m.scott at stud.man.ac.uk
Fri Dec 6 15:20:41 EST 2002


VXL has several (27 to be precise) cases where we need a

IF(CMAKE_COMPILER_IS_GNUCXX)
  SET_SOURCE_FILES_PROPERTIES(wibble.cxx COMPILE_FLAGS -O0)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)

to avoid internal compiler errors.

I have noticed two problems with this.

The -O2 is being added to lots of build commands which were never specified,
e.g.
from vxl/core/vnl/Makefile
#---------------------------------------------------------
# Build vnl_math.o  From /work/vxl/src/core/vnl/vnl_math.cxx
#

vnl_math.o: /work/vxl/src/core/vnl/vnl_math.cxx
        echo "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0
$(CMAKE_SHLIB_C
FLAGS) $(INCLUDE_FLAGS) -c /work/vxl/src/core/vnl/vnl_math.cxx -o
vnl_math.o"
        $(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0
$(CMAKE_SHLIB_CFLAGS)
 $(INCLUDE_FLAGS) -c /work/vxl/src/core/vnl/vnl_math.cxx -o vnl_math.o

#---------------------------------------------------------
# Build vnl_copy.o  From /work/vxl/src/core/vnl/vnl_copy.cxx
#

vnl_copy.o: /work/vxl/src/core/vnl/vnl_copy.cxx
        echo "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0
$(CMAKE_SHLIB_C
FLAGS) $(INCLUDE_FLAGS) -c /work/vxl/src/core/vnl/vnl_copy.cxx -o
vnl_copy.o"
        $(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0
$(CMAKE_SHLIB_CFLAGS)
 $(INCLUDE_FLAGS) -c /work/vxl/src/core/vnl/vnl_copy.cxx -o vnl_copy.o

vnl_math.cxx was specified to have -O0, but vnl_copy.cxx was not.

Not all files have -O0 added to them. It appears that when one file has -O0
added legitimately, every other compile line in the Makefile also has -O0
added. Further legitimate -O0s add extra -O0s to the command line.

Templates/vnl_vector_fixed+float.4-.o:
/work/vxl/src/core/vnl/Templates/vnl_vector_fixed
+float.4-.cxx
        echo "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0
$(CMAKE_SHLIB_C
FLAGS) $(INCLUDE_FLAGS) -c
/work/vxl/src/core/vnl/Templates/vnl_vector_fixed+float.4-.cx
x -o Templates/vnl_vector_fixed+float.4-.o"
        $(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0
$(CMAKE_SHLIB_CFLAGS)
 $(INCLUDE_FLAGS) -c
/work/vxl/src/core/vnl/Templates/vnl_vector_fixed+float.4-.cxx -o T
emplates/vnl_vector_fixed+float.4-.o

#---------------------------------------------------------
# Build vnl_matrix+long-.o  From
/work/vxl/src/core/vnl/Templates/vnl_matrix+long-.cxx
#

vnl_matrix+long-.o: /work/vxl/src/core/vnl/Templates/vnl_matrix+long-.cxx
        echo "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0 -O0
$(CMAKE_SHL
IB_CFLAGS) $(INCLUDE_FLAGS) -c
/work/vxl/src/core/vnl/Templates/vnl_matrix+long-.cxx -o
vnl_matrix+long-.o"
        $(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) -Dvnl_EXPORTS -O0 -O0
$(CMAKE_SHLIB_CFL
AGS) $(INCLUDE_FLAGS) -c
/work/vxl/src/core/vnl/Templates/vnl_matrix+long-.cxx -o vnl_ma
trix+long-.o

Since ITK also uses VNL - they may also be running at much less than full
power.

The second problem is that I have also tested this with Intel's icc. None of
them should have a -O0 added, since the guard is checking for
CMAKE_COMPILER_IS_GNUCXX. So I guess that CMAKE_COMPILER_IS_GNUCXX is
reporting true for icc by mistake. I have tried setting the internal
variable in the cache to no effect.

I would appreciate an urgent fix. If someone could point me in the right
direction I might even be able to fix it myself.

I've found this problem in both cmake 1.4.4 and cmake 1.4.6

Any ideas?

Ian.





More information about the CMake mailing list