mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-26 06:07:26 -05:00
Compare commits
6 Commits
v0.28.2
...
v0.29.0-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ce0b9926b | ||
|
|
c309839859 | ||
|
|
b80286ef81 | ||
|
|
02d57a1601 | ||
|
|
5f614e5eb6 | ||
|
|
1f5cb903e5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
build/
|
||||||
/build*
|
/build*
|
||||||
/.vscode
|
/.vscode
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
28
README.md
28
README.md
@@ -1,7 +1,7 @@
|
|||||||
[](https://travis-ci.com/TheLartians/CPM.cmake)
|
[](https://travis-ci.com/cpm-cmake/CPM.cmake)
|
||||||
[](https://github.com/TheLartians/CPM.cmake/actions)
|
[](https://github.com/cpm-cmake/CPM.cmake/actions)
|
||||||
[](https://github.com/TheLartians/CPM.cmake/actions)
|
[](https://github.com/cpm-cmake/CPM.cmake/actions)
|
||||||
[](https://github.com/TheLartians/CPM.cmake/actions) [](https://gitter.im/TheLartians/CPM.cmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://github.com/cpm-cmake/CPM.cmake/actions)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<p align="center">
|
<p align="center">
|
||||||
@@ -80,19 +80,19 @@ CPMAddPackage(
|
|||||||
target_link_libraries(tests Catch2)
|
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
|
## 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.
|
The command below will perform this automatically.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p cmake
|
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
|
## Updating CPM
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ Dependencies using CPM will automatically use the updated script of the outermos
|
|||||||
## Limitations
|
## 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.
|
- **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).
|
- **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).
|
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.
|
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.
|
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
|
## 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.
|
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
|
### CPM_DOWNLOAD_ALL
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ cmake -Bbuild
|
|||||||
cmake --build build --target cpm-update-package-lock
|
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
|
## Built with CPM.cmake
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ If you know others, feel free to add them here through a PR.
|
|||||||
## Snippets
|
## Snippets
|
||||||
|
|
||||||
These examples demonstrate how to include some well-known projects with CPM.
|
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)
|
### [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
|
### 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.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# CPM.cmake - CMake's missing package manager
|
# 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
|
# MIT License
|
||||||
# -----------
|
# -----------
|
||||||
@@ -38,9 +38,12 @@ if(CPM_DIRECTORY)
|
|||||||
"${CPM_INDENT} \
|
"${CPM_INDENT} \
|
||||||
A dependency is using a more recent CPM version (${CURRENT_CPM_VERSION}) than the current project (${CPM_VERSION}). \
|
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. \
|
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()
|
endif()
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||||
|
include(FetchContent)
|
||||||
|
endif()
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -133,7 +136,10 @@ include(CMakeParseArguments)
|
|||||||
|
|
||||||
# Initialize logging prefix
|
# Initialize logging prefix
|
||||||
if(NOT CPM_INDENT)
|
if(NOT CPM_INDENT)
|
||||||
set(CPM_INDENT "CPM:")
|
set(CPM_INDENT
|
||||||
|
"CPM:"
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(cpm_find_package NAME VERSION)
|
function(cpm_find_package NAME VERSION)
|
||||||
@@ -237,6 +243,8 @@ endfunction()
|
|||||||
# Download and add a package from source
|
# Download and add a package from source
|
||||||
function(CPMAddPackage)
|
function(CPMAddPackage)
|
||||||
|
|
||||||
|
set(flagArgs EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set(oneValueArgs
|
set(oneValueArgs
|
||||||
NAME
|
NAME
|
||||||
FORCE
|
FORCE
|
||||||
@@ -255,7 +263,7 @@ function(CPMAddPackage)
|
|||||||
|
|
||||||
set(multiValueArgs OPTIONS)
|
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
|
# Set default values for arguments
|
||||||
|
|
||||||
@@ -381,7 +389,9 @@ function(CPMAddPackage)
|
|||||||
set(${CPM_ARGS_NAME}_ADDED YES)
|
set(${CPM_ARGS_NAME}_ADDED YES)
|
||||||
set(${CPM_ARGS_NAME}_SOURCE_DIR ${download_directory})
|
set(${CPM_ARGS_NAME}_SOURCE_DIR ${download_directory})
|
||||||
if(NOT CPM_ARGS_DOWNLOAD_ONLY AND EXISTS ${download_directory}/CMakeLists.txt)
|
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()
|
endif()
|
||||||
set(CPM_SKIP_FETCH TRUE)
|
set(CPM_SKIP_FETCH TRUE)
|
||||||
set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
|
set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
|
||||||
@@ -421,7 +431,7 @@ function(CPMAddPackage)
|
|||||||
cpm_declare_fetch(
|
cpm_declare_fetch(
|
||||||
"${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}"
|
"${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}")
|
cpm_get_fetch_properties("${CPM_ARGS_NAME}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -544,23 +554,35 @@ function(cpm_get_fetch_properties PACKAGE)
|
|||||||
)
|
)
|
||||||
endfunction()
|
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
|
# 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})
|
if(${CPM_DRY_RUN})
|
||||||
message(STATUS "${CPM_INDENT} package ${PACKAGE} not fetched (dry run)")
|
message(STATUS "${CPM_INDENT} package ${PACKAGE} not fetched (dry run)")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DOWNLOAD_ONLY)
|
FetchContent_GetProperties(${PACKAGE})
|
||||||
FetchContent_GetProperties(${PACKAGE})
|
string(TOLOWER "${PACKAGE}" lower_case_name)
|
||||||
if(NOT ${PACKAGE}_POPULATED)
|
|
||||||
FetchContent_Populate(${PACKAGE})
|
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()
|
endif()
|
||||||
else()
|
|
||||||
set(CPM_OLD_INDENT "${CPM_INDENT}")
|
|
||||||
set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:")
|
|
||||||
FetchContent_MakeAvailable(${PACKAGE})
|
|
||||||
set(CPM_INDENT "${CPM_OLD_INDENT}")
|
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ endif()
|
|||||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||||
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
|
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
|
||||||
file(DOWNLOAD
|
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}
|
${CPM_DOWNLOAD_LOCATION}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ find_package(Threads REQUIRED)
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME asio
|
NAME asio
|
||||||
VERSION 1.16.1
|
VERSION 1.18.1
|
||||||
GITHUB_REPOSITORY chriskohlhoff/asio
|
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:
|
# 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)
|
if(asio_ADDED)
|
||||||
add_library(asio INTERFACE)
|
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)
|
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED)
|
||||||
|
|
||||||
@@ -65,3 +65,4 @@ endif()
|
|||||||
|
|
||||||
add_executable(CPMExampleASIOStandalone main.cpp)
|
add_executable(CPMExampleASIOStandalone main.cpp)
|
||||||
target_link_libraries(CPMExampleASIOStandalone asio)
|
target_link_libraries(CPMExampleASIOStandalone asio)
|
||||||
|
target_compile_features(CPMExampleASIOStandalone PRIVATE cxx_std_11)
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ CPMAddPackage(
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME benchmark
|
NAME benchmark
|
||||||
GITHUB_REPOSITORY google/benchmark
|
GITHUB_REPOSITORY google/benchmark
|
||||||
VERSION 1.5.0
|
VERSION 1.5.2
|
||||||
OPTIONS "BENCHMARK_ENABLE_TESTING Off"
|
OPTIONS "BENCHMARK_ENABLE_TESTING Off"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(benchmark_ADDED)
|
if(benchmark_ADDED)
|
||||||
# patch google benchmark target
|
# Don't use C++14 because it doesn't work in some configurations.
|
||||||
set_target_properties(benchmark PROPERTIES CXX_STANDARD 17)
|
set_target_properties(benchmark PROPERTIES CXX_STANDARD 11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMExampleBenchmark "main.cpp")
|
add_executable(CPMExampleBenchmark "main.cpp")
|
||||||
set_target_properties(CPMExampleBenchmark PROPERTIES CXX_STANDARD 17)
|
|
||||||
target_link_libraries(CPMExampleBenchmark fibonacci benchmark)
|
target_link_libraries(CPMExampleBenchmark fibonacci benchmark)
|
||||||
|
target_compile_features(CPMExampleBenchmark PRIVATE cxx_std_17)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ project(CPMExampleBoost)
|
|||||||
# ---- Create binary ----
|
# ---- Create binary ----
|
||||||
|
|
||||||
add_executable(CPMExampleBoost main.cpp)
|
add_executable(CPMExampleBoost main.cpp)
|
||||||
set_target_properties(CPMExampleBoost PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMExampleBoost PRIVATE cxx_std_17)
|
||||||
|
|
||||||
# ---- Dependencies ----
|
# ---- Dependencies ----
|
||||||
|
|
||||||
@@ -18,4 +18,6 @@ CPMFindPackage(
|
|||||||
FIND_PACKAGE_ARGUMENTS "COMPONENTS system"
|
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)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import PIPE, run
|
from subprocess import PIPE, run
|
||||||
|
|
||||||
@@ -9,14 +11,16 @@ examples = [
|
|||||||
|
|
||||||
assert(len(examples) > 0)
|
assert(len(examples) > 0)
|
||||||
|
|
||||||
|
|
||||||
def runCommand(command):
|
def runCommand(command):
|
||||||
print('- %s' % command)
|
print('- %s' % command)
|
||||||
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True)
|
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True)
|
||||||
if result.returncode != 0:
|
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)
|
exit(result.returncode)
|
||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
|
|
||||||
print('')
|
print('')
|
||||||
for example in examples:
|
for example in examples:
|
||||||
print("running example %s" % example.name)
|
print("running example %s" % example.name)
|
||||||
@@ -24,6 +28,6 @@ for example in examples:
|
|||||||
project = Path(".") / 'build' / example.name
|
project = Path(".") / 'build' / example.name
|
||||||
configure = runCommand('cmake -H%s -B%s' % (example, project))
|
configure = runCommand('cmake -H%s -B%s' % (example, project))
|
||||||
print(' ' + '\n '.join([line for line in configure.split('\n') if 'CPM:' in line]))
|
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(' ' + '\n '.join([line for line in build.split('\n') if 'Built target' in line]))
|
||||||
print('')
|
print('')
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ CPMAddPackage(
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME Catch2
|
NAME Catch2
|
||||||
GITHUB_REPOSITORY catchorg/Catch2
|
GITHUB_REPOSITORY catchorg/Catch2
|
||||||
VERSION 2.5.0
|
VERSION 2.13.4
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Create binary ----
|
# ---- Create binary ----
|
||||||
|
|
||||||
add_executable(CPMExampleCatch2 main.cpp)
|
add_executable(CPMExampleCatch2 main.cpp)
|
||||||
target_link_libraries(CPMExampleCatch2 fibonacci Catch2)
|
target_link_libraries(CPMExampleCatch2 fibonacci Catch2)
|
||||||
set_target_properties(CPMExampleCatch2 PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMExampleCatch2 PRIVATE cxx_std_17)
|
||||||
|
|
||||||
# ---- Enable testing ----
|
# ---- Enable testing ----
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ include(../../cmake/CPM.cmake)
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME cereal
|
NAME cereal
|
||||||
VERSION 1.2.2
|
VERSION 1.3.0
|
||||||
GITHUB_REPOSITORY USCiLab/cereal
|
GITHUB_REPOSITORY USCiLab/cereal
|
||||||
OPTIONS "SKIP_PORTABILITY_TEST ON" "JUST_INSTALL_CEREAL ON"
|
OPTIONS "SKIP_PORTABILITY_TEST ON" "JUST_INSTALL_CEREAL ON"
|
||||||
)
|
)
|
||||||
@@ -17,4 +17,4 @@ CPMAddPackage(
|
|||||||
|
|
||||||
add_executable(CPMExampleCereal main.cpp)
|
add_executable(CPMExampleCereal main.cpp)
|
||||||
target_link_libraries(CPMExampleCereal cereal)
|
target_link_libraries(CPMExampleCereal cereal)
|
||||||
set_target_properties(CPMExampleCereal PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMExampleCereal PRIVATE cxx_std_17)
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ CPMAddPackage(
|
|||||||
|
|
||||||
add_executable(CPMExampleCXXOpts main.cpp)
|
add_executable(CPMExampleCXXOpts main.cpp)
|
||||||
target_link_libraries(CPMExampleCXXOpts cxxopts)
|
target_link_libraries(CPMExampleCXXOpts cxxopts)
|
||||||
set_target_properties(CPMExampleCXXOpts PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMExampleCXXOpts PRIVATE cxx_std_17)
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ CPMAddPackage(
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME doctest
|
NAME doctest
|
||||||
GITHUB_REPOSITORY onqtam/doctest
|
GITHUB_REPOSITORY onqtam/doctest
|
||||||
GIT_TAG 2.3.2
|
GIT_TAG 2.4.5
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Create binary ----
|
# ---- Create binary ----
|
||||||
|
|
||||||
add_executable(CPMExampleDoctest main.cpp)
|
add_executable(CPMExampleDoctest main.cpp)
|
||||||
target_link_libraries(CPMExampleDoctest fibonacci doctest)
|
target_link_libraries(CPMExampleDoctest fibonacci doctest)
|
||||||
set_target_properties(CPMExampleDoctest PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMExampleDoctest PRIVATE cxx_std_17)
|
||||||
|
|
||||||
# ---- Enable testing ----
|
# ---- Enable testing ----
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ CPMAddPackage(
|
|||||||
|
|
||||||
if(EnTT_ADDED)
|
if(EnTT_ADDED)
|
||||||
add_library(EnTT INTERFACE)
|
add_library(EnTT INTERFACE)
|
||||||
target_include_directories(EnTT INTERFACE ${EnTT_SOURCE_DIR}/src)
|
target_include_directories(EnTT SYSTEM INTERFACE ${EnTT_SOURCE_DIR}/src)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMEnTTExample "main.cpp")
|
add_executable(CPMEnTTExample main.cpp)
|
||||||
set_target_properties(CPMEnTTExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMEnTTExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMEnTTExample EnTT)
|
target_link_libraries(CPMEnTTExample EnTT)
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ include(../../cmake/CPM.cmake)
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME fmt
|
NAME fmt
|
||||||
GIT_TAG 6.1.2
|
GIT_TAG 7.1.3
|
||||||
GITHUB_REPOSITORY fmtlib/fmt
|
GITHUB_REPOSITORY fmtlib/fmt
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMFmtExample "main.cpp")
|
add_executable(CPMFmtExample main.cpp)
|
||||||
set_target_properties(CPMFmtExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMFmtExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMFmtExample fmt)
|
target_link_libraries(CPMFmtExample fmt)
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ CPMAddPackage(
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME googletest
|
NAME googletest
|
||||||
GITHUB_REPOSITORY google/googletest
|
GITHUB_REPOSITORY google/googletest
|
||||||
GIT_TAG release-1.8.1
|
GIT_TAG release-1.10.0
|
||||||
VERSION 1.8.1
|
VERSION 1.10.0
|
||||||
OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
|
OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ CPMAddPackage(
|
|||||||
|
|
||||||
add_executable(CPMExampleGtest main.cpp)
|
add_executable(CPMExampleGtest main.cpp)
|
||||||
target_link_libraries(CPMExampleGtest fibonacci gtest gtest_main gmock)
|
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 ----
|
# ---- Enable testing ----
|
||||||
|
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ include(../../cmake/CPM.cmake)
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME nlohmann_json
|
NAME nlohmann_json
|
||||||
VERSION 3.6.1
|
VERSION 3.9.1
|
||||||
# not using the repo as it takes forever to clone
|
# not using the repo as it takes forever to clone
|
||||||
URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip
|
URL https://github.com/nlohmann/json/releases/download/v3.9.1/include.zip
|
||||||
URL_HASH SHA256=69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf
|
URL_HASH SHA256=6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91
|
||||||
)
|
)
|
||||||
|
|
||||||
if(nlohmann_json_ADDED)
|
if(nlohmann_json_ADDED)
|
||||||
add_library(nlohmann_json INTERFACE)
|
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()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMJSONExample "main.cpp")
|
add_executable(CPMJSONExample main.cpp)
|
||||||
set_target_properties(CPMJSONExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMJSONExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMJSONExample nlohmann_json)
|
target_link_libraries(CPMJSONExample nlohmann_json)
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ CPMAddPackage(
|
|||||||
|
|
||||||
if(linenoise_ADDED)
|
if(linenoise_ADDED)
|
||||||
add_library(linenoise ${linenoise_SOURCE_DIR}/linenoise.c)
|
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()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMlinenoiseExample "main.cpp")
|
add_executable(CPMlinenoiseExample main.cpp)
|
||||||
set_target_properties(CPMlinenoiseExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMlinenoiseExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMlinenoiseExample linenoise)
|
target_link_libraries(CPMlinenoiseExample linenoise)
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ include(../../cmake/CPM.cmake)
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME range-v3
|
NAME range-v3
|
||||||
URL https://github.com/ericniebler/range-v3/archive/0.5.0.zip
|
URL https://github.com/ericniebler/range-v3/archive/0.11.0.zip
|
||||||
VERSION 0.5.0
|
VERSION 0.11.0
|
||||||
# the range-v3 CMakeLists screws with configuration options
|
# the range-v3 CMakeLists screws with configuration options
|
||||||
DOWNLOAD_ONLY True
|
DOWNLOAD_ONLY True
|
||||||
)
|
)
|
||||||
|
|
||||||
if(range-v3_ADDED)
|
if(range-v3_ADDED)
|
||||||
add_library(range-v3 INTERFACE IMPORTED)
|
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()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMRangev3Example "main.cpp")
|
add_executable(CPMRangev3Example main.cpp)
|
||||||
set_target_properties(CPMRangev3Example PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMRangev3Example PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMRangev3Example range-v3)
|
target_link_libraries(CPMRangev3Example range-v3)
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ CPMAddPackage(
|
|||||||
|
|
||||||
if(simple_match_ADDED)
|
if(simple_match_ADDED)
|
||||||
add_library(simple_match INTERFACE IMPORTED)
|
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()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMSimpleMatchExample "main.cpp")
|
add_executable(CPMSimpleMatchExample main.cpp)
|
||||||
set_target_properties(CPMSimpleMatchExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMSimpleMatchExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMSimpleMatchExample simple_match)
|
target_link_libraries(CPMSimpleMatchExample simple_match)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if(lua_ADDED)
|
|||||||
list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c")
|
list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c")
|
||||||
add_library(lua STATIC ${lua_sources})
|
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()
|
endif()
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
@@ -32,12 +32,12 @@ CPMAddPackage(
|
|||||||
|
|
||||||
if(sol2_ADDED)
|
if(sol2_ADDED)
|
||||||
add_library(sol2 INTERFACE IMPORTED)
|
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)
|
target_link_libraries(sol2 INTERFACE lua)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMSol2Example "main.cpp")
|
add_executable(CPMSol2Example main.cpp)
|
||||||
set_target_properties(CPMSol2Example PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMSol2Example PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMSol2Example sol2)
|
target_link_libraries(CPMSol2Example sol2)
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ include(../../cmake/CPM.cmake)
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME spdlog
|
NAME spdlog
|
||||||
GITHUB_REPOSITORY gabime/spdlog
|
GITHUB_REPOSITORY gabime/spdlog
|
||||||
VERSION 1.7.0
|
VERSION 1.8.2
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMSpdlogExample "main.cpp")
|
add_executable(CPMSpdlogExample main.cpp)
|
||||||
set_target_properties(CPMSpdlogExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMSpdlogExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMSpdlogExample spdlog)
|
target_link_libraries(CPMSpdlogExample spdlog)
|
||||||
|
|||||||
@@ -9,15 +9,13 @@ include(../../cmake/CPM.cmake)
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME yaml-cpp
|
NAME yaml-cpp
|
||||||
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
|
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
|
||||||
# 0.6.2 uses deprecated CMake syntax
|
|
||||||
VERSION 0.6.3
|
VERSION 0.6.3
|
||||||
# 0.6.3 is not released yet, so use the most recent commit
|
GIT_TAG yaml-cpp-0.6.3
|
||||||
GIT_TAG 012269756149ae99745b6dafefd415843d7420bb
|
|
||||||
OPTIONS "YAML_CPP_BUILD_TESTS Off" "YAML_CPP_BUILD_CONTRIB Off" "YAML_CPP_BUILD_TOOLS Off"
|
OPTIONS "YAML_CPP_BUILD_TESTS Off" "YAML_CPP_BUILD_CONTRIB Off" "YAML_CPP_BUILD_TOOLS Off"
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Executable ----
|
# ---- Executable ----
|
||||||
|
|
||||||
add_executable(CPMYamlExample "main.cpp")
|
add_executable(CPMYamlExample main.cpp)
|
||||||
set_target_properties(CPMYamlExample PROPERTIES CXX_STANDARD 17)
|
target_compile_features(CPMYamlExample PRIVATE cxx_std_17)
|
||||||
target_link_libraries(CPMYamlExample yaml-cpp)
|
target_link_libraries(CPMYamlExample yaml-cpp)
|
||||||
|
|||||||
Reference in New Issue
Block a user