Reputation: 71
I have a git-bare-repository on my desktop and I would like to clone it with CMake. My repository has this path C:\Users\demoUser\Desktop\learnGIT\prog
. My CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 2.8)
project(Demo)
include(ExternalProject)
ExternalProject_Add(demo
GIT_REPOSITORY C:/Users/demoUser/Desktop/learnGIT/prog
GIT_TAG master
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
but in the generated folder prog-build
is just wast. The generated folder structure doesn't include any of my files from the repository.
Does somebody has an idea?
Upvotes: 7
Views: 12296
Reputation: 2351
You'll find a complete example in this ANSWER.
When you add external projects (via git) it's sometimes important to have these dependent projects fetched (and build) before the building of the main part of your project starts.
You can achieve this by adding the option STEP_TARGETS build to your ExternalProject_Add section. See the ANSWER.
Upvotes: 0
Reputation: 506
You have to have a target in your project that depends on external project
add_dependencies(TargetName ExternalProjectName)
The git clone
happens on TargetName
build (not on CMake reload)
Upvotes: 6
Reputation: 61
you have to tell cmake that it needs "demo" to build your target. In this way you force cmake to download the external project "demo" before compiling.
for example
set(SRC ${PROJECT_SOURCE_DIR}/src/main.cpp
${PROJECT_SOURCE_DIR}/src/file1.cpp)
add_executable(Demobin ${SRC})
add_dependencies(Demobin demo)
Upvotes: 0