7

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
user3841904
  • 71
  • 1
  • 1
  • 4
  • 2
    please post any error messages cmake/make/VS gives you. which exact cmake version are you using? it runs fine on cmake 3.1 on my ubuntu14 where i use exactly your code (but my bare repo and branch). – daniel.wirtz Feb 04 '15 at 10:25

3 Answers3

6
  1. You have to have a target in your project that depends on external project

    add_dependencies(TargetName ExternalProjectName)
    
  2. The git clone happens on TargetName build (not on CMake reload)

Oleg
  • 486
  • 6
  • 12
0

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)
Ramy Gad
  • 61
  • 1
  • 3
0

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.

Chris
  • 2,071
  • 4
  • 14
  • 22