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

Verweij, Arjen VerweijA at tass-safe.com
Wed Jul 21 16:42:56 EDT 2010


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

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


More information about the CMake mailing list