From 49567a59a150370b219793d1d588fd99e5ca9a1c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 17:30:13 -0400 Subject: [PATCH 1/4] indentlog: build: streamline using xo-cmake macros --- CMakeLists.txt | 42 ++++++------------------------------ example/ex1/CMakeLists.txt | 2 +- example/ex2/CMakeLists.txt | 2 +- example/ex3/CMakeLists.txt | 2 +- example/ex4/CMakeLists.txt | 2 +- example/hello/CMakeLists.txt | 2 +- utest/CMakeLists.txt | 2 +- 7 files changed, 12 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86f6de3a..c8c5c655 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,7 @@ enable_language(CXX) # common XO cmake macros (see proj/xo-cmake) include(xo_macros/xo_cxx) -include(cmake/nestlog.cmake) -include(cmake/code-coverage.cmake) +include(xo_macros/code-coverage) enable_testing() # activate code coverage for all executables + libraries (when -DCODE_COVERAGE=ON) @@ -46,10 +45,11 @@ add_subdirectory(utest) # see [[https://stackoverflow.com/questions/47718485/install-and-export-interface-only-library-cmake]] # add_library(indentlog INTERFACE) -target_include_directories(indentlog INTERFACE - $ - $ - ) +xo_include_headeronly_options2(indentlog) +#target_include_directories(indentlog INTERFACE +# $ +# $ +# ) # ---------------------------------------------------------------- # provide find_package() support @@ -60,36 +60,6 @@ xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets xo_install_library2(${PROJECT_NAME}) -#include(CMakePackageConfigHelpers) -#write_basic_package_version_file("${PROJECT_BINARY_DIR}/indentlogConfigVersion.cmake" -# VERSION 0.1 -# COMPATIBILITY AnyNewerVersion -#) -# -#install( -# TARGETS indentlog -# EXPORT indentlogTargets -# LIBRARY DESTINATION lib COMPONENT Runtime -# ARCHIVE DESTINATION lib COMPONENT Development -# RUNTIME DESTINATION bin COMPONENT Runtime -# PUBLIC_HEADER DESTINATION include COMPONENT Development -# BUNDLE DESTINATION bin COMPONENT Runtime -# ) - -#include(CMakePackageConfigHelpers) -#configure_package_config_file( -# "${PROJECT_SOURCE_DIR}/cmake/indentlogConfig.cmake.in" -# "${PROJECT_BINARY_DIR}/indentlogConfig.cmake" -# INSTALL_DESTINATION lib/cmake/indentlog -# ) -# -#install(EXPORT indentlogTargets DESTINATION lib/cmake/indentlog) -#install( -# FILES -# "${PROJECT_BINARY_DIR}/indentlogConfigVersion.cmake" -# "${PROJECT_BINARY_DIR}/indentlogConfig.cmake" -# DESTINATION lib/cmake/indentlog) - # ---------------------------------------------------------------- # install .hpp diff --git a/example/ex1/CMakeLists.txt b/example/ex1/CMakeLists.txt index 6af29d79..a9d1b27d 100644 --- a/example/ex1/CMakeLists.txt +++ b/example/ex1/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(ex1 ex1.cpp) -xo_include_options(ex1) +xo_include_options2(ex1) diff --git a/example/ex2/CMakeLists.txt b/example/ex2/CMakeLists.txt index 1ac5735a..20026b03 100644 --- a/example/ex2/CMakeLists.txt +++ b/example/ex2/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(ex2 ex2.cpp) -xo_include_options(ex2) +xo_include_options2(ex2) diff --git a/example/ex3/CMakeLists.txt b/example/ex3/CMakeLists.txt index d81e0e99..9791a931 100644 --- a/example/ex3/CMakeLists.txt +++ b/example/ex3/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(ex3 ex3.cpp) -xo_include_options(ex3) +xo_include_options2(ex3) diff --git a/example/ex4/CMakeLists.txt b/example/ex4/CMakeLists.txt index 02c1f301..2a6b9c31 100644 --- a/example/ex4/CMakeLists.txt +++ b/example/ex4/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(ex4 ex4.cpp) -xo_include_options(ex4) +xo_include_options2(ex4) diff --git a/example/hello/CMakeLists.txt b/example/hello/CMakeLists.txt index d6f694e6..1ff23000 100644 --- a/example/hello/CMakeLists.txt +++ b/example/hello/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(hello hello.cpp) -xo_include_options(hello) +xo_include_options2(hello) diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index c6e6e596..fbbeb9d7 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -7,7 +7,7 @@ set(SELF_SOURCE_FILES indentlog_utest_main.cpp) add_executable(${SELF_EXECUTABLE_NAME} ${SELF_SOURCE_FILES}) -xo_include_options(${SELF_EXECUTABLE_NAME}) +xo_include_options2(${SELF_EXECUTABLE_NAME}) add_test(NAME ${SELF_EXECUTABLE_NAME} COMMAND ${SELF_EXECUTABLE_NAME}) target_code_coverage(${SELF_EXECUTABLE_NAME} AUTO ALL) From 66d8b439416e80918c4ff5b1cdea4b8f8e32ca6a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 17:59:12 -0400 Subject: [PATCH 2/4] indentlog: build: streamline using xo-cmake macros --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8c5c655..db51a3d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,9 +34,8 @@ endif() if(NOT CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX /home/${USER}/local CACHE STRING "install directory") endif() -if(NOT CMAKE_INSTALL_RPATH) - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib CACHE STRING "runpath in installed libraries/executables") -endif() + +xo_toplevel_compile_options() add_subdirectory(example) add_subdirectory(utest) From 50b787759391477b66810471812812037b1f9c45 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 18:13:46 -0400 Subject: [PATCH 3/4] indentlog: consolidate CMAKE_CXX_STANDARD setting --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db51a3d9..423b00e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,9 +18,6 @@ add_code_coverage() # add_code_coverage_all_targets(EXCLUDE /nix/store/* utest/*) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED True) - # always write compile_commands.json set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") From afd595185b5d4b879a19eb03af3d8e971feffdcc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 18:23:21 -0400 Subject: [PATCH 4/4] indentlog: consolidate CMAKE_EXPORT_COMPILE_COMMANDS + tidy --- CMakeLists.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 423b00e4..b8553e93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,20 +18,6 @@ add_code_coverage() # add_code_coverage_all_targets(EXCLUDE /nix/store/* utest/*) -# always write compile_commands.json -set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") - -if(NOT USER) - set(USER $ENV{USER}) -endif() - -# hmm. this works if explicitly given with cmake: -# cmake -DCMAKE_INSTALL_PREFIX=/home/roland/local path/to/source -# but not as default -if(NOT CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX /home/${USER}/local CACHE STRING "install directory") -endif() - xo_toplevel_compile_options() add_subdirectory(example)