https://github.com/memgraph/cmake
This is a collection of CMake modules that are useful for all Memgraph projects.
https://github.com/memgraph/cmake
Last synced: 3 months ago
JSON representation
This is a collection of CMake modules that are useful for all Memgraph projects.
- Host: GitHub
- URL: https://github.com/memgraph/cmake
- Owner: memgraph
- License: apache-2.0
- Created: 2022-01-22T12:07:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T20:55:17.000Z (over 1 year ago)
- Last Synced: 2025-08-25T09:21:54.282Z (8 months ago)
- Language: CMake
- Size: 32.2 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Memgraph CMake
This is a collection of CMake modules that are useful for all Memgraph
projects.
## Hints
To list all targets run `cmake --build . --target help`.
## Possible usages
```
include(FetchContent)
include(ExternalProject)
# Boost
file(DOWNLOAD https://raw.githubusercontent.com/memgraph/cmake/main/modules/external-boost.cmake
${CMAKE_BINARY_DIR}/external-boost.cmake)
include(${CMAKE_BINARY_DIR}/external-boost.cmake)
target_link_libraries({{target}} PRIVATE boost_headers boost_thread_static)
# fmtlib
file(DOWNLOAD https://raw.githubusercontent.com/memgraph/cmake/main/modules/external-fmt.cmake
${CMAKE_BINARY_DIR}/external-fmt.cmake)
include(${CMAKE_BINARY_DIR}/external-fmt.cmake)
target_link_libraries({{target}} PRIVATE fmtlib_static)
# mgclient
file(DOWNLOAD https://raw.githubusercontent.com/memgraph/cmake/main/modules/external-mgclient.cmake
${CMAKE_BINARY_DIR}/external-mgclient.cmake)
include(${CMAKE_BINARY_DIR}/external-mgclient.cmake)
target_link_libraries({{target}} PRIVATE mgclient_shared)
# Google Benchmark
file(DOWNLOAD https://raw.githubusercontent.com/memgraph/cmake/main/modules/fetch-gbenchmark.cmake
${CMAKE_BINARY_DIR}/fetch-gbenchmark.cmake)
include(${CMAKE_BINARY_DIR}/fetch-gbenchmark.cmake)
target_link_libraries({{target}} PRIVATE benchmark::benchmark)
# Google Test
file(DOWNLOAD https://raw.githubusercontent.com/memgraph/cmake/main/modules/fetch-gtest.cmake
${CMAKE_BINARY_DIR}/fetch-gtest.cmake)
include(${CMAKE_BINARY_DIR}/fetch-gtest.cmake)
target_link_libraries({{target}} PRIVATE gtest gtest_main)
# NLohmann JSON
file(DOWNLOAD https://raw.githubusercontent.com/memgraph/cmake/main/modules/fetch-nlohmann.cmake
${CMAKE_BINARY_DIR}/fetch-nlohmann.cmake)
include(${CMAKE_BINARY_DIR}/fetch-nlohmann.cmake)
target_link_libraries({{target}} PRIVATE nlohmann_json::nlohmann_json)
```
## References
* [CMake Guidelines](https://docs.salome-platform.org/latest/dev/cmake/html/various.html)
* [FetchContent vs ExternalProject](https://www.scivision.dev/cmake-fetchcontent-vs-external-project)
* https://www.jwlawson.co.uk/interest/2020/02/23/cmake-external-project.html
* https://coderefinery.github.io/cmake-workshop/fetch-content/
* NOTE: It's not easy to combine ExternalProject and find_package because find_package is configure-time, ExternalProject is build-time
* NOTE: CMAKE_ARGS does NOT work under FetchContent.