Get version from CMake configued header and only build implementations which have the runtime around

This commit is contained in:
Tom Deakin 2016-04-28 17:10:14 +01:00
parent b9e70e11ab
commit 7006871cbe
3 changed files with 20 additions and 8 deletions

View File

@ -3,17 +3,29 @@ cmake_minimum_required(VERSION 2.8)
project(gpu-stream) 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) 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) cuda_add_executable(cuda.exe src/main.cpp src/CUDAStream.cu)
target_compile_definitions(cuda.exe PUBLIC CUDA) 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) add_executable(ocl.exe src/main.cpp src/OCLStream.cpp)
target_compile_definitions(ocl.exe PUBLIC OCL) target_compile_definitions(ocl.exe PUBLIC OCL)
target_link_libraries(ocl.exe ${OpenCL_LIBRARY}) target_link_libraries(ocl.exe ${OpenCL_LIBRARY})
else (${OpenCL_FOUND})
message("Skipping OpenCL...")
endif (${OpenCL_FOUND})

View File

@ -1,4 +0,0 @@
#define VERSION_STRING "2.0"
#define IMPLEMENTATION_STRING "CUDA"

4
src/common.h.in Normal file
View File

@ -0,0 +1,4 @@
#define VERSION_STRING "@gpu-stream_VERSION_MAJOR@.@gpu-stream_VERSION_MINOR@"
#define IMPLEMENTATION_STRING "@gpu-stream_IMPLEMENTATION@"