cmake_minimum_required(VERSION 3.2 FATAL_ERROR)

project(Cudalicious CXX)
option(BUILD_EXAMPLES "Build the bundled examples" OFF)

if (BUILD_EXAMPLES)
  find_package(CUDA REQUIRED)

  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wpedantic")

  find_package(CUDA REQUIRED)
  set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -arch=sm_30 -std=c++11 -Xcompiler -Wno-unused,-Wno-unused-parameter,-Wno-language-extension-token")

  # Temporary "hack"...
  include_directories(include)

  cuda_add_executable(vector_add example/vector_add/vector_add.cu)
endif()

cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(Cudalicious CXX CUDA)
option(BUILD_EXAMPLES "Build the bundled examples" OFF)

if (BUILD_EXAMPLES)
  set(CMAKE_CXX_STANDARD 14)  # NOTE: Also affects CMAKE_CUDA_STANDARD.
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")

  # Since nvcc doesn't support -std=c++14 yet, manually set to c++11.
  set(CMAKE_CUDA_STANDARD 11)
  set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_50")

  add_executable(vector_add example/vector_add/vector_add.cu)
  target_include_directories(vector_add PRIVATE include)
endif()

Migrate to native CUDA support added in CMake 3.8
Migrate to native CUDA support added in CMake 3.8
