Skip to content

Commit b8693ef

Browse files
Fix tests
1 parent c95b65d commit b8693ef

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
cmake_minimum_required(VERSION 4.0)
22
project(memlayout LANGUAGES CXX)
33

4-
#option(ENABLE_CPU "Build CPU tests" ON)
5-
#option(ENABLE_CUDA "Build CUDA tests" ON)
4+
option(BUILD_TESTING "Build unit tests" OFF)
5+
option(BUILD_DOCS "Build documentation" OFF)
66

77
add_subdirectory(memlayout)
88

9-
add_subdirectory(tests EXCLUDE_FROM_ALL)
9+
if(BUILD_TESTING)
10+
add_subdirectory(tests)
11+
endif()
1012

11-
add_subdirectory(docs EXCLUDE_FROM_ALL)
13+
if(BUILD_DOCS)
14+
add_subdirectory(docs)
15+
endif()

tests/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
set(CMAKE_CXX_STANDARD 20)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
4+
15
include(FetchContent)
26
FetchContent_Declare(
37
googletest
@@ -10,4 +14,9 @@ include(GoogleTest)
1014

1115
add_subdirectory(cpu)
1216

13-
add_subdirectory(gpu)
17+
find_package(CUDAToolkit QUIET)
18+
if(CUDAToolkit_FOUND OR CMAKE_CUDA_COMPILER)
19+
add_subdirectory(gpu)
20+
else()
21+
message(STATUS "CUDA not found - skipping GPU tests")
22+
endif()

tests/cpu/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
set(CMAKE_CXX_STANDARD 20)
2-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
4-
51
add_executable(test_cpu test_cpu.cpp)
62
target_include_directories(test_cpu PUBLIC ${CMAKE_SOURCE_DIR}/tests/include)
73
target_link_libraries(test_cpu PRIVATE memlayout::Wrapper GTest::gtest_main)

0 commit comments

Comments
 (0)