I have found two bugs in compiler flag support for Linux that I would like to discuss here before making formal bug reports.
1. A general compiler flag bug with ENABLE_LANGUAGE. By accident while investigating the second fortran-related compiler flag bug below, I also happened an ENABLE_LANGUAGE bug that affects all languages. The combination PROJECT(free_eos CXX) ENABLE_LANGUAGE(C) defines the correct CXX flags, but blanks the C flags in the cache rather than defining them properly, e.g., //C compiler. CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc //Flags for C compiler. CMAKE_C_FLAGS:STRING=' ' //Flags used by the compiler during debug builds. CMAKE_C_FLAGS_DEBUG:STRING= //Flags used by the compiler during release minsize builds. CMAKE_C_FLAGS_MINSIZEREL:STRING= //Flags used by the compiler during release builds (/MD /Ob1 /Oi // /Ot /Oy /Gs will produce slightly less optimized but smaller // files). CMAKE_C_FLAGS_RELEASE:STRING= //Flags used by the compiler during Release with Debug Info builds. // CMAKE_C_FLAGS_RELWITHDEBINFO:STRING= With these compile flags blanked, it turns, e.g., CMAKE_BUILD_TYPE=Debug into a no-op for the C language. If I try, instead PROJECT(free_eos C) ENABLE_LANGUAGE(CXX) then the C flags are defined correctly, but the CXX flags are blanked turning, e.g., CMAKE_BUILD_TYPE=Debug into a no-op for the C++ language. I don't know a fix for this bug in ENABLE_LANGUAGE for Linux, and the only workaround is never to use it, and always specify required languages with the PROJECT command (which is awkward if you want to have language support at the user's option). #######Bug in Fortran flags. Even if I use PROJECT(free_eos Fortran) to avoid the first general compiler flag bug, then the cached Fortran flags I get with Linux/g77 for 2.4.6 are all blanked, e.g. //Fortran compiler. CMAKE_Fortran_COMPILER:FILEPATH=/usr/bin/g77 //Flags for Fortran compiler. CMAKE_Fortran_FLAGS:STRING=' ' //Flags used by the compiler during debug builds. CMAKE_Fortran_FLAGS_DEBUG:STRING= //Flags used by the compiler during release minsize builds. CMAKE_Fortran_FLAGS_MINSIZEREL:STRING= //Flags used by the compiler during release builds (/MD /Ob1 /Oi // /Ot /Oy /Gs will produce slightly less optimized but smaller // files). CMAKE_Fortran_FLAGS_RELEASE:STRING= //Flags used by the compiler during Release with Debug Info builds. // CMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING= Now, these special compilation flags are set correctly in the cache for gcc and g++ if and only if (see first bug) C and/or CXX are mentioned in the PROJECT command. Under those circumstances, CMAKE_C_FLAGS_DEBUG:STRING=-g CMAKE_CXX_FLAGS_DEBUG:STRING=-g for example, appear in the cache. Thus I looked at how those specific C/CXX flags were set on Linux for gcc. It turns out that is the responsibility of Platform/gcc.cmake. There is also a Platform/g77.cmake with all the right g77 flag information, but nothing includes it on Linux, and that is the second bug. A fix for this bug is to put the following lines at the end of Platform/gcc.cmake: # Treat g77 the same as gcc and g++ INCLUDE(Platform/g77) (Another alternative is to put the same two lines right after # always include the gcc compiler information INCLUDE(Platform/gcc) at the end of the CMakeGenericSystem.cmake file. What is the preferred alternative? Once I know that I will file a bug report for this second bug with the preferred fix. Of course, neither form of the fix works unless you specify Fortran as an argument to the PROJECT command and not the ENABLE_LANGUAGE command (see first bug). Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake