This commit is contained in:
Roland Conybeare 2023-10-03 17:02:35 -04:00
commit 1df07c4bb1
7 changed files with 13 additions and 61 deletions

View file

@ -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)
@ -19,25 +18,7 @@ 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 "")
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()
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)
@ -46,10 +27,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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
xo_include_headeronly_options2(indentlog)
#target_include_directories(indentlog INTERFACE
# $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
# $<INSTALL_INTERFACE:include>
# )
# ----------------------------------------------------------------
# provide find_package() support
@ -60,36 +42,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

View file

@ -1,2 +1,2 @@
add_executable(ex1 ex1.cpp)
xo_include_options(ex1)
xo_include_options2(ex1)

View file

@ -1,2 +1,2 @@
add_executable(ex2 ex2.cpp)
xo_include_options(ex2)
xo_include_options2(ex2)

View file

@ -1,2 +1,2 @@
add_executable(ex3 ex3.cpp)
xo_include_options(ex3)
xo_include_options2(ex3)

View file

@ -1,2 +1,2 @@
add_executable(ex4 ex4.cpp)
xo_include_options(ex4)
xo_include_options2(ex4)

View file

@ -1,2 +1,2 @@
add_executable(hello hello.cpp)
xo_include_options(hello)
xo_include_options2(hello)

View file

@ -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)