I have following project structure
CmakeLists.txt
src/main.cpp
A/CMakeLists.txt
A/test.cpp
B/CMakeLists.txt
B/other.cpp
libs/
The build configuration is written in a way that the sub-directories are compiled as static libraries (stored into libs) and then they are used to produce final binary.
Now suppose I transfer this project to my bud, with only CMakeLists.txt, source-files and static libraries in libs.
When compiling the project, he/she have to recompile again all the source files, despite the libraries are already there.
Is there any way to tell cmake to re-use pre-build static libraries ??
Excerpt from top cmakelist.txt .
add_subdirectory (${PROJECT_SOURCE_DIR}/src/A)
add_subdirectory (${PROJECT_SOURCE_DIR}/src/B)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
add_executable(myBinary ${PROJECT_SOURCE_DIR}/src/main.cpp )
add_dependencies(myBinary A B)
target_link_libraries (myBinary A B)
Subdirectory cmakelist.txt .
project (A)
file(GLOB SOURCES "*.cpp")
add_library (A STATIC ${SOURCES})