From d349796363163419026d7ced0f46f3702ba4a2df Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 26 Sep 2023 17:11:57 -0400 Subject: [PATCH] initial commit --- .gitignore | 1 + CMakeLists.txt | 17 +++++++++++++++++ README.md | 21 +++++++++++++++++++++ cmake/xo_cxx.cmake | 23 +++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 cmake/xo_cxx.cmake diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..378eac25 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..b1480c47 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) + +project(xo_macros VERSION 1.0) + +# if any are useful for this project.. +#include (cmake/foo.cmake) + +# ---------------------------------------------------------------- +# cmake export + +set(XO_PROJECT_NAME xo_macros) + +install( + FILES + "cmake/xo_cxx.cmake" + DESTINATION share/cmake/${XO_PROJECT_NAME} +) diff --git a/README.md b/README.md new file mode 100644 index 00000000..a06e0291 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# XO cmake modules + +Collects cmake macros to be shared across XO projects (e.g. indentlog, reflect, kalman, ..) + +## Features + +- support for both manyrepo and monorepo projects +- support for generating cmake `xxxConfig.cmake` files, so cmake `find_package()` works reliably + +## Example + +In some XO project `foo`: +``` +$ cd build +$ cmake -DCMAKE_MODULE_PATH=/usr/local/share/cmake .. +``` + +then in `foo/CMakeLists.txt`: +``` +include(xo_macros/xo_cxx) +``` diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake new file mode 100644 index 00000000..6daf88f9 --- /dev/null +++ b/cmake/xo_cxx.cmake @@ -0,0 +1,23 @@ +set(XO_STANDARD_COMPILE_OPTIONS -Werror -Wall -Wextra) +set(XO_COMPILE_OPTIONS ${XO_STANDARD_COMPILE_OPTIONS}) + +macro(xo_copmile_options target) + target_copmile_options(${target} PRIVATE ${XO_COMPILE_OPTIONS}) +endmacro() + +# dependency on an xo library (including header-only libraries) +# e.g. indentlog +# +# An xo package foo works with cmake +# find_package(foo) +# by providing plugin .cmake files in +# ${PREFIX}/lib/cmake/foo/fooConfig.cmake +# ${PREFIX}/lib/cmake/foo/fooConfigVersion.cmake +# ${PREFIX}/lib/cmake/foo/fooTargets.cmake +# +# dep: name of required dependency, e.g. indentlog +# +macro(xo_internal_dependency target dep) + find_pacakge(${dep} CONFIG REQUIRED) + target_link_libraries(${target} PUBLIC ${dep}) +endmacro()