[CMake] SS12 and -xcode=pic32

George Neill georgen at neillnet.com
Tue Oct 28 03:39:16 EDT 2008


Alan,

On Tue, Oct 28, 2008 at 1:00 AM, Alan W. Irwin
<irwin at beluga.phys.uvic.ca> wrote:
> 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....
> :-)

*wink* yeah i'll go with that ... though it's more likely to be my
silly habits from years of unix compiles. :)

Your suggestion does work perfectly when _all_ items in the build
require those flags.  I am looking just to compile only my shared libs
(and a couple of exes) with -xcode=pic32  .. the rest of my source
doesn't need the compile flag, infact, the default -xcode=abs44 is
better for performance reasons.

> 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.

I'll spend some time researching.  Thanks for the pointer.

> 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.

Well, Bill answered my original question about setting the
CMAKE_SHARED_LIBRARY_C_FLAGS variable and I guess now I am just trying
to make sure I am using cmake in an acceptable way when overriding
compile flags.  I probably should have spun a new thread, I apologize
for not doing so.

Thanks for your comments, I really appreciate it.

Later,
George


More information about the CMake mailing list