diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e1abd6..5bb8a4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,17 +3,29 @@ cmake_minimum_required(VERSION 2.8) project(gpu-stream) -set(CMAKE_SOURCE_DIR src/) +set(gpu-stream_VERSION_MAJOR 2) +set(gpu-stream_VERSION_MINOR 0) list(APPEND CMAKE_CXX_FLAGS --std=c++11) -find_package(CUDA REQUIRED) - +find_package(CUDA QUIET) +if (${CUDA_FOUND}) +set(IMPLEMENTATION CUDA) +configure_file(src/common.h.in src/common_cuda.h) cuda_add_executable(cuda.exe src/main.cpp src/CUDAStream.cu) target_compile_definitions(cuda.exe PUBLIC CUDA) +else (${CUDA_FOUND}) +message("Skipping CUDA...") +endif (${CUDA_FOUND}) -find_package(OpenCL) +find_package(OpenCL QUIET) +if (${OpenCL_FOUND}) +set(gpu-stream_IMPLEMENTATION OpenCL) +configure_file(src/common.h.in src/common_ocl.h) add_executable(ocl.exe src/main.cpp src/OCLStream.cpp) target_compile_definitions(ocl.exe PUBLIC OCL) target_link_libraries(ocl.exe ${OpenCL_LIBRARY}) +else (${OpenCL_FOUND}) +message("Skipping OpenCL...") +endif (${OpenCL_FOUND}) diff --git a/src/common.h b/src/common.h deleted file mode 100644 index c4bdadb..0000000 --- a/src/common.h +++ /dev/null @@ -1,4 +0,0 @@ - -#define VERSION_STRING "2.0" -#define IMPLEMENTATION_STRING "CUDA" - diff --git a/src/common.h.in b/src/common.h.in new file mode 100644 index 0000000..44dc040 --- /dev/null +++ b/src/common.h.in @@ -0,0 +1,4 @@ + +#define VERSION_STRING "@gpu-stream_VERSION_MAJOR@.@gpu-stream_VERSION_MINOR@" +#define IMPLEMENTATION_STRING "@gpu-stream_IMPLEMENTATION@" +