[CMake] SS12 and -xcode=pic32

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Oct 28 02:00:59 EDT 2008


On 2008-10-27 15:27-0500 George Neill wrote:

> Alan,
>
> On Mon, Oct 27, 2008 at 3:10 PM, Alan W. Irwin
> <irwin at beluga.phys.uvic.ca> wrote:
>> On 2008-10-27 12:54-0500 George Neill wrote:
>>
>>> Hi All,
>>>
>>> I am using cmake 2.4.8 and Sun Studio 12.
>>>
>>> I am trying to overwrite these default cmake compiler settings from
>>> Modules/Platorm/SunOS.cmake
>>>
>>>  SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC")
>>>  SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC")
>>>
>>> to
>>>
>>>  SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-xcode=pic32")
>>>  SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-xcode=pic32")
>>>
>>> However I am not having any luck.
>>>
>> {...]
>>>
>>> Any suggestions?
>>
>> The brute-force but completely reliable method is to
>> set your desired compilers and associated flags before running cmake, e.g.,
>>
>> export CC='cc -xcode=pic32'
>> export CXX='c++ -xcode=pic32'
>
> Should that be ...
>
> export CFLAGS="-xcode=pic32"
> export CXXFLAGS="-xcode=pic32"

Uh... No.

To set the record straight for others reading this in the future, please do
exactly what I suggested (which works) rather than trying something else.

George, in your defense, you probably believed the wiki documentation.... :-)

http://www.vtk.org/Wiki/CMake_Useful_Variables does mention CC and CXX, but
that site now fails to mention that you can also set the associated compile
flags at the same time if you follow my instructions above. Somebody removed
discussion of that possibility from the wiki a year or so ago.  I feel that
was a mistake since the method is so useful and so reliable. If you are
interested in how the method is implemented, check out the CMake logic you
see at the top of Modules/CMakeDetermine<LANG>Compiler.cmake which uses, e.g.,

GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS
CMAKE_C_FLAGS_ENV_INIT)

to extract the compiler name AND associated flags from the environment
variable.

Apparently, Bill is also helping you find an internal CMake method of
overriding the default compile flags, but I prefer the environment variable
approach for doing the same thing.  The reason is that, by definition, that
can be used by one user with special platform needs without interfering with
other users building the same software package on different platforms.  Of
course, the internal method is fine if you have a single-user package or if
you can hedge the internal method around with enough CMake platform
detection logic so it doesn't interfere with users on other platforms.

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
__________________________


More information about the CMake mailing list