Set location of C ++ object object using CMake

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

  • The end result of the project should be a set of object files (* .o).
  • The location of the object files is important. I want to select the directory where the files are exposed.

Does CMake support this type of behavior? If so, how? Can I do this using move commands after building the object file?

+4
source share
1 answer

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 using install (DIRECTORY ...) .

Using parameters:

DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} #Probably you have to check more precisely where the object files are built DESTINATION #it something relative to DESTDIR, if set, or CMAKE_INSTALL_PREFIX otherwise FILES_MATCHING PATTERN "*.o" 

The disadvantage of this solution will be in the name of the output directory, which will be mainly decided by cmake, I wonder if something can be done in this regard.

0
source

Source: https://habr.com/ru/post/1486876/


All Articles