[CMake] CMAKE_ARGS for FetchContent

Mads Andreasen temp1 at andreasen.cc
Fri Jul 6 06:25:40 EDT 2018


Hi,

I am trying to work with FetchContent in cmake 3.11.
I want to use the jsoncpp library and use FetchContent to get and build it.

I also want to configure the jsoncpp build with some cmake arguments and I
can't seem to get that right.

My CMakeLists.txt looks like this:
**************************************************************
cmake_minimum_required(VERSION 3.11)
project(Foo)

include(FetchContent)

FetchContent_Declare(jsoncpp
  URL "c:/project/jsoncpp-src"
    CMAKE_ARGS
"-DJSONCPP_WITH_CMAKE_PACKAGE=ON;-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF"
)

FetchContent_Populate(jsoncpp)

add_executable(Foo main.cpp)
**************************************************************


FetchContent downloads and configures the jsoncpp as an ExternalProject.
That part looks like this:
*********************************************
ExternalProject_Add(jsoncpp-populate
                     "UPDATE_DISCONNECTED" "False" "URL"
"c:/project/jsoncpp-src" "CMAKE_ARGS" "-DJSONCPP_WITH_CMAKE_PACKAGE=ON"
"-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF"
                    SOURCE_DIR
"C:/temp/foo/build/_deps/jsoncpp-src"
                    BINARY_DIR
"C:/temp/foo/build/_deps/jsoncpp-build"
                    CONFIGURE_COMMAND   ""
                    BUILD_COMMAND       ""
                    INSTALL_COMMAND     ""
                    TEST_COMMAND        ""
)
*******************************************************

For the external project - the CMAKE_ARGS are no longer a list, but
individual arguments.

I have tried different things, like escaping the ; with \\; and stuff like
that, and I can't get it to work.
I'm thinking there is something obvious I am missing?

Best regards,
Mads
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180706/73c04ab4/attachment.html>


More information about the CMake mailing list