Czy można w projekcie cmake kompilować kilka aplikacji które używają bibliotek z GIT-a
ale każda aplikacja używa innej rewizji ?
app1 używa biblioteki https://git.com/xyz.git wersji 000001
app2 używa biblioteki https://git.com/xyz.git wersji 000002
cmake_minimum_required(VERSION 3.0.0)
project(app1 VERSION 0.1.0)
include(FetchContent)
FetchContent_Declare(
lib1
GIT_REPOSITORY https://git.com/xyz.git
GIT_TAG 000001
)
FetchContent_Populate(lib1)
add_subdirectory(${lib1_SOURCE_DIR} ${lib1_BINARY_DIR})
add_executable(app1 main.cpp)
target_link_libraries(app1 lib)
cmake_minimum_required(VERSION 3.0.0)
project(app2 VERSION 0.1.0)
include(FetchContent)
FetchContent_Declare(
lib2
GIT_REPOSITORY https://git.com/xyz.git
GIT_TAG 000002
)
FetchContent_Populate(lib2)
add_subdirectory(${lib2_SOURCE_DIR} ${lib2_BINARY_DIR})
add_executable(app2 main.cpp)
cmake_minimum_required(VERSION 3.0.0)
project(master VERSION 0.1.0)
add_subdirectory(app1)
add_subdirectory(app2)
CMake Error at build/_deps/.../CMakeLists.txt:x (add_library):
[build] add_library cannot create target "xyz" because another
[build] target with the same name already exists. The existing target is a static
[build] library created in source directory
[build] ".../build/_deps/lib2-src/src".
[build] See documentation for policy CMP0002 for more details.