Skip to content

Commit

Permalink
Merge pull request #671 from andrsd/cmake-updates
Browse files Browse the repository at this point in the history
Updating cmake scripts to work with cmake 3.31+
  • Loading branch information
andrsd authored Jan 4, 2025
2 parents 7f5d732 + 801e1b4 commit c170fb8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (GODZILLA_BUILD_TESTS)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.12.0
GIT_TAG v1.15.2
)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
mark_as_advanced(FORCE
Expand Down
38 changes: 10 additions & 28 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ if(GODZILLA_CODE_COVERAGE)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${COVERAGE_INFO}")

if(CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
find_program(
LLVM_COV_PATH
NAMES
llvm-cov
)
find_program(
LLVM_PROFDATA_PATH
NAMES
llvm-profdata
)
find_program(LLVM_COV_PATH NAMES llvm-cov)
find_program(LLVM_PROFDATA_PATH NAMES llvm-profdata)
mark_as_advanced(FORCE
LLVM_COV_PATH
LLVM_PROFDATA_PATH
Expand Down Expand Up @@ -81,7 +73,10 @@ if(GODZILLA_CODE_COVERAGE)
${CODE_COVERAGE_PROFRAWS}
)

add_custom_target(htmlcov DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html)
add_custom_target(htmlcov
DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html
COMMENT "Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)
add_custom_command(
OUTPUT
${PROJECT_BINARY_DIR}/htmlcov/index.html
Expand All @@ -98,14 +93,6 @@ if(GODZILLA_CODE_COVERAGE)
${COVERAGE_INFO}
)

add_custom_command(
TARGET htmlcov
POST_BUILD
COMMAND ;
COMMENT
"Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)

function(target_code_coverage TARGET_NAME)
target_compile_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
target_link_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
Expand Down Expand Up @@ -154,7 +141,10 @@ if(GODZILLA_CODE_COVERAGE)
${EXCLUDE_REGEX}
)

add_custom_target(htmlcov DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html)
add_custom_target(htmlcov
DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html
COMMENT "Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)
add_custom_command(
OUTPUT
${PROJECT_BINARY_DIR}/htmlcov/index.html
Expand All @@ -166,14 +156,6 @@ if(GODZILLA_CODE_COVERAGE)
${COVERAGE_INFO}
)

add_custom_command(
TARGET htmlcov
POST_BUILD
COMMAND ;
COMMENT
"Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)

function(target_code_coverage TARGET_NAME)
target_compile_options(${TARGET_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
target_link_options(${TARGET_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
Expand Down
18 changes: 9 additions & 9 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
find_package(Doxygen QUIET)
find_program(SPHINX_BUILD sphinx-build)

if(DOXYGEN_FOUND AND NOT ${SPHINX_BUILD} STREQUAL SPHINX_BUILD-NOTFOUND)
if (DOXYGEN_FOUND AND NOT ${SPHINX_BUILD} STREQUAL SPHINX_BUILD-NOTFOUND)
find_program(SPHINX_BUILD sphinx-build)
mark_as_advanced(FORCE SPHINX_BUILD)

configure_file(Doxyfile.in Doxyfile)
configure_file(conf.py.in conf.py)

add_custom_target(doc DEPENDS ${PROJECT_BINARY_DIR}/html/index.html)
add_custom_target(doc
DEPENDS ${PROJECT_BINARY_DIR}/html/index.html
COMMENT "Open ${PROJECT_BINARY_DIR}/docs/html/index.html in your browser to view the documentation."
)

file(GLOB_RECURSE RST_FILES ${PROJECT_SOURCE_DIR}/docs/*.rst)
file(GLOB_RECURSE HEADER_FILES ${PROJECT_SOURCE_DIR}/include/*.h)
Expand All @@ -35,30 +38,27 @@ if(DOXYGEN_FOUND AND NOT ${SPHINX_BUILD} STREQUAL SPHINX_BUILD-NOTFOUND)
${PROJECT_BINARY_DIR}/docs/Doxyfile
${HEADER_FILES}
)

add_custom_command(
TARGET doc
POST_BUILD
COMMAND echo "Open ${PROJECT_BINARY_DIR}/docs/html/index.html in your browser to view the documentation."
)

else()
add_custom_target(doc)

add_custom_command(
TARGET doc
POST_BUILD
COMMAND echo "Unable to generate documentation:"
)

if (NOT DOXYGEN_FOUND)
add_custom_command(
TARGET doc
POST_BUILD
COMMAND echo "- 'doxygen' is not installed."
)
endif()

if (${SPHINX_BUILD} STREQUAL SPHINX_BUILD-NOTFOUND)
add_custom_command(
TARGET doc
POST_BUILD
COMMAND echo "- 'sphinx-build' is not installed."
)
endif()
Expand Down

0 comments on commit c170fb8

Please sign in to comment.