Skip to content

Add code example to doxygen and validate in CI #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add CMakeLists.txt file update missed in previous commit
  • Loading branch information
aggarw13 committed Jul 23, 2021
commit 0b48d4ba482d32e02b79bb7c1e83772aacee28df
72 changes: 42 additions & 30 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ set( UNIT_TEST_DIR ${MODULE_ROOT_DIR}/test/unit-test CACHE INTERNAL "backoffAlgo
set( UNITY_DIR ${UNIT_TEST_DIR}/Unity CACHE INTERNAL "Unity library source directory." )

# Configure options to always show in CMake GUI.
option( BUILD_CLONE_SUBMODULES
"Set this to ON to automatically clone any required Git submodules. When OFF, submodules must be manually cloned."
option( BUILD_UNIT_TESTS
"Set this to ON to build unit tests. This will clone the required Unity test framework submodule if it is not cloned already."
OFF )

# Set output directories.
Expand All @@ -47,41 +47,53 @@ target_include_directories( coverity_analysis

# ==================================== Unit Test Configuration ====================================

# Include Unity build configuration.
include( unit-test/unity_build.cmake )
if(${BUILD_CODE_EXAMPLE})

# Check if the Unity source directory exists, and if not present, clone the submodule
# if BUILD_CLONE_SUBMODULES configuration is enabled.
if( NOT EXISTS ${UNITY_DIR}/src )
# Attempt to clone Unity.
if( ${BUILD_CLONE_SUBMODULES} )
# Target for code example binary.
add_executable( code_example_posix
${MODULE_ROOT_DIR}/docs/doxygen/code_examples/backoff_algorithm_posix.c )

target_link_libraries( code_example_posix coverity_analysis )

endif()

# ==================================== Unit Test Configuration ====================================

if(${BUILD_UNIT_TESTS})

# Include Unity build configuration.
include( unit-test/unity_build.cmake )

# Check if the Unity source directory exists, and if not present, clone the submodule
# if BUILD_CLONE_SUBMODULES configuration is enabled.
if( NOT EXISTS ${UNITY_DIR}/src )
# Attempt to clone Unity.
clone_unity()
else()
message( FATAL_ERROR "The required submodule Unity does not exist. Either clone it manually, or set BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." )
endif()
endif()

# Add unit test and coverage configuration.
# Add unit test and coverage configuration.

# Use CTest utility for managing test runs. This has to be added BEFORE
# defining test targets with add_test()
enable_testing()

# Use CTest utility for managing test runs. This has to be added BEFORE
# defining test targets with add_test()
enable_testing()
# Add build targets for Unity and Unit, required for unit testing.
add_unity_targets()

# Add build targets for Unity and Unit, required for unit testing.
add_unity_targets()
# Add function to enable Unity based tests and coverage.
include( ${MODULE_ROOT_DIR}/tools/unity/create_test.cmake )

# Add function to enable Unity based tests and coverage.
include( ${MODULE_ROOT_DIR}/tools/unity/create_test.cmake )
# Include build configuration for unit tests.
add_subdirectory( unit-test )

# Include build configuration for unit tests.
add_subdirectory( unit-test )
# ==================================== Coverage Analysis configuration ============================

# ==================================== Coverage Analysis configuration ============================
# Add a target for running coverage on tests.
add_custom_target( coverage
COMMAND ${CMAKE_COMMAND} -DUNITY_DIR=${UNITY_DIR}
-P ${MODULE_ROOT_DIR}/tools/unity/coverage.cmake
DEPENDS unity backoff_algorithm_utest
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

# Add a target for running coverage on tests.
add_custom_target( coverage
COMMAND ${CMAKE_COMMAND} -DUNITY_DIR=${UNITY_DIR}
-P ${MODULE_ROOT_DIR}/tools/unity/coverage.cmake
DEPENDS unity backoff_algorithm_utest
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()