From bd3f39693349aa7e6159a5f7384dc2ae667009b1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 12:01:27 -0400 Subject: [PATCH] xo-cmake: + xo_include_options2() --- cmake/xo_cxx.cmake | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index 6daf88f9..160a1833 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -1,10 +1,49 @@ + set(XO_STANDARD_COMPILE_OPTIONS -Werror -Wall -Wextra) set(XO_COMPILE_OPTIONS ${XO_STANDARD_COMPILE_OPTIONS}) -macro(xo_copmile_options target) +# ---------------------------------------------------------------- +# use this in subdirs that compile c++ code +# +macro(xo_include_options2 target) + # ---------------------------------------------------------------- + # PROJECT_SOURCE_DIR: + # so we can for example write + # #include "ordinaltree/foo.hpp" + # from anywhere in the project + # PROJECT_BINARY_DIR: + # since generated version file will be in build directory, + # need that build directory to also appear in + # compiler's include path + # + target_include_directories( + ${target} PUBLIC + $ # e.g. for #include "indentlog/scope.hpp" + $ + $ # e.g. for #include "Refcounted.hpp" in refcnt/src + $ + $ # e.g. for generated .hpp files + ) + + # ---------------------------------------------------------------- + # make standard directories for std:: includes explicit + # so that + # (1) they appear in compile_commands.json. + # (2) clangd (run from emacs lsp-mode) can find them + # + if(CMAKE_EXPORT_COMPILE_COMMANDS) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) + endif() +endmacro() + +# ---------------------------------------------------------------- +# +macro(xo_compile_options target) target_copmile_options(${target} PRIVATE ${XO_COMPILE_OPTIONS}) endmacro() +# ---------------------------------------------------------------- +# # dependency on an xo library (including header-only libraries) # e.g. indentlog # @@ -18,6 +57,6 @@ endmacro() # dep: name of required dependency, e.g. indentlog # macro(xo_internal_dependency target dep) - find_pacakge(${dep} CONFIG REQUIRED) + find_package(${dep} CONFIG REQUIRED) target_link_libraries(${target} PUBLIC ${dep}) endmacro()