Skip to content

Instantly share code, notes, and snippets.

@matthewfeickert
Last active July 1, 2020 06:12
Show Gist options
  • Save matthewfeickert/a153968a7d2e2dd1e2c04a890146b3d2 to your computer and use it in GitHub Desktop.
Save matthewfeickert/a153968a7d2e2dd1e2c04a890146b3d2 to your computer and use it in GitHub Desktop.
Minimal failing exampe of CMake

Build

To provide the same testing environment as would be used in production:

$ docker pull atlas/analysisbase:21.2.114
$ docker run --rm -it -v $PWD:/code/ -w /code/ atlas/analysisbase:21.2.114 /bin/bash -c "source /release_setup.sh; bash"
# bash build.sh
#!/usr/bin/env bash
function print_and_run () {
printf "\n# %s\n" "${1}"
eval $(echo "$1")
}
function setNumProcessors () {
# Set the number of processors used for build
# to be 1 less than are available
if [[ -f "$(which nproc)" ]]; then
NPROC="$(nproc)"
else
NPROC="$(grep -c '^processor' /proc/cpuinfo)"
fi
echo "$(($(nproc)-1))"
}
function build {
cd "${baseDir}"
if [[ -d "${baseDir}/build" ]]; then
rm -rf "${baseDir}/build"
fi
print_and_run "mkdir -p build"
print_and_run "cd build"
print_and_run "cmake .."
NPROC="$(setNumProcessors)"
printf "\n# %s\n" "cmake --build . -- -j${NPROC}"
cmake --build . -- -j${NPROC}
}
# Run program
baseDir=${PWD}
build
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 14)
project(testing_frugal)
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.8.0
)
FetchContent_Declare(
FunctionalPlus
GIT_REPOSITORY https://github.com/Dobiasd/FunctionalPlus.git
GIT_TAG v0.2.7-p0
)
FetchContent_Declare(
frugally-deep
GIT_REPOSITORY https://github.com/Dobiasd/frugally-deep.git
GIT_TAG v0.14.3-p0
)
FetchContent_MakeAvailable(nlohmann_json FunctionalPlus frugally-deep) # This fails
#FetchContent_MakeAvailable(nlohmann_json FunctionalPlus) # This doesn't fail
@matthewfeickert
Copy link
Author

matthewfeickert commented Jul 1, 2020

Updating the GIT_TAGs following Dobiasd/frugally-deep#232 will cause this to no longer fail. 👍 Thanks @henryiii.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment