Skip to content

Commit

Permalink
xo-ratio: streamline example+utest build
Browse files Browse the repository at this point in the history
  • Loading branch information
Rconybea committed May 30, 2024
1 parent 63b4255 commit ae69a41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# emacs project control file
.projectile
# clangd working space (see emacs+lsp)
.cache
# typical cmake build directory (source-tree-nephew)
Expand Down
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ enable_language(CXX)
include(GNUInstallDirs)
include(cmake/xo-bootstrap-macros.cmake)

xo_cxx_toplevel_options2()

# ----------------------------------------------------------------
# cmake -DCMAKE_BUILD_TYPE=coverage
#
xo_toplevel_coverage_config2()
xo_cxx_toplevel_options3()

# ----------------------------------------------------------------
# c++ settings
Expand Down
13 changes: 5 additions & 8 deletions example/ex1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
set(SELF_EXE xo_ratio_ex1)
set(SELF_SRCS ex1.cpp)

add_executable(${SELF_EXE} ${SELF_SRCS})
xo_include_options2(${SELF_EXE})

# ----------------------------------------------------------------
# dependencies..

xo_self_dependency(${SELF_EXE} xo_ratio)
#xo_dependency(${SELF_EXE} reflect)
if (XO_ENABLE_EXAMPLES)
add_executable(${SELF_EXE} ${SELF_SRCS})
xo_include_options2(${SELF_EXE})
xo_self_dependency(${SELF_EXE} xo_ratio)
endif()

# end CMakeLists.txt
53 changes: 9 additions & 44 deletions utest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,18 @@ set(SELF_SRCS
ratio_utest_main.cpp
ratio.test.cpp)

xo_add_utest_executable(${SELF_EXE} ${SELF_SRCS})
if (ENABLE_TESTING)
xo_add_utest_executable(${SELF_EXE} ${SELF_SRCS})

# ----------------------------------------------------------------
# in coverage build, target to build+install coverage report
xo_utest_coverage_config2()

if (XO_SUBMODULE_BUILD)
# in submodule build, generate aggregate coverage report
# for all xo libraries
else()
set(CCOV_OUTPUT_DIR ${PROJECT_BINARY_DIR}/ccov/html)
set(CCOV_INDEX_FILE ${CCOV_OUTPUT_DIR}/index.html)
set(CCOV_REPORT_EXE ${PROJECT_BINARY_DIR}/gen-ccov)
# CMAKE_INSTALL_DOCDIR
# =default=> DATAROOTDIR/doc/PROJECT_NAME
# =default=> CMAKE_INSTALL_PREFIX/share/doc/xo_flatstring
set(CCOV_INSTALL_DOCDIR ${CMAKE_INSTALL_DOCDIR}/ccov)
# ----------------------------------------------------------------
# dependencies..

# 'test' target should always be out-of-date
#
# DEPENDS: reminder - can't put 'test' here, requires 'all' target
#
add_custom_command(
OUTPUT ${CCOV_INDEX_FILE}
DEPENDS ${SELF_EXE}
COMMAND ${CCOV_REPORT_EXE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating coverage report -> [${CCOV_OUTPUT_DIR}]")

add_custom_target(
ccov
DEPENDS ${CCOV_INDEX_FILE} ${SELF_EXE})

# OPTIONAL: quietly skip this step if ccov report not generated
install(
DIRECTORY ${CCOV_OUTPUT_DIR}
FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
DESTINATION ${CCOV_INSTALL_DOCDIR}
COMPONENT Documentation
OPTIONAL)
xo_self_headeronly_dependency(${SELF_EXE} xo_ratio)
xo_dependency(${SELF_EXE} randomgen)
xo_dependency(${SELF_EXE} indentlog)
xo_external_target_dependency(${SELF_EXE} Catch2 Catch2::Catch2)
endif()

# ----------------------------------------------------------------
# dependencies..

xo_self_headeronly_dependency(${SELF_EXE} xo_ratio)
xo_dependency(${SELF_EXE} randomgen)
xo_dependency(${SELF_EXE} indentlog)
xo_external_target_dependency(${SELF_EXE} Catch2 Catch2::Catch2)

# end CMakeLists.txt

0 comments on commit ae69a41

Please sign in to comment.