Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Directory for CMake Library Output

Tags:

cmake

In CMake, I can't seem to output my library in ../out/library, only library. When I do the ../out/library path, it tells me it can't find the library, as if it wants to link to it.

add_library(../out/JE3D ../source/CDeviceLayerSDL.cpp) 

There's more files, I'm just saving space. When I do that, I get this error.

Linking CXX static library lib../out/JE3D.a /usr/bin/ar: lib../out/JE3D.a: No such file or directory make[2]: * [lib../out/JE3D.a] Error 1 make[1]: * [CMakeFiles/../out/JE3D.dir/all] Error 2 make: *** [all] Error 2

like image 582
Jookia Avatar asked Sep 18 '10 14:09

Jookia


People also ask

Where is my cmake executable?

Run cmake-gui.exe, which should be in your Start menu under Program Files, there may also be a shortcut on your desktop, or if you built from source, it will be in the build directory.


1 Answers

The LIBRARY_OUTPUT_DIRECTORY target property specifies the directory where library target files will be built.

set_target_properties(JE3D PROPERTIES          LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library) 

If all the libraries are in one directory, I find it more convenient to set the CMAKE_LIBRARY_OUTPUT_DIRECTORY variable, which is used to initialize the LIBRARY_OUTPUT_DIRECTORY property when creating a target.

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library) 

Edit: Check comments if your target is a static library

like image 183
Chin Huang Avatar answered Oct 18 '22 10:10

Chin Huang