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?

4

3 回答 3

6
  1. 您的项目中必须有一个依赖于外部项目的目标

    add_dependencies(TargetName ExternalProjectName)
    
  2. git clone发生在构建TargetName (不是在 CMake 重新加载时)

于 2017-10-18T07:40:10.420 回答
0

您必须告诉 cmake 它需要“演示”来构建您的目标。通过这种方式,您可以强制 cmake 在编译之前下载外部项目“demo”。

例如

set(SRC ${PROJECT_SOURCE_DIR}/src/main.cpp 
    ${PROJECT_SOURCE_DIR}/src/file1.cpp)  
    add_executable(Demobin ${SRC})  
    add_dependencies(Demobin demo)
于 2015-07-21T16:10:20.160 回答
0

您将在此ANSWER中找到一个完整的示例。


当您(通过 git)添加外部项目时,在项目主要部分的构建开始之前获取(并构建)这些依赖项目有时很重要。

您可以通过将选项STEP_TARGETS build添加到ExternalProject_Add部分来实现此目的。见答案

于 2019-11-08T08:32:36.583 回答