From ea8faf70328621f1469cae1dc1cfc0b7c4e73796 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 12:08:54 -0500 Subject: [PATCH] xo-printjson: build: update for latest xo-cmake macros --- CMakeLists.txt | 20 ++---------------- utest/CMakeLists.txt | 50 +------------------------------------------- 2 files changed, 3 insertions(+), 67 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b12b9f56..1ba80032 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,25 +3,11 @@ cmake_minimum_required(VERSION 3.10) project(printjson VERSION 0.1) -enable_language(CXX) -# common XO cmake macros (see https://github.com/rconybea/xo-cmake) +include(GNUInstallDirs) include(cmake/xo-bootstrap-macros.cmake) -# ---------------------------------------------------------------- -# unit test setup - -enable_testing() -# activate code coverage for all executables + libraries (when configured with -DCODE_COVERAGE=ON) -add_code_coverage() -# 1. assuming that /nix/store/ prefixes .hpp files belonging to gcc, catch2 etc. -# we're not interested in code coverage for these sources. -# 2. exclude the utest/ subdir, we don't need coverage on the unit tests themselves; -# rather, want coverage on the code that the unit tests exercise. -# -# NOTE: this seems to work only with the 'ccov-all' target. In particular, doesn't seem to do anything with the 'ccov' target -# -add_code_coverage_all_targets(EXCLUDE /nix/store/* ${PROJECT_SOURCE_DIR}/utest/* ${PROJECT_BINARY_DIR}/local/* ${PROJECT_SOURCE_DIR}/repo/*) +xo_cxx_toplevel_options3() # ---------------------------------------------------------------- # c++ settings @@ -31,8 +17,6 @@ set(PROJECT_CXX_FLAGS "") #set(PROJECT_CXX_FLAGS "-fconcepts-diagnostics-depth=2") add_definitions(${PROJECT_CXX_FLAGS}) -xo_toplevel_compile_options() - # ---------------------------------------------------------------- add_subdirectory(src/printjson) diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 0b2177e8..8b4e7828 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -3,56 +3,8 @@ set(SELF_EXE utest.printjson) set(SELF_SRCS printjson_utest_main.cpp PrintJson.test.cpp) -add_executable(${SELF_EXE} ${SELF_SRCS}) -xo_include_options2(${SELF_EXE}) - -add_test(NAME ${SELF_EXE} COMMAND ${SELF_EXE}) -target_code_coverage(${SELF_EXE} AUTO ALL) - -# ---------------------------------------------------------------- -# generic project dependency - -## PROJECT_SOURCE_DIR: -## so we can for example write -## #include "indentlog/scope.hpp" -## from anywhere in the project -## PROJECT_BINARY_DIR: -## since version file will be in build directory, need that directory -## to also be included in compiler's include path -## -#target_include_directories(${SELF_EXE} PUBLIC -# ${PROJECT_SOURCE_DIR} -# ${PROJECT_BINARY_DIR}) - -# ---------------------------------------------------------------- -# dependencies on this codebase - +xo_add_utest_executable(${SELF_EXE} ${SELF_SRCS}) xo_self_dependency(${SELF_EXE} printjson) - -# ---------------------------------------------------------------- -# dependencies on other codebases - xo_external_target_dependency(${SELF_EXE} Catch2 Catch2::Catch2) -# need this so that catch2/include appears in compile_commands.json, -# on which lsp integration relies. -# -# See also /nix/store/*-catch2-*/lib/cmake/Catch2/ParseAndAddCatchTests.cmake; -# commands here derived from ^ .cmake file -# -#find_path(CATCH_INCLUDE_DIR "catch2/catch.hpp") -#target_include_directories(${SELF_EXE} PUBLIC ${CATCH_INCLUDE_DIR}) - -# supplied from xo_include_options2() -## ---------------------------------------------------------------- -## 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() - # end CMakeLists.txt