In my project there is a folder that contains third party libraries (google test, zlib, ...). I want to put the libraries in a common folder when all this libraries are built. I'm trying to do this with cmake but I'm having problems. I'm trying this code:
add_subdirectory(gtest-1.6.0)
add_custom_command(
TARGET gtest_main
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SRC_LIB_DIR}/*.a ${DST_LIB_DIR})
I think the problem could be that the target gtest main in not defined at this level but in a lower level
If you set the CMAKE_LIBRARY_OUTPUT_DIRECTORY
variable in your CMakeLists.txt before calling add_subdirectory
(and the subproject does not override it), libraries should fall into the right place.
Additionally like this the target in the subproject keeps their dependency to the output-file. Which wouldn't work with your copy - the target would be always out-of-date and thus rebuilt.
EDIT: I overlooked that your copy-command is copying .a-files and thanks to @Fraser's comment I learned as well that CMAKE_ARCHIVE_OUTPUT_DIRECTORY
should to do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With