I have a Project with the following folder structure
/
|- build
|- MyLib1
| |- source
| | |- lib1_s1.cpp
| | |- lib2_s2.cpp
| |- include
| | |- lib1_s1.hpp
| | |- lib2_s2.hpp
| |- CMakeLists.txt
|- app
| |- source
| | |- app_s1.cpp
| | |- app_s2.cpp
| |- include
| | |- app_s1.hpp
| | |- app_s2.hpp
| |- CMakeLists.txt
|
|- CMakeLists.txt
My app depends on MyLib1 (compiled as a static library). lib1/CMakeLists.txt is as follows:
add_library(MyLib1 STATIC ${LIB_SRC})
install(TARGETS MyLib1 DESTINATION ${CMAKE_SOURCE_DIR}/bin)
And my app/CMakeLists.txt is as follows:
add_executable(app ${APP_SRC}/main.cpp)
target_link_libraries(app ${CMAKE_SOURCE_DIR}/bin/libMyLib1.a )
install(TARGETS app DESTINATION ${CMAKE_SOURCE_DIR}/bin)
In my build folder, I call cmake which builds MyLib1 successfully, but doesn't install it. The error generated is:
make[2]: *** No rule to make target `../bin/libMyLib1.a', needed by`/app'. Stop.
My Cmake version is:
cmake version 3.11.0-rc3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
I've already seen a few answers on stack overflow with the most relevant being this. But, the proposed solution doesn't seem to solve my problem.
What could I do differently to resolve the issue?