Skip to content
Snippets Groups Projects
Commit fac3e1f7 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Merge branch 'main' into dev

parents e1f3e2fd 09989632
No related branches found
No related tags found
1 merge request!28v0.2.2
Pipeline #60586 passed
...@@ -54,14 +54,16 @@ before-build = [ ...@@ -54,14 +54,16 @@ before-build = [
"bash .gitlab/ci/cibuildwheel_build_deps_before_build_wheel.sh /host" "bash .gitlab/ci/cibuildwheel_build_deps_before_build_wheel.sh /host"
] ]
before-test = [ before-test = [
"bash .gitlab/ci/cibuildwheel_build_deps_before_build_wheel.sh /host" "pip install aidge-core",
"pip install aidge-backend-cpu",
] ]
[tool.cibuildwheel.windows] [tool.cibuildwheel.windows]
before-build = [ before-build = [
"powershell -File .\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1" "powershell -File .\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1"
] ]
before-test = [ before-test = [
"powershell -File .\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1" "pip install aidge-core",
"pip install aidge-backend-cpu",
] ]
......
Include(FetchContent) include(FetchContent)
# Fetch and make available Catch2 for unit testing
FetchContent_Declare( FetchContent_Declare(
Catch2 Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.1 # or a later release GIT_TAG v3.0.1 # or a later release
) )
FetchContent_MakeAvailable(Catch2) FetchContent_MakeAvailable(Catch2)
# Gather all source files for the test executable
file(GLOB_RECURSE src_files "*.cpp") file(GLOB_RECURSE src_files "*.cpp")
set(tests_exe tests${module_name}) set(tests_exe tests${module_name})
add_executable(tests_exe ${src_files})
set_target_properties(tests_exe PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# Find required and optional dependencies
find_package(aidge_backend_cpu REQUIRED) find_package(aidge_backend_cpu REQUIRED)
find_package(aidge_backend_cuda) find_package(aidge_backend_cuda)
if(NOT DEFINED CMAKE_CUDA_STANDARD) # Find CUDA Toolkit if CUDA backend is available
set(CMAKE_CUDA_STANDARD 14) if(aidge_backend_cuda_FOUND)
set(CMAKE_CUDA_STANDARD_REQUIRED ON) # Specify CUDA Toolkit without COMPONENTS to avoid missing imported targets
enable_language(CUDA)
find_package(CUDA REQUIRED)
find_package(CUDAToolkit REQUIRED)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
endif() endif()
target_link_libraries(tests_exe # Define the test executable
add_executable(${tests_exe} ${src_files})
# Include CUDA headers
include_directories(${CUDA_INCLUDE_DIRS})
# Link against the required aidge_backend_cpu library
target_link_libraries(${tests_exe}
PUBLIC ${module_name} _aidge_backend_cpu PUBLIC ${module_name} _aidge_backend_cpu
PRIVATE Catch2::Catch2WithMain PRIVATE Catch2::Catch2WithMain
) )
# Conditional CUDA linkage and definitions
if(aidge_backend_cuda_FOUND) if(aidge_backend_cuda_FOUND)
# Enable CUDA language support and separable compilation for the target
enable_language(CUDA) enable_language(CUDA)
find_package(CUDAToolkit REQUIRED) set_target_properties(${tests_exe} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries( _aidge_backend_cuda target_include_directories(${tests_exe} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
INTERFACE # Link manually specified CUDA libraries if the targets are not available
cudart # Ensure CUDA dependencies are included target_link_libraries(${tests_exe}
cublas # Include other CUDA components if needed PUBLIC
cudnn _aidge_backend_cuda
) CUDA::cudart
CUDA::cublas
target_include_directories(_aidge_backend_cuda INTERFACE ${CUDAToolkit_INCLUDE_DIRS}) cudnn
target_link_libraries(tests_exe
PUBLIC ${module_name} _aidge_backend_cuda
) )
# Define a preprocessor macro if aidge_backend_cuda is linked # Define a preprocessor macro to indicate CUDA support
target_compile_definitions(tests_exe PUBLIC USE_AIDGE_BACKEND_CUDA) target_compile_definitions(${tests_exe} PUBLIC USE_AIDGE_BACKEND_CUDA)
endif() endif()
# Add Catch2 test discovery
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest) include(CTest)
include(Catch) include(Catch)
catch_discover_tests(tests_exe) catch_discover_tests(${tests_exe})
0.2.0 0.3.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment