Skip to content

Commit

Permalink
Add to main CMake lists + Windows workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kboyarinov committed Feb 6, 2025
1 parent 39af2e8 commit b9f1e5e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
28 changes: 13 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ jobs:
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DTBB_CPF=${{ matrix.preview }} -DTBB_TEST=OFF -DTBB_EXAMPLES=ON ..
cmake --build . -v --target light_test_examples
linux-doc-examples-testing:
doc-examples-testing:
name: doc_examples_${{ matrix.os }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}
runs-on: ['${{ matrix.os }}']
timeout-minutes: 10
Expand All @@ -376,26 +376,24 @@ jobs:
matrix:
include:
- os: ubuntu-latest
generator: "Unix Makefiles"
c_compiler: gcc
cxx_compiler: g++
std: 20
build_type: relwithdebinfo
job_name: linux_doc_examples_testing_ubuntu_latest
- os: windows-2022
generator: "Visual Studio 17 2022"
c_compiler: cl
cxx_compiler: cl
std: 20
build_type: relwithdebinfo
steps:
- uses: actions/checkout@v4
- name: Build library
run: |
mkdir build && cd build
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DTBB_TEST=OFF ..
cmake --build . -v --target tbb --target tbbmalloc --target tbbmalloc_proxy
- name: Test doc examples
run: |
source `find ./build -name vars.sh`
cd doc/main/examples_testing
mkdir build && cd build
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ..
cmake --build . -v --target build-doc-examples
ctest -C ${{ matrix.build_type }} --timeout ${env:TEST_TIMEOUT} --output-on-failure
cmake -G ${{ matrix.generator }} -DCMAKE_CXX_STANDARD=${{ matrix.std }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type}} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DTBB_TEST=ON -D_TBB_DOC_EXAMPLES=ON ..
cmake --build . -v --parallel --target build-doc-examples
ctest -C ${{ matrix.build_type }} --timeout ${env:TEST_TIMEOUT} --output-on-failure -L doc-examples
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ endif()

option(TBB_TEST "Enable testing" ON)
option(TBB_EXAMPLES "Enable examples" OFF)
option(_TBB_DOC_EXAMPLES "Enable documentation examples" OFF)
option(TBB_STRICT "Treat compiler warnings as errors" ON)
option(TBB_WINDOWS_DRIVER "Build as Universal Windows Driver (UWD)" OFF)
option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Windows Store)" OFF)
Expand Down Expand Up @@ -330,6 +331,16 @@ if (TBB_EXAMPLES)
add_subdirectory(examples)
endif()

set(TBB_DOC_EXAMPLES_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/doc/main/examples_testing")

if (_TBB_DOC_EXAMPLES)
if (NOT EXISTS ${TBB_DOC_EXAMPLES_DIRECTORY})
message(FATAL_ERROR "Documentation examples are not found while testing was enabled")
else()
add_subdirectory(${TBB_DOC_EXAMPLES_DIRECTORY})
endif()
endif()

if (TBB_BENCH)
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/benchmark)
message(FATAL_ERROR "Benchmarks are not supported yet")
Expand Down
32 changes: 15 additions & 17 deletions doc/main/examples_testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,36 @@
# limitations under the License.

cmake_minimum_required(VERSION 3.11)
project(doc_examples_testing)
project(doc_examples_testing LANGUAGES CXX)

set(_tbb_include_path "${CMAKE_CURRENT_SOURCE_DIR}/../../../include")
set(_reference_examples_path "${CMAKE_CURRENT_SOURCE_DIR}/../reference/examples")
set(_userguide_examples_path "${CMAKE_CURRENT_SOURCE_DIR}/../tbb_userguide/examples")

add_custom_target(build-doc-examples
COMMENT "Build oneTBB documentation samples")
set(doc_examples_test_label "doc-examples")

macro(add_example example_path)
message(STATUS "Adding ${_example_path}")
macro(add_doc_example _doc_example_path)
message(STATUS "Adding ${_doc_example_path}")

get_filename_component(_example_name "${_example_path}" NAME_WE)
add_executable(${_example_name} EXCLUDE_FROM_ALL "${_example_path}")
get_filename_component(_doc_example_name "${_doc_example_path}" NAME_WE)
add_executable(${_doc_example_name} EXCLUDE_FROM_ALL "${_doc_example_path}")

target_include_directories(${_example_name} PRIVATE ${_tbb_include_path})
target_link_libraries(${_example_name} tbb)
target_link_libraries(${_example_name} tbbmalloc)
add_dependencies(${_doc_example_name} TBB::tbb TBB::tbbmalloc)
target_link_libraries(${_doc_example_name} TBB::tbb TBB::tbbmalloc)

add_dependencies(build-doc-examples ${_example_name})
add_test(NAME ${_example_name} COMMAND ${_example_name})
add_dependencies(build-doc-examples ${_doc_example_name})
add_test(NAME ${_doc_example_name} COMMAND ${_doc_example_name})
set_tests_properties(${_doc_example_name} PROPERTIES LABELS "${doc_examples_test_label}")
endmacro()

file(GLOB_RECURSE REFERENCE_EXAMPLES_LIST "${_reference_examples_path}/*.cpp")
file(GLOB_RECURSE USERGUIDE_EXAMPLES_LIST "${_userguide_examples_path}/*.cpp")

foreach(_example_path IN LISTS REFERENCE_EXAMPLES_LIST)
add_example(${_example_path})
foreach(_doc_example_path IN LISTS REFERENCE_EXAMPLES_LIST)
add_doc_example(${_doc_example_path})
endforeach()

foreach(_example_path IN LISTS USERGUIDE_EXAMPLES_LIST)
add_example(${_example_path})
foreach(_doc_example_path IN LISTS USERGUIDE_EXAMPLES_LIST)
add_doc_example(${_doc_example_path})
endforeach()

enable_testing()

0 comments on commit b9f1e5e

Please sign in to comment.