-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (103 loc) · 4.08 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required(VERSION 2.6.3)
project(GCVL)
option(BUILD_OPENCL "Build OpenCL module" ON)
option(BUILD_CUDA "Build CUDA module" OFF)
option(BUILD_TESTS "Build tests" ON)
option(COVERALLS "Coveralls support" OFF)
# Set a default build type for single-configuration
# CMake generators if no build type is set.
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
if ((NOT CMAKE_BUILD_TYPE MATCHES Debug) AND
(NOT CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) AND
(NOT CMAKE_BUILD_TYPE MATCHES MinSizeRel))
set(CMAKE_BUILD_TYPE Release)
endif ((NOT CMAKE_BUILD_TYPE MATCHES Debug) AND
(NOT CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) AND
(NOT CMAKE_BUILD_TYPE MATCHES MinSizeRel))
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/lib)
# Select flags.
IF (MSVC)
MESSAGE("-- Current build compiler is cl")
ADD_DEFINITIONS(-D_ISOC9X_SOURCE)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /arch:AVX /favor:INTEL64")
#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:MULTIPLE")
ENDIF ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-std=gnu++0x")
endif()
IF(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND COVERALLS)
message("Trying to obtain code coverage data")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") # enabling coverage
endif()
ENDIF()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#OpenCL
if(BUILD_OPENCL)
find_package(OpenCL REQUIRED)
include_directories(${OPENCL_INCLUDE_DIRS})
endif(BUILD_OPENCL)
#CUDA
if(BUILD_CUDA)
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
endif(BUILD_CUDA)
#OpenCV
IF (MSVC)
set(OpenCV_DIR $ENV{OpenCV_DIR})
set(OpenCV_STATIC OFF)
ENDIF()
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
#Boost
IF (MSVC)
set(Boost_USE_STATIC_LIBS ON)
ENDIF ()
find_package(Boost 1.46 COMPONENTS thread system iostreams filesystem date_time timer chrono REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
#OpenMP
FIND_PACKAGE(OpenMP)
IF(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
ELSE()
message(STATUS "Disabling OpenMP support")
ENDIF()
set(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
add_subdirectory(src/gcvl)
if(BUILD_TESTS)
add_subdirectory(src/test_cpu)
if(BUILD_OPENCL)
add_subdirectory(src/test_opencl)
endif(BUILD_OPENCL)
if(BUILD_CUDA)
add_subdirectory(src/test_cuda)
endif(BUILD_CUDA)
endif(BUILD_TESTS)
message(STATUS "*${CMAKE_BUILD_TYPE}* build being prepared")
# Create the GCVLConfig.cmake file for the build tree
configure_file(GCVLConfig.cmake.in "${PROJECT_SOURCE_DIR}/bin/GCVLConfig.cmake" @ONLY)