Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

external project - Unknown CMake command "ExternalProject_Add"

I have following CMakeLists.txt file:

cmake_minimum_required (VERSION 3.2 FATAL_ERROR)

project (utils VERSION 1.0.0 LANGUAGES CXX)

ExternalProject_Add(json-c
    GIT_REPOSITORY "https://github.com/json-c/json-c.git"
    UPDATE_COMMAND git pull "https://github.com/json-c/json-c.git"

    CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image/./configure
                      --prefix=${SDL_INSTALL_DIR}

    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/json-c

    INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
    )

I want to add json-c library to my project, but when I run cmake I'm getting error: Unknown CMake command "ExternalProject_Add". My CMake version is 3.6.2 on OS X

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

While it is not directly written in documentation pages for versions prior to v3.14, CMake functions described under cmake-modules section requires including specific module.

As function ExternalProject_Add is described in the documentation page titled as "ExternalProject", you need to use

include(ExternalProject)

before using it.


Same strategy works for any other modules except Find<name> ones. Those modules are used via

find_package(<name>)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...