[CMake] Compiler varience?
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Tue Sep 9 14:20:35 EDT 2008
CMake uses files in cmake-2.6/Modules/Platform to set up the flags required
for each kind of platform/compiler. I assume, for example, that Linux.cmake
sets up defaults for that platform. Also, it is pretty clear that
Linux-Intel-C.cmake contains the correct flags for the Intel C compiler
under Linux, etc.
The logic for obtaining all platform/compiler ID's is contained in the
cmake-2.6/Modules/*CompilerId* files. If you cannot guess the correct
Platform file name for your platform/compiler of choice, I would put message
commands in those files to see what that name should be, and then update or
create that Platform file to make sure you have the compiler flags set the
way you want.
HTH
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 libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
-------------- next part --------------
Hey,
Is there a module out there that will supply pre-defined flags for
different compilers?
I made a start on one, but I can't believe I am the first, but a snippet
of what I have been making:
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
SET(C_WARN_DEF "-W")
SET(C_WARN_FULL "-W -Wall -Wshadow")
SET(C_WARN_NONE "-w")
SET(C_WARN_ERROR "-Werror")
SET(C_OPT_DEBUG "-g")
SET(C_OPT_NONE "-O0")
SET(C_OPT_SPEED "-O3")
SET(C_OPT_SIZE "-Os")
SET(C_WORD32 "-m32")
SET(C_WORD64 "-m64")
elseif (${CMAKE_C_COMPILER_ID} STREQUAL "MSVC")
SET(C_WARN_DEF "/W3")
SET(C_WARN_FULL "/W4")
SET(C_WARN_NONE "/w")
SET(C_WARN_ERROR "/WX")
SET(C_OPT_DEBUG "/Z7")
SET(C_OPT_NONE "/Od")
SET(C_OPT_SPEED "/O2")
SET(C_OPT_SIZE "/O1")
SET(C_WORD32 "")
SET(C_WORD64 "")
endif ()
In other words, I want something that will set things like the above for
EACH compiler (as I said, I have made some progress). The WORD32/WORD64
also need linker flags too. Plus going even further than the above (for
doing things like enabling platform-specific optimizations, like
-march=i686 on gcc, maybe in C_OPT_CPU) would be nice. FYI, I have made
the CXX equivalents too.
I only started using cmake this weekend, so my implementation may be a
little naive and simplistic. But before I go completely crazy with
this, I wanted to know if it has been done. It is kind of silly that
the end-user has to know the flags for EACH compiler that may be used to
compile their project to do things like enable ALL warnings, or optimize
for size. It also seems a little odd that each end-user would have to
write the if/elseif/endif code to accommodate each compiler themselves.
I searched the bug database, and did not see any open issues relating to
this, and the mailing list is not easily searchable (though google
didn't turn up any results).
FYI, I just moved from bjam to cmake - mainly because bjam is a little
difficult to use and is quirky with relation to paths and such. Cmake
is much more user-friendly, but does not seem to be as refined as far as
handling different compiler flags as above.
FYI 2, yes, I know I can use different settings of CMAKE_BUILD_TYPE to
change the opimization/debug symbols flags, but that's only part of the
story (there is nothing to change warning levels or force a 32-bit
compile on a 64-bit machine). And if I was to make my own build type
(eg. RELEASE32) I would need the flags above anyway to remain compiler
agnostic.
PreZ :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5509 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080909/d3ec1650/attachment-0001.bin>
-------------- next part --------------
_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list