4

I would like to use CMake for a project, but I have the following two requirements:

  1. The final output of the project should be a set of object files (*.o).
  2. The location of the object files is important. I want to select which directory the files are outputted.

Does CMake support this type of behavior? If so, how? Can I do it with move commands after the object file is build?

dcdo
  • 161
  • 1
  • 6
  • Is your source tree split up over multiple directories? or are all your source files in the directories? – GWW Jun 18 '13 at 17:17
  • All source files are in a single directory. The object files will need to go to a special directory for use later by a proprietary commercial software package. – dcdo Jun 18 '13 at 17:27
  • This is one case where CMake is just a REALLY bad fit. If you must use cmake I'd run a bash or python script after to search the build tree for the .o files you are looking for, then package them up. – JonnyRo Jul 12 '13 at 01:04

1 Answers1

0

First create an object library.

Now the problem is that:

Object libraries cannot be imported, exported, installed, or linked. http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:add_library

I would try to use the install(DIRECTORY ...).

Using the options:

DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}   #Probably you have to check more precisely where the object files are built

DESTINATION    #it's something relative to DESTDIR, if set, or CMAKE_INSTALL_PREFIX otherwise

FILES_MATCHING

PATTERN "*.o"

A flaw of this solution will be in the output directory name, that will be basically decided by cmake, I wonder if anything can be done in that respect.

Antonio
  • 19,451
  • 13
  • 99
  • 197