open-source-parsers / open-source-parsers/jsoncpp
CMake FetchContent build error
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.9k
- Forks
- 2.7k
- Avg merge
- 31m
- Merged PRs (30d)
- 1
Description
Describe the bug
I'm attempting to switch my project's dependencies over to CMake's FetchContent functionality, but jsoncpp returns a build error. Full disclaimer, I'm just starting to experiment with the FetchContent functionality and I'm not an expert on CMake.
I'm using CMake 3.25.2. The version of CMake that introduced FetchContent_MakeAvailable, which downloads and builds external dependencies, was 3.14.
Here's the error:
λ cmake .
[...]
-- JsonCpp Version: 1.9.5
######################################################
# jsoncpp should not be configured & built in the jsoncpp source directory
# You must run cmake in a build directory.
# For example:
# mkdir jsoncpp-Sandbox ; cd jsoncpp-sandbox
# git clone https://github.com/open-source-parsers/jsoncpp.git # or download & unpack the source tarball
# mkdir jsoncpp-build
# this will create the following directory structure
#
# jsoncpp-Sandbox
# +--jsoncpp
# +--jsoncpp-build
#
# Then you can proceed to configure and build
# by using the following commands
#
# cd jsoncpp-build
# cmake ../jsoncpp # or ccmake, or cmake-gui
# make
#
# NOTE: Given that you already tried to make an in-source build
# CMake have already created several files & directories
# in your source tree. run 'git status' to find them and
# remove them by doing:
#
# cd jsoncpp-Sandbox/jsoncpp
# git clean -n -d
# git clean -f -d
# git checkout --
#
######################################################
CMake Error at _deps/jsoncpp_dep-src/include/PreventInSourceBuilds.cmake:41 (message):
Quitting configuration
Call Stack (most recent call first):
_deps/jsoncpp_dep-src/include/PreventInSourceBuilds.cmake:45 (AssureOutOfSourceBuilds)
_deps/jsoncpp_dep-src/CMakeLists.txt:81 (include)
To Reproduce
Steps to reproduce the behavior:
- Include the following snippet in a project with a CMakeLists.txt file:
cmake_minimum_required (VERSION 3.14)
[...]
FetchContent_Declare (jsoncpp_dep
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp
GIT_TAG 5defb4ed1a4293b8e2bf641e16b156fb9de498cc)
FetchContent_MakeAvailable (jsoncpp_dep)
- Run
cmake .in the project directory.
Expected behavior
The project would build as expected.
Desktop (please complete the following information):
- OS: macOS 12.6.3 Monterey
- CMake 3.25.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided CMakeLists.txt snippet and cmake .. Start by reading _deps/jsoncpp_dep-src/include/PreventInSourceBuilds.cmake and the call from CMakeLists.txt at line 81. Done means the FetchContent configuration no longer aborts with the in-source-build error and the project builds as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100