Compare commits

..

7 Commits

Author SHA1 Message Date
Lars Melchior
1ce0b9926b set EXCLUDE_FROM_ALL as an optional flag 2021-02-15 13:45:16 +01:00
Lars Melchior
c309839859 respect DOWNLOAD_ONLY flag 2021-02-15 13:11:51 +01:00
Lars Melchior
b80286ef81 add dependencies using EXCLUDE_FROM_ALL flag 2021-02-15 13:04:32 +01:00
Lars Melchior
02d57a1601 Update URLs for new CPM.cmake organisation (#194)
* update URLs for new CPM.cmake organisation

* trigger travis
2021-02-08 21:31:06 +01:00
Claus Klein
5f614e5eb6 update most package versions (#190)
* update most package versions

extent build_all.py to inject cmake modules
and use Ninja generator

* fix build problems while build on debian

use SYSTEM include paths (for clang++)
we should not use local installed header!

* fix banchmark example

finalize cmake project code injection as an option

* fix build problems on travis CI

gtest needs c++17

* Update examples/build_all.py

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>

* reindent py script requested by review

indent with only 2 spaces again

* changes according the review

the gtest build error seems to be a make -j cpucount problem

* revert filter too

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
2021-02-07 17:08:04 +01:00
Xavier Muller
1f5cb903e5 fix superbuild cmake < 3.17 (#193)
* CPM_INDENT in the global scope as suggest

* Fix FetchContent failure with cmake < 3.17

* format
2021-02-07 17:07:47 +01:00
alexandreSalconiDenis
7000572bbe Feature/prettify package lock (#162)
* add prettify macro

* apply the prettier and change the name of the output arg

* add parameter inside macro

* resolve path if its cmake_sourc_dir

* add missing uparsed argument

* add early unit test for prettifier

* retab prettify_cpm_add_package

* rename prettify_cpm_add_package  cpm_prettyfy_package_arguments

* convert macro to function and fix unit test

* fix typo in the name of the parse argument in prettyfy function

* change the unit test to test only the function

* add test for the commented part

* remove dead code

* fix typo

* run cmake-format on CPM.cmake

* reformated unit test prettify

* flip the logic to add space on new argument unparsed to avoir space at the end

* remove debug message

* apply most suggestion from pr 162, disable formating only for small part in unit test

* add unit test to cover defauld source dir added inside lock

* run format tool on unit test

* remove dead code

* change the prettifier from 4 space to 2

* run format on unit test
2021-01-27 13:29:15 +01:00
23 changed files with 227 additions and 90 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
build/
/build*
/.vscode
*.DS_Store
*.DS_Store

View File

@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.com/TheLartians/CPM.cmake.svg?branch=master)](https://travis-ci.com/TheLartians/CPM.cmake)
[![Actions Status](https://github.com/TheLartians/CPM.cmake/workflows/MacOS/badge.svg)](https://github.com/TheLartians/CPM.cmake/actions)
[![Actions Status](https://github.com/TheLartians/CPM.cmake/workflows/Windows/badge.svg)](https://github.com/TheLartians/CPM.cmake/actions)
[![Actions Status](https://github.com/TheLartians/CPM.cmake/workflows/Ubuntu/badge.svg)](https://github.com/TheLartians/CPM.cmake/actions) [![Join the chat at https://gitter.im/TheLartians/CPM.cmake](https://badges.gitter.im/TheLartians/CPM.cmake.svg)](https://gitter.im/TheLartians/CPM.cmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.com/cpm-cmake/CPM.cmake.svg?branch=master)](https://travis-ci.com/cpm-cmake/CPM.cmake)
[![Actions Status](https://github.com/cpm-cmake/CPM.cmake/workflows/MacOS/badge.svg)](https://github.com/cpm-cmake/CPM.cmake/actions)
[![Actions Status](https://github.com/cpm-cmake/CPM.cmake/workflows/Windows/badge.svg)](https://github.com/cpm-cmake/CPM.cmake/actions)
[![Actions Status](https://github.com/cpm-cmake/CPM.cmake/workflows/Ubuntu/badge.svg)](https://github.com/cpm-cmake/CPM.cmake/actions)
<br />
<p align="center">
@@ -80,19 +80,19 @@ CPMAddPackage(
target_link_libraries(tests Catch2)
```
See the [examples directory](https://github.com/TheLartians/CPM.cmake/tree/master/examples) for complete examples with source code and check [below](#snippets) or in the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/More-Snippets) for example snippets.
See the [examples directory](https://github.com/cpm-cmake/CPM.cmake/tree/master/examples) for complete examples with source code and check [below](#snippets) or in the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets) for example snippets.
## Adding CPM
To add CPM to your current project, simply add the [latest release](https://github.com/TheLartians/CPM.cmake/releases/latest) of `CPM.cmake` or `get_cpm.cmake` to your project's `cmake` directory.
To add CPM to your current project, simply add the [latest release](https://github.com/cpm-cmake/CPM.cmake/releases/latest) of `CPM.cmake` or `get_cpm.cmake` to your project's `cmake` directory.
The command below will perform this automatically.
```bash
mkdir -p cmake
wget -O cmake/CPM.cmake https://github.com/TheLartians/CPM.cmake/releases/latest/download/get_cpm.cmake
wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
```
You can also download CPM.cmake directly from your project's `CMakeLists.txt`. See the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/Downloading-CPM.cmake-in-CMake) for more details.
You can also download CPM.cmake directly from your project's `CMakeLists.txt`. See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Downloading-CPM.cmake-in-CMake) for more details.
## Updating CPM
@@ -112,7 +112,7 @@ Dependencies using CPM will automatically use the updated script of the outermos
## Limitations
- **No pre-built binaries** For every new build directory, all dependencies are initially downloaded and built from scratch. To avoid extra downloads it is recommend to set the [`CPM_SOURCE_CACHE`](#CPM_SOURCE_CACHE) environmental variable. Using a caching compiler such as [ccache](https://github.com/TheLartians/Ccache.cmake) can drastically reduce build time.
- **Dependent on good CMakeLists** Many libraries do not have CMakeLists that work well for subprojects. Luckily this is slowly changing, however, until then, some manual configuration may be required (see the snippets [below](#snippets) for examples). For best practices on preparing projects for CPM, see the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/Preparing-projects-for-CPM.cmake).
- **Dependent on good CMakeLists** Many libraries do not have CMakeLists that work well for subprojects. Luckily this is slowly changing, however, until then, some manual configuration may be required (see the snippets [below](#snippets) for examples). For best practices on preparing projects for CPM, see the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Preparing-projects-for-CPM.cmake).
- **First version used** In diamond-shaped dependency graphs (e.g. `A` depends on `C`@1.1 and `B`, which itself depends on `C`@1.2 the first added dependency will be used (in this case `C`@1.1). In this case, B requires a newer version of `C` than `A`, so CPM will emit a warning. This can be easily resolved by adding a new version of the dependency in the outermost project, or by introducing a [package lock file](#package-lock).
For projects with more complex needs and where an extra setup step doesn't matter, it may be worth to check out an external C++ package manager such as [vcpkg](https://github.com/microsoft/vcpkg), [conan](https://conan.io) or [hunter](https://github.com/ruslo/hunter).
@@ -127,7 +127,7 @@ Additionally, it is difficult to cross-compile projects (e.g. for mobile), as th
CPM.cmake allows dependencies to be unambiguously defined and builds them from source.
Note that the behaviour differs from `find_package`, as variables exported to the parent scope (such as `<PackageName>_LIBRARIES`) will not be visible after adding a package using CPM.cmake.
The behaviour can be [achieved manually](https://github.com/TheLartians/CPM.cmake/issues/132#issuecomment-644955140), if required.
The behaviour can be [achieved manually](https://github.com/cpm-cmake/CPM.cmake/issues/132#issuecomment-644955140), if required.
## Comparison to pure FetchContent / ExternalProject
@@ -160,7 +160,7 @@ export CPM_SOURCE_CACHE=$HOME/.cache/CPM
Note that passing the variable as a configure option to CMake will always override the value set by the environmental variable.
You can use `CPM_SOURCE_CACHE` on GitHub Actions workflows [cache](https://github.com/actions/cache) and combine it with ccache, to make your CI faster. See the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/Caching-with-CPM.cmake-and-ccache-on-GitHub-Actions) for more info.
You can use `CPM_SOURCE_CACHE` on GitHub Actions workflows [cache](https://github.com/actions/cache) and combine it with ccache, to make your CI faster. See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Caching-with-CPM.cmake-and-ccache-on-GitHub-Actions) for more info.
### CPM_DOWNLOAD_ALL
@@ -201,7 +201,7 @@ cmake -Bbuild
cmake --build build --target cpm-update-package-lock
```
See the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/Package-lock) for more info.
See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Package-lock) for more info.
## Built with CPM.cmake
@@ -240,7 +240,7 @@ If you know others, feel free to add them here through a PR.
## Snippets
These examples demonstrate how to include some well-known projects with CPM.
See the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/More-Snippets) for more snippets.
See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets) for more snippets.
### [Catch2](https://github.com/catchorg/Catch2)
@@ -371,4 +371,4 @@ For a full example on using CPM to download and configure lua with sol2 see [her
### Full Examples
See the [examples directory](https://github.com/TheLartians/CPM.cmake/tree/master/examples) for full examples with source code and check out the [wiki](https://github.com/TheLartians/CPM.cmake/wiki/More-Snippets) for many more example snippets.
See the [examples directory](https://github.com/cpm-cmake/CPM.cmake/tree/master/examples) for full examples with source code and check out the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets) for many more example snippets.

View File

@@ -1,6 +1,6 @@
# CPM.cmake - CMake's missing package manager
# ===========================================
# See https://github.com/TheLartians/CPM.cmake for usage and update instructions.
# See https://github.com/cpm-cmake/CPM.cmake for usage and update instructions.
#
# MIT License
# -----------
@@ -38,9 +38,12 @@ if(CPM_DIRECTORY)
"${CPM_INDENT} \
A dependency is using a more recent CPM version (${CURRENT_CPM_VERSION}) than the current project (${CPM_VERSION}). \
It is recommended to upgrade CPM to the most recent version. \
See https://github.com/TheLartians/CPM.cmake for more information."
See https://github.com/cpm-cmake/CPM.cmake for more information."
)
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
include(FetchContent)
endif()
return()
endif()
@@ -133,7 +136,10 @@ include(CMakeParseArguments)
# Initialize logging prefix
if(NOT CPM_INDENT)
set(CPM_INDENT "CPM:")
set(CPM_INDENT
"CPM:"
CACHE INTERNAL ""
)
endif()
function(cpm_find_package NAME VERSION)
@@ -237,6 +243,8 @@ endfunction()
# Download and add a package from source
function(CPMAddPackage)
set(flagArgs EXCLUDE_FROM_ALL)
set(oneValueArgs
NAME
FORCE
@@ -255,7 +263,7 @@ function(CPMAddPackage)
set(multiValueArgs OPTIONS)
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
cmake_parse_arguments(CPM_ARGS "${flagArgs}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
# Set default values for arguments
@@ -381,7 +389,9 @@ function(CPMAddPackage)
set(${CPM_ARGS_NAME}_ADDED YES)
set(${CPM_ARGS_NAME}_SOURCE_DIR ${download_directory})
if(NOT CPM_ARGS_DOWNLOAD_ONLY AND EXISTS ${download_directory}/CMakeLists.txt)
add_subdirectory(${download_directory} ${${CPM_ARGS_NAME}_BINARY_DIR})
cpm_add_subdirectory(
${download_directory} ${${CPM_ARGS_NAME}_BINARY_DIR} "${CPM_ARGS_EXCLUDE_FROM_ALL}"
)
endif()
set(CPM_SKIP_FETCH TRUE)
set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
@@ -421,7 +431,7 @@ function(CPMAddPackage)
cpm_declare_fetch(
"${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}"
)
cpm_fetch_package("${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}")
cpm_fetch_package("${CPM_ARGS_NAME}" "${DOWNLOAD_ONLY}" "${CPM_ARGS_EXCLUDE_FROM_ALL}")
cpm_get_fetch_properties("${CPM_ARGS_NAME}")
endif()
@@ -464,14 +474,16 @@ endmacro()
function(cpm_add_to_package_lock Name)
if(NOT CPM_DONT_CREATE_PACKAGE_LOCK)
file(APPEND ${CPM_PACKAGE_LOCK_FILE} "# ${Name}\nCPMDeclarePackage(${Name} \"${ARGN}\")\n")
cpm_prettify_package_arguments(PRETTY_ARGN false ${ARGN})
file(APPEND ${CPM_PACKAGE_LOCK_FILE} "# ${Name}\nCPMDeclarePackage(${Name}\n${PRETTY_ARGN})\n")
endif()
endfunction()
function(cpm_add_comment_to_package_lock Name)
if(NOT CPM_DONT_CREATE_PACKAGE_LOCK)
cpm_prettify_package_arguments(PRETTY_ARGN true ${ARGN})
file(APPEND ${CPM_PACKAGE_LOCK_FILE}
"# ${Name} (unversioned)\n# CPMDeclarePackage(${Name} \"${ARGN}\")\n"
"# ${Name} (unversioned)\n# CPMDeclarePackage(${Name}\n${PRETTY_ARGN}#)\n"
)
endif()
endfunction()
@@ -542,23 +554,35 @@ function(cpm_get_fetch_properties PACKAGE)
)
endfunction()
function(cpm_add_subdirectory SOURCE_DIR BINARY_DIR EXCLUDE)
if(EXCLUDE)
set(addSubdirectoryExtraArgs EXCLUDE_FROM_ALL)
else()
set(addSubdirectoryExtraArgs "")
endif()
add_subdirectory(${SOURCE_DIR} ${BINARY_DIR} ${addSubdirectoryExtraArgs})
endfunction()
# downloads a previously declared package via FetchContent
function(cpm_fetch_package PACKAGE DOWNLOAD_ONLY)
function(cpm_fetch_package PACKAGE DOWNLOAD_ONLY EXCLUDE)
if(${CPM_DRY_RUN})
message(STATUS "${CPM_INDENT} package ${PACKAGE} not fetched (dry run)")
return()
endif()
if(DOWNLOAD_ONLY)
FetchContent_GetProperties(${PACKAGE})
if(NOT ${PACKAGE}_POPULATED)
FetchContent_Populate(${PACKAGE})
FetchContent_GetProperties(${PACKAGE})
string(TOLOWER "${PACKAGE}" lower_case_name)
if(NOT ${lower_case_name}_POPULATED)
FetchContent_Populate(${PACKAGE})
if(NOT DOWNLOAD_ONLY AND EXISTS ${${lower_case_name}_SOURCE_DIR}/CMakeLists.txt)
set(CPM_OLD_INDENT "${CPM_INDENT}")
set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:")
cpm_add_subdirectory(
${${lower_case_name}_SOURCE_DIR} ${${lower_case_name}_BINARY_DIR} ${EXCLUDE}
)
set(CPM_INDENT "${CPM_OLD_INDENT}")
endif()
else()
set(CPM_OLD_INDENT "${CPM_INDENT}")
set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:")
FetchContent_MakeAvailable(${PACKAGE})
set(CPM_INDENT "${CPM_OLD_INDENT}")
endif()
endfunction()
@@ -625,3 +649,68 @@ function(cpm_is_git_tag_commit_hash GIT_TAG RESULT)
endif()
endif()
endfunction()
function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT)
set(oneValueArgs
NAME
FORCE
VERSION
GIT_TAG
DOWNLOAD_ONLY
GITHUB_REPOSITORY
GITLAB_REPOSITORY
GIT_REPOSITORY
SOURCE_DIR
DOWNLOAD_COMMAND
FIND_PACKAGE_ARGUMENTS
NO_CACHE
GIT_SHALLOW
)
set(multiValueArgs OPTIONS)
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(oneArgName ${oneValueArgs})
if(DEFINED CPM_ARGS_${oneArgName})
if(${IS_IN_COMMENT})
string(APPEND PRETTY_OUT_VAR "#")
endif()
if(${oneArgName} STREQUAL "SOURCE_DIR")
string(REPLACE ${CMAKE_SOURCE_DIR} "\${CMAKE_SOURCE_DIR}" CPM_ARGS_${oneArgName}
${CPM_ARGS_${oneArgName}}
)
endif()
string(APPEND PRETTY_OUT_VAR " ${oneArgName} ${CPM_ARGS_${oneArgName}}\n")
endif()
endforeach()
foreach(multiArgName ${multiValueArgs})
if(DEFINED CPM_ARGS_${multiArgName})
if(${IS_IN_COMMENT})
string(APPEND PRETTY_OUT_VAR "#")
endif()
string(APPEND PRETTY_OUT_VAR " ${multiArgName}\n")
foreach(singleOption ${CPM_ARGS_${multiArgName}})
if(${IS_IN_COMMENT})
string(APPEND PRETTY_OUT_VAR "#")
endif()
string(APPEND PRETTY_OUT_VAR " \"${singleOption}\"\n")
endforeach()
endif()
endforeach()
if(NOT "${CPM_ARGS_UNPARSED_ARGUMENTS}" STREQUAL "")
if(${IS_IN_COMMENT})
string(APPEND PRETTY_OUT_VAR "#")
endif()
string(APPEND PRETTY_OUT_VAR " ")
foreach(CPM_ARGS_UNPARSED_ARGUMENT ${CPM_ARGS_UNPARSED_ARGUMENTS})
string(APPEND PRETTY_OUT_VAR " ${CPM_ARGS_UNPARSED_ARGUMENT}")
endforeach()
string(APPEND PRETTY_OUT_VAR "\n")
endif()
set(${OUT_VAR}
${PRETTY_OUT_VAR}
PARENT_SCOPE
)
endfunction()

View File

@@ -13,7 +13,7 @@ endif()
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()

View File

@@ -10,9 +10,9 @@ find_package(Threads REQUIRED)
CPMAddPackage(
NAME asio
VERSION 1.16.1
VERSION 1.18.1
GITHUB_REPOSITORY chriskohlhoff/asio
GIT_TAG asio-1-16-1 # asio uses non-standard version tag, we must specify GIT_TAG
GIT_TAG asio-1-18-1 # asio uses non-standard version tag, we must specify GIT_TAG
)
# ASIO doesn't use CMake, we have to configure it manually. Extra notes for using on Windows:
@@ -24,7 +24,7 @@ CPMAddPackage(
if(asio_ADDED)
add_library(asio INTERFACE)
target_include_directories(asio INTERFACE ${asio_SOURCE_DIR}/asio/include)
target_include_directories(asio SYSTEM INTERFACE ${asio_SOURCE_DIR}/asio/include)
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED)
@@ -65,3 +65,4 @@ endif()
add_executable(CPMExampleASIOStandalone main.cpp)
target_link_libraries(CPMExampleASIOStandalone asio)
target_compile_features(CPMExampleASIOStandalone PRIVATE cxx_std_11)

View File

@@ -15,17 +15,17 @@ CPMAddPackage(
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.5.0
VERSION 1.5.2
OPTIONS "BENCHMARK_ENABLE_TESTING Off"
)
if(benchmark_ADDED)
# patch google benchmark target
set_target_properties(benchmark PROPERTIES CXX_STANDARD 17)
# Don't use C++14 because it doesn't work in some configurations.
set_target_properties(benchmark PROPERTIES CXX_STANDARD 11)
endif()
# ---- Executable ----
add_executable(CPMExampleBenchmark "main.cpp")
set_target_properties(CPMExampleBenchmark PROPERTIES CXX_STANDARD 17)
target_link_libraries(CPMExampleBenchmark fibonacci benchmark)
target_compile_features(CPMExampleBenchmark PRIVATE cxx_std_17)

View File

@@ -5,7 +5,7 @@ project(CPMExampleBoost)
# ---- Create binary ----
add_executable(CPMExampleBoost main.cpp)
set_target_properties(CPMExampleBoost PROPERTIES CXX_STANDARD 17)
target_compile_features(CPMExampleBoost PRIVATE cxx_std_17)
# ---- Dependencies ----
@@ -18,4 +18,6 @@ CPMFindPackage(
FIND_PACKAGE_ARGUMENTS "COMPONENTS system"
)
target_link_libraries(CPMExampleBoost PRIVATE Boost::system pthread)
find_package(Threads REQUIRED)
target_link_libraries(CPMExampleBoost PRIVATE Boost::system Threads::Threads)

View File

@@ -1,5 +1,7 @@
#!/usr/bin/python3
import os
from pathlib import Path
from subprocess import PIPE, run
@@ -9,14 +11,16 @@ examples = [
assert(len(examples) > 0)
def runCommand(command):
print('- %s' % command)
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True)
if result.returncode != 0:
print("error while running '%s':\n" % command, ' ' + str(result.stderr).replace('\n','\n '))
print("error while running '%s':\n" % command, ' ' + str(result.stderr).replace('\n', '\n '))
exit(result.returncode)
return result.stdout
print('')
for example in examples:
print("running example %s" % example.name)
@@ -24,6 +28,6 @@ for example in examples:
project = Path(".") / 'build' / example.name
configure = runCommand('cmake -H%s -B%s' % (example, project))
print(' ' + '\n '.join([line for line in configure.split('\n') if 'CPM:' in line]))
build = runCommand('cmake --build %s -j4' % (project))
build = runCommand('cmake --build %s -- -j%i' % (project, os.cpu_count() / 2))
print(' ' + '\n '.join([line for line in build.split('\n') if 'Built target' in line]))
print('')

View File

@@ -15,14 +15,14 @@ CPMAddPackage(
CPMAddPackage(
NAME Catch2
GITHUB_REPOSITORY catchorg/Catch2
VERSION 2.5.0
VERSION 2.13.4
)
# ---- Create binary ----
add_executable(CPMExampleCatch2 main.cpp)
target_link_libraries(CPMExampleCatch2 fibonacci Catch2)
set_target_properties(CPMExampleCatch2 PROPERTIES CXX_STANDARD 17)
target_compile_features(CPMExampleCatch2 PRIVATE cxx_std_17)
# ---- Enable testing ----

View File

@@ -8,7 +8,7 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME cereal
VERSION 1.2.2
VERSION 1.3.0
GITHUB_REPOSITORY USCiLab/cereal
OPTIONS "SKIP_PORTABILITY_TEST ON" "JUST_INSTALL_CEREAL ON"
)
@@ -17,4 +17,4 @@ CPMAddPackage(
add_executable(CPMExampleCereal main.cpp)
target_link_libraries(CPMExampleCereal cereal)
set_target_properties(CPMExampleCereal PROPERTIES CXX_STANDARD 17)
target_compile_features(CPMExampleCereal PRIVATE cxx_std_17)

View File

@@ -17,4 +17,4 @@ CPMAddPackage(
add_executable(CPMExampleCXXOpts main.cpp)
target_link_libraries(CPMExampleCXXOpts cxxopts)
set_target_properties(CPMExampleCXXOpts PROPERTIES CXX_STANDARD 17)
target_compile_features(CPMExampleCXXOpts PRIVATE cxx_std_17)

View File

@@ -15,14 +15,14 @@ CPMAddPackage(
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY onqtam/doctest
GIT_TAG 2.3.2
GIT_TAG 2.4.5
)
# ---- Create binary ----
add_executable(CPMExampleDoctest main.cpp)
target_link_libraries(CPMExampleDoctest fibonacci doctest)
set_target_properties(CPMExampleDoctest PROPERTIES CXX_STANDARD 17)
target_compile_features(CPMExampleDoctest PRIVATE cxx_std_17)
# ---- Enable testing ----

View File

@@ -16,11 +16,11 @@ CPMAddPackage(
if(EnTT_ADDED)
add_library(EnTT INTERFACE)
target_include_directories(EnTT INTERFACE ${EnTT_SOURCE_DIR}/src)
target_include_directories(EnTT SYSTEM INTERFACE ${EnTT_SOURCE_DIR}/src)
endif()
# ---- Executable ----
add_executable(CPMEnTTExample "main.cpp")
set_target_properties(CPMEnTTExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMEnTTExample main.cpp)
target_compile_features(CPMEnTTExample PRIVATE cxx_std_17)
target_link_libraries(CPMEnTTExample EnTT)

View File

@@ -8,12 +8,12 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME fmt
GIT_TAG 6.1.2
GIT_TAG 7.1.3
GITHUB_REPOSITORY fmtlib/fmt
)
# ---- Executable ----
add_executable(CPMFmtExample "main.cpp")
set_target_properties(CPMFmtExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMFmtExample main.cpp)
target_compile_features(CPMFmtExample PRIVATE cxx_std_17)
target_link_libraries(CPMFmtExample fmt)

View File

@@ -15,8 +15,8 @@ CPMAddPackage(
CPMAddPackage(
NAME googletest
GITHUB_REPOSITORY google/googletest
GIT_TAG release-1.8.1
VERSION 1.8.1
GIT_TAG release-1.10.0
VERSION 1.10.0
OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
)
@@ -24,7 +24,7 @@ CPMAddPackage(
add_executable(CPMExampleGtest main.cpp)
target_link_libraries(CPMExampleGtest fibonacci gtest gtest_main gmock)
set_target_properties(CPMExampleGtest PROPERTIES CXX_STANDARD 17)
target_compile_features(CPMExampleGtest PRIVATE cxx_std_17)
# ---- Enable testing ----

View File

@@ -8,19 +8,19 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME nlohmann_json
VERSION 3.6.1
VERSION 3.9.1
# not using the repo as it takes forever to clone
URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip
URL_HASH SHA256=69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf
URL https://github.com/nlohmann/json/releases/download/v3.9.1/include.zip
URL_HASH SHA256=6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91
)
if(nlohmann_json_ADDED)
add_library(nlohmann_json INTERFACE)
target_include_directories(nlohmann_json INTERFACE ${nlohmann_json_SOURCE_DIR})
target_include_directories(nlohmann_json SYSTEM INTERFACE ${nlohmann_json_SOURCE_DIR}/include)
endif()
# ---- Executable ----
add_executable(CPMJSONExample "main.cpp")
set_target_properties(CPMJSONExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMJSONExample main.cpp)
target_compile_features(CPMJSONExample PRIVATE cxx_std_17)
target_link_libraries(CPMJSONExample nlohmann_json)

View File

@@ -14,11 +14,11 @@ CPMAddPackage(
if(linenoise_ADDED)
add_library(linenoise ${linenoise_SOURCE_DIR}/linenoise.c)
target_include_directories(linenoise PUBLIC ${linenoise_SOURCE_DIR})
target_include_directories(linenoise SYSTEM PUBLIC ${linenoise_SOURCE_DIR})
endif()
# ---- Executable ----
add_executable(CPMlinenoiseExample "main.cpp")
set_target_properties(CPMlinenoiseExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMlinenoiseExample main.cpp)
target_compile_features(CPMlinenoiseExample PRIVATE cxx_std_17)
target_link_libraries(CPMlinenoiseExample linenoise)

View File

@@ -8,19 +8,19 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME range-v3
URL https://github.com/ericniebler/range-v3/archive/0.5.0.zip
VERSION 0.5.0
URL https://github.com/ericniebler/range-v3/archive/0.11.0.zip
VERSION 0.11.0
# the range-v3 CMakeLists screws with configuration options
DOWNLOAD_ONLY True
)
if(range-v3_ADDED)
add_library(range-v3 INTERFACE IMPORTED)
target_include_directories(range-v3 INTERFACE "${range-v3_SOURCE_DIR}/include")
target_include_directories(range-v3 SYSTEM INTERFACE "${range-v3_SOURCE_DIR}/include")
endif()
# ---- Executable ----
add_executable(CPMRangev3Example "main.cpp")
set_target_properties(CPMRangev3Example PROPERTIES CXX_STANDARD 17)
add_executable(CPMRangev3Example main.cpp)
target_compile_features(CPMRangev3Example PRIVATE cxx_std_17)
target_link_libraries(CPMRangev3Example range-v3)

View File

@@ -15,11 +15,11 @@ CPMAddPackage(
if(simple_match_ADDED)
add_library(simple_match INTERFACE IMPORTED)
target_include_directories(simple_match INTERFACE "${simple_match_SOURCE_DIR}/include")
target_include_directories(simple_match SYSTEM INTERFACE "${simple_match_SOURCE_DIR}/include")
endif()
# ---- Executable ----
add_executable(CPMSimpleMatchExample "main.cpp")
set_target_properties(CPMSimpleMatchExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMSimpleMatchExample main.cpp)
target_compile_features(CPMSimpleMatchExample PRIVATE cxx_std_17)
target_link_libraries(CPMSimpleMatchExample simple_match)

View File

@@ -20,7 +20,7 @@ if(lua_ADDED)
list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c")
add_library(lua STATIC ${lua_sources})
target_include_directories(lua PUBLIC $<BUILD_INTERFACE:${lua_SOURCE_DIR}>)
target_include_directories(lua SYSTEM PUBLIC $<BUILD_INTERFACE:${lua_SOURCE_DIR}>)
endif()
CPMAddPackage(
@@ -32,12 +32,12 @@ CPMAddPackage(
if(sol2_ADDED)
add_library(sol2 INTERFACE IMPORTED)
target_include_directories(sol2 INTERFACE ${sol2_SOURCE_DIR}/include)
target_include_directories(sol2 SYSTEM INTERFACE ${sol2_SOURCE_DIR}/include)
target_link_libraries(sol2 INTERFACE lua)
endif()
# ---- Executable ----
add_executable(CPMSol2Example "main.cpp")
set_target_properties(CPMSol2Example PROPERTIES CXX_STANDARD 17)
add_executable(CPMSol2Example main.cpp)
target_compile_features(CPMSol2Example PRIVATE cxx_std_17)
target_link_libraries(CPMSol2Example sol2)

View File

@@ -9,11 +9,11 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME spdlog
GITHUB_REPOSITORY gabime/spdlog
VERSION 1.7.0
VERSION 1.8.2
)
# ---- Executable ----
add_executable(CPMSpdlogExample "main.cpp")
set_target_properties(CPMSpdlogExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMSpdlogExample main.cpp)
target_compile_features(CPMSpdlogExample PRIVATE cxx_std_17)
target_link_libraries(CPMSpdlogExample spdlog)

View File

@@ -9,15 +9,13 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
# 0.6.2 uses deprecated CMake syntax
VERSION 0.6.3
# 0.6.3 is not released yet, so use the most recent commit
GIT_TAG 012269756149ae99745b6dafefd415843d7420bb
GIT_TAG yaml-cpp-0.6.3
OPTIONS "YAML_CPP_BUILD_TESTS Off" "YAML_CPP_BUILD_CONTRIB Off" "YAML_CPP_BUILD_TOOLS Off"
)
# ---- Executable ----
add_executable(CPMYamlExample "main.cpp")
set_target_properties(CPMYamlExample PROPERTIES CXX_STANDARD 17)
add_executable(CPMYamlExample main.cpp)
target_compile_features(CPMYamlExample PRIVATE cxx_std_17)
target_link_libraries(CPMYamlExample yaml-cpp)

View File

@@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
include(${CPM_PATH}/CPM.cmake)
include(${CPM_PATH}/testing.cmake)
# cmake-format: off
cpm_prettify_package_arguments(PRETTY_ARGN false
NAME Dependency
SOURCE_DIR ${CMAKE_SOURCE_DIR}/local_dependency/dependency
UPDATE_DISCONNECTED ON
TESTCUSTOMDATA TRUE
)
# cmake-format: on
set(EXPECTED_UNCOMMENTED
" NAME Dependency
SOURCE_DIR \${CMAKE_SOURCE_DIR}/local_dependency/dependency
UPDATE_DISCONNECTED ON TESTCUSTOMDATA TRUE
"
)
assert_equal(${PRETTY_ARGN} ${EXPECTED_UNCOMMENTED})
# cmake-format: off
cpm_prettify_package_arguments(PRETTY_ARGN true
NAME Dependency
SOURCE_DIR ${CMAKE_SOURCE_DIR}/local_dependency/dependency
UPDATE_DISCONNECTED ON
TESTCUSTOMDATA TRUE
)
# cmake-format: on
set(EXPECTED_COMMENTED
"# NAME Dependency
# SOURCE_DIR \${CMAKE_SOURCE_DIR}/local_dependency/dependency
# UPDATE_DISCONNECTED ON TESTCUSTOMDATA TRUE
"
)
assert_equal(${PRETTY_ARGN} ${EXPECTED_COMMENTED})
cpm_prettify_package_arguments(PRETTY_ARGN true "local directory")
set(EXPECTED_COMMENTED_LOCALDIR "# local directory
"
)
assert_equal(${PRETTY_ARGN} ${EXPECTED_COMMENTED_LOCALDIR})