Skip to content

Commit

Permalink
Merge branch 'task/#21337-add-cmake-options-to-enable-or-disable-sepa…
Browse files Browse the repository at this point in the history
…rate-parts' into 'integration'

Task #21337 - Add cmake options to enable/disable separate parts

See merge request elektrobit/base-os/safu!19
  • Loading branch information
gehwolf committed Mar 13, 2024
2 parents 76f0261 + 81ca3f6 commit df5eb75
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ project_add_documentation_target(
MARKDOWN
${CMAKE_SOURCE_DIR}/documentation/documentation.md
)
if (UNIT_TESTS)
enable_testing()
endif (UNIT_TESTS)

add_subdirectory(src)
if(UNIT_TESTS)
enable_testing()
add_subdirectory(test/utest)
endif(UNIT_TESTS)
add_subdirectory(test/utest)

if(PACKAGING)
include(cmake/Packing.cmake)
Expand Down
22 changes: 19 additions & 3 deletions ci/clean.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
#!/bin/sh -eu
set -e -u

CMD_PATH="$(realpath "$(dirname "$0")")"
BASE_DIR="$(realpath "$CMD_PATH/..")"

OPTION_DEPS=1
for element in "$@"; do
case $element in
--no-deps) OPTION_DEPS=0 ;;
*) echo "error: unknown option: $1"; exit 1 ;;
esac
done

echo "remove build directories"
rm -rf \
"$BASE_DIR/build" \
"$BASE_DIR/doc/source/generated"
if [ $OPTION_DEPS -eq 1 ]; then
rm -rf "$BASE_DIR/build"
else
rm -rf \
"$BASE_DIR/build/Debug" \
"$BASE_DIR/build/Release" \
"$BASE_DIR/build/doc"
fi

rm -rf "$BASE_DIR/doc/source/generated"
6 changes: 2 additions & 4 deletions cmake/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
CMake options
=============

ENABLE_ASAN=[on|off]
--------------------
default: on
.. program-output:: cmake -LH 2>/dev/null | sed '0,/^-- Cache values$/d'
:shell:

Control if safu should be build with address sanitizer
12 changes: 9 additions & 3 deletions cmake/project.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
set(SAFU_VERSION 0.52.2)
set(SAFU_VERSION 0.52.3)

# Attention: Aside from the version, as many things as possible in this file
# should be put into functions, as this solves potential issues with commands
Expand All @@ -16,12 +16,18 @@ macro(project_set_environment)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(GNUInstallDirs)

option(UNIT_TESTS "Build unit tests" ON)
option(SAFU_BUILD_DEFAULTS "enable all default builds" ON)

option(ENABLE_ANALYZER "Build with -fanalyzer" ON)
option(ENABLE_CI "Use CI mode for building" OFF)
option(INSTALL_UNIT_TESTS "Install unit tests" ON)
option(ENABLE_ASAN "Link with ASAN" ON)

option(UNIT_TESTS "Build unit tests" ${SAFU_BUILD_DEFAULTS})
option(INSTALL_UNIT_TESTS "Install unit tests" ${UNIT_TESTS})

option(SAFU_MOCK_LIBRARY "Build the mock libraries" ${SAFU_BUILD_DEFAULTS})
option(INSTALL_SAFU_MOCK_LIBRARY "Install the mock libraries" ${SAFU_MOCK_LIBRARY})

add_compile_options(
-Wshadow -Wall -Wextra -pedantic -D_DEFAULT_SOURCE
)
Expand Down
11 changes: 7 additions & 4 deletions test/utest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SPDX-License-Identifier: MIT
include(unit_test.cmake)

add_subdirectory(mocks)
add_subdirectory(safu)
if (UNIT_TESTS)
include(unit_test.cmake)
add_subdirectory(safu)
endif (UNIT_TESTS)
if (SAFU_MOCK_LIBRARY OR UNIT_TESTS)
add_subdirectory(mocks)
endif (SAFU_MOCK_LIBRARY OR UNIT_TESTS)
20 changes: 11 additions & 9 deletions test/utest/mocks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ write_basic_package_version_file(
COMPATIBILITY SameMajorVersion
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/safu/mock_safuConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/safu/mock_safuConfigVersion.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/safu"
)
if (SAFU_MOCK_LIBRARY AND INSTALL_SAFU_MOCK_LIBRARY)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/safu/mock_safuConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/safu/mock_safuConfigVersion.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/safu"
)

install(TARGETS mock_safu EXPORT safuTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY safu/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/safu FILES_MATCHING PATTERN "*.h")
install(TARGETS mock_safu EXPORT safuTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY safu/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/safu FILES_MATCHING PATTERN "*.h")
endif (SAFU_MOCK_LIBRARY AND INSTALL_SAFU_MOCK_LIBRARY)

0 comments on commit df5eb75

Please sign in to comment.