[CMake] how to set ar/ranlib flags per target

Verweij, Arjen VerweijA at tass-safe.com
Wed Jul 21 17:13:35 EDT 2010


Well the thread you reference asks the TS to submit a bug in Mantis. Was such a bug ever submitted?

I did a quick check and I can't find one using several queries.

No other ideas for fixing your problem except for wrapping add_library to include 32/64 bit argument.

Regards,
Arjen

>-----Original Message-----
>From: Hickel, Kelly [mailto:Kelly_Hickel at bmc.com]
>Sent: woensdag 21 juli 2010 22:46
>To: Verweij, Arjen; cmake at cmake.org
>Subject: RE: how to set ar/ranlib flags per target
>
>
>> -----Original Message-----
>> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On
>> Behalf Of Verweij, Arjen
>> Sent: Wednesday, July 21, 2010 3:43 PM
>> To: cmake at cmake.org
>> Subject: Re: [CMake] how to set ar/ranlib flags per target
>>
>> Kelly,
>>
>> I suffer from the same problem and solved it like this:
>>
>> SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -X64 cr <TARGET> <LINK_FLAGS>
>> <OBJECTS>")
>> SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> -X64 r  <TARGET> <LINK_FLAGS>
>> <OBJECTS>")
>> SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")
>> SET(CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
>> SET(CMAKE_CXX_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
>> SET(CMAKE_CXX_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})
>> SET(CMAKE_Fortran_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
>> SET(CMAKE_Fortran_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
>> SET(CMAKE_Fortran_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})
>>
>> Does that help you?
>>
>> Regards,
>> Arjen
>
>Thanks Arjen, but I don't believe it does.
>As far as I know that sets the flag globally, I have some targets that
>are 32 bit and some that are 64 bit, so I need to set it per target.
>
>Reading the source, I found STATIC_LIBRARY_FLAGS, which *almost* works,
>but it puts the flags AFTER the name of the output library, and ar on
>AIX doesn't like that, complains it can't find the object file -X64.
>Apparently the flag must come before the "cr" or "r" commands, e.g. "ar
>-X64 cr foo.a bar.o baz.o".
>
>Thanks,
>-Kelly
>
>>
>> >-----Original Message-----
>> >From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On
>> Behalf
>> >Of Hickel, Kelly
>> >Sent: woensdag 21 juli 2010 21:00
>> >To: cmake at cmake.org
>> >Subject: [CMake] how to set ar/ranlib flags per target
>> >
>> >
>> >Hello,
>> >
>> >I'm using CMake 2.8.1, and have a problem on AIX similar to this one:
>> >http://web.archiveorange.com/archive/v/5y7PkUbT6iizO31eshQa .
>> >
>> >I have the additional complication of needing to build both 32 and 64
>> >bit libraries from the same set of CMake files.
>> >
>> >I've tried a number of things (list below), does anyone have any
>> ideas?
>> >
>> >(Wherever I write CMAKE_C_xyz below, I've also changed CMAKE_CXX_xyz
>> >at the same time, where I write xyz_ARCHIVE_CREATE, I've also changed
>> >xyz_ARCHIVE_APPEND)
>> >
>> >1) Adding the flag to LINK_FLAGS because the definition for
>> >   CMAKE_C_ARCHIVE_CREATE appears to include that on the command
>line,
>> >   but the generated link.txt input files don't include any options.
>> >2) Changed the definition for CMAKE_C_ARCHIVE_CREATE in a private
>> >   toolchain file that I specify on the command line.  By writing
>> >   messages that show the value of that variable, I can see my change
>> >   take, but it appears to get reset to the default before processing
>> of
>> >   my CMakeLists.txt file begins.
>> >3) Frequently set CMAKE_C_ARCHIVE_CREATE to "<CMAKE_AR> <AR_FLAGS> r
>> >   <TARGET> <LINK_FLAGS> <OBJECTS>", when I did this, I ended up with
>> >the
>> >   literal string "AR_FLAGS" in the link.txt file, not that useful!
>> >
>> >I'm sure I'm missing something, any hints will be appreciated!
>> >
>> >Thanks,
>> >Kelly
>> >
>> >_______________________________________________
>> >Powered by www.kitware.com
>> >
>> >Visit other Kitware open-source projects at
>> >http://www.kitware.com/opensource/opensource.html
>> >
>> >Please keep messages on-topic and check the CMake FAQ at:
>> >http://www.cmake.org/Wiki/CMake_FAQ
>> >
>> >Follow this link to subscribe/unsubscribe:
>> >http://www.cmake.org/mailman/listinfo/cmake
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list