• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ---------------------------------------------------------------------------
2#  Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3#
4#  Distributed under the Boost Software License, Version 1.0
5#  See accompanying file LICENSE_1_0.txt or copy at
6#  http://www.boost.org/LICENSE_1_0.txt
7#
8# ---------------------------------------------------------------------------
9
10cmake_minimum_required(VERSION 2.8)
11
12project(BoostCompute)
13
14set(CMAKE_MODULE_PATH ${BoostCompute_SOURCE_DIR}/cmake)
15if (CMAKE_VERSION VERSION_LESS "3.1.0")
16    list(APPEND CMAKE_MODULE_PATH "${BoostCompute_SOURCE_DIR}/cmake/opencl")
17endif()
18
19# find OpenCL
20find_package(OpenCL REQUIRED)
21include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
22
23# find Boost
24find_package(Boost 1.54 REQUIRED)
25include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
26
27# optional support for c++11
28option(BOOST_COMPUTE_USE_CPP11 "Use C++11 features" OFF)
29if(NOT MSVC)
30  if(${BOOST_COMPUTE_USE_CPP11})
31    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
32  endif()
33endif()
34
35# optional support for offline-caching
36option(BOOST_COMPUTE_USE_OFFLINE_CACHE "Use offline cache for OpenCL program binaries" OFF)
37if(${BOOST_COMPUTE_USE_OFFLINE_CACHE})
38  add_definitions(-DBOOST_COMPUTE_USE_OFFLINE_CACHE)
39endif()
40
41# thread-safety options
42option(BOOST_COMPUTE_THREAD_SAFE "Compile with BOOST_COMPUTE_THREAD_SAFE defined" OFF)
43if(${BOOST_COMPUTE_THREAD_SAFE})
44  add_definitions(-DBOOST_COMPUTE_THREAD_SAFE)
45  if(${BOOST_COMPUTE_USE_CPP11})
46    if(MSVC)
47      if (MSVC_VERSION GREATER 1800)
48        add_definitions(-DBOOST_COMPUTE_HAVE_THREAD_LOCAL)
49      endif()
50    else()
51      add_definitions(-DBOOST_COMPUTE_HAVE_THREAD_LOCAL)
52    endif()
53  endif()
54endif()
55
56# optional third-party libraries
57option(BOOST_COMPUTE_HAVE_EIGEN "Have Eigen" OFF)
58option(BOOST_COMPUTE_HAVE_OPENCV "Have OpenCV" OFF)
59option(BOOST_COMPUTE_HAVE_QT "Have Qt" OFF)
60option(BOOST_COMPUTE_HAVE_VTK "Have VTK" OFF)
61option(BOOST_COMPUTE_HAVE_CUDA "Have CUDA" OFF)
62option(BOOST_COMPUTE_HAVE_TBB "Have TBB" OFF)
63option(BOOST_COMPUTE_HAVE_BOLT "Have BOLT" OFF)
64
65include_directories(include)
66
67if(${OpenCL_HEADER_CL_EXT_FOUND})
68  add_definitions(-DBOOST_COMPUTE_HAVE_HDR_CL_EXT)
69endif()
70
71if(WIN32)
72  # optional support for boost dynamic libraries
73  option(BOOST_COMPUTE_BOOST_ALL_DYN_LINK "Use boost dynamic link libraries" OFF)
74  if(${BOOST_COMPUTE_BOOST_ALL_DYN_LINK})
75    add_definitions(-DBOOST_ALL_DYN_LINK)
76  else()
77    # for default use statis libs
78    set(Boost_USE_STATIC_LIBS ON)
79  endif()
80  link_directories(${Boost_LIBRARY_DIRS})
81endif()
82
83# compiler options
84option(BOOST_COMPUTE_ENABLE_COVERAGE "Enable code coverage generation" OFF)
85
86# Visual Studio C++
87if(MSVC)
88  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
89  add_definitions(-D_SCL_SECURE_NO_WARNINGS)
90  add_definitions(-DNOMINMAX)
91  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
92  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4003") # Not enough actual parameters for a BOOST_PP macro
93  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # Warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
94  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4305") # Warning C4305: 'initializing': truncation from 'double' to 'float'
95  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") # Warning C4800: 'uint32_t' : forcing value to bool 'true' or 'false' (performance warning)
96  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4838") # Warning C4838: conversion from 'double' to 'float' requires a narrowing conversion
97endif()
98
99option(BOOST_COMPUTE_BUILD_TESTS "Build the Boost.Compute tests" OFF)
100if(${BOOST_COMPUTE_BUILD_TESTS})
101  enable_testing()
102  add_subdirectory(test)
103endif()
104
105option(BOOST_COMPUTE_BUILD_BENCHMARKS "Build the Boost.Compute benchmarks" OFF)
106if(${BOOST_COMPUTE_BUILD_BENCHMARKS})
107  add_subdirectory(perf)
108endif()
109
110option(BOOST_COMPUTE_BUILD_EXAMPLES "Build the Boost.Compute examples" OFF)
111if(${BOOST_COMPUTE_BUILD_EXAMPLES})
112  add_subdirectory(example)
113endif()
114
115# configure cmake config file
116configure_file(
117  cmake/BoostComputeConfig.cmake.in
118  ${BoostCompute_BINARY_DIR}/BoostComputeConfig.cmake
119  @ONLY
120)
121
122# install cmake config file
123install(
124  FILES ${BoostCompute_BINARY_DIR}/BoostComputeConfig.cmake
125  DESTINATION lib/cmake/BoostCompute
126)
127
128# install header files
129install(DIRECTORY include/boost DESTINATION include/compute)
130