On 22. Apr, 2010, at 7:52 , Matthias Goesswein wrote:

> Am 21.04.2010 18:56, schrieb Alexander Neundorf:
>> On Wednesday 21 April 2010, Matthias Goesswein wrote:
>>> Hello!
>>> 
>>> My libarian-tool needs a flag before each object file:
>>> 
>>> e.g.
>>> 
>>> libarian -a file1.o -a file2.o -a file3.o library.a
>>> 
>>> CMake provides the<OBJECTS>  tag variable for use within the rule
>>> variable of the libarian, but i didn't fond a way to insert the "-a"
>>> flags before each object file.
>>> 
>>> Is there any way for doing that?
>> 
>> AFAIK no.
>> Please put it as feature request in the bug tracker.
>> What kind of toolchain are you using ?
>> 
>> Alex
> 
> I'd like to use the Softune toolchain (for Fujitsu Microcontrollers), and the 
> librarian can only add object files to an library with the "-a" command line 
> option. All object files must have that flag. It could be done with wrapper 
> shell scripts, but shells are platform specific and so it's for me a no go. 
> It's no problem if you use only one build plattform, but if not so, you would 
> have to write several shell scripts, or add the shell executable for each 
> build plattform.
> 
> I've already put it in as a feature request yesterday 
> (http://public.kitware.com/Bug/view.php?id=10588)
> 
> I also want to use Keil Compiler with CMake, but i would also need wrapper 
> scripts for the compiler, librarian and linker, because of the non standard 
> way of command line options. (It uses brackets, something like: cc 
> -o{obj1.o,obj2.o,...})
> 
> It would be nice to have the latter approach of my feature request (with 
> regular expressions), because it would be highly customizable. Someone could 
> even change slashes to backslashes, which could be handy if a windows tool is 
> used within cygwin or msys, which requires backslashes (slashes are standard 
> on cygwin or msys).
> 
> Matthias.

You don't have to use shell wrapper scripts. CMake is a portable (rather 
quirky) scripting language ;-) I often do something like this:

add_custom_command(OUTPUT something
  COMMAND "${CMAKE_COMMAND}" -DSOME=VALUE -P 
"${CMAKE_CURRENT_BINARY_DIR}/some_configured_script.cmake"
  DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/some_configured_script.cmake"
  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  COMMENT "Doing something incredibly smart"
  VERBATIM
  )


You can also modify CMAKE_<LANG>_CREATE_STATIC_LIBRARY to suit your needs, 
perhaps something like this:

set(CMAKE_C_CREATE_STATIC_LIBRARY
  "${CMAKE_COMMAND} -DOBJECTS=\"<OBJECTS>\" -DLIBRARY=\"<TARGET>\" -P 
${CMAKE_BINARY_DIR}/create_archive.cmake")


where create_archive.cmake is configured to contain the full path to the 
librarian tool (using @ONLY) and perhaps with other things. E.g. 
create_archive.cmake.in might contain (untested):

set(ARGS)
foreach(o IN LISTS OBJECTS)
  set(ARGS "${ARGS} -a ${o}")
endforeach()
set(ARGS "${ARGS} ${LIBRARY}")

execute_process(
  COMMAND "@LIBRARIAN_EXECUTABLE@" ${ARGS}
  RESULT_VARIABLE RES
  OUTPUT_VARIABLE OUT
  ERROR_VARIABLE OUT)

if(RES)
  message(FATAL_ERROR "@LIBRARIAN_EXECUTABLE@ failed to create archive 
${LIBRARY}."
    "The output message was\n"
    "${OUT}")
endif()


HTH

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

Reply via email to