-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
72 lines (60 loc) · 2.1 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
PROJECT( gpumatting )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
#==============Set Directories=================
SET( SOURCE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
SET( doc_DIR "doc/" )
SET( test_DIR "tests/" )
SET( EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin" )
SET( LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib" )
#=================Options=======================
OPTION( DEBUG_MODE
"If on, will build everything with debug flags."
ON )
OPTION( DO_TESTING
"If on, will make unit tests."
ON )
OPTION( DO_PROFILING
"If on, and using g++, will perform profiling."
OFF )
#==============Custom Cmake Modules=============
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules" )
#===================Find Shit================
FIND_PACKAGE(CUDA REQUIRED)
SET(CUDA_SEPARABLE_COMPILATION OFF)
IF( NOT CUDA_NVCC_FLAGS )
SET( CUDA_NVCC_FLAGS "-arch sm_30" )
ENDIF()
#Include the FindCUDA script
INCLUDE(FindCUDA)
CUDA_BUILD_CLEAN_TARGET()
#===========Set release/debug settings==========
# OpenMP
IF( CMAKE_COMPILER_IS_GNUCXX )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp" )
ELSEIF( MSVC )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp" )
ENDIF()
IF( CMAKE_COMPILER_IS_GNUCXX )
SET( CMAKE_CXX_FLAGS_DEBUG "-g3 -Wall -Wno-sign-compare" )
SET( LINK_FLAGS_DEBUG "-rdynamic" )
SET( CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -Wno-deprecated -Wno-sign-compare" )
SET( LINK_FLAGS_RELEASE "-rdynamic" )
IF( DO_PROFILING )
SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" )
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg" )
ENDIF()
ENDIF()
IF( DEBUG_MODE )
SET( CMAKE_BUILD_TYPE Debug )
ELSE()
SET( CMAKE_BUILD_TYPE Release )
# This definition disables the assert() macro.
ADD_DEFINITIONS( -DNDEBUG )
ENDIF()
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} )
CUDA_ADD_EXECUTABLE( matting main.cu SLIC.cpp Solve.cpp )
IF( DO_TESTING )
ADD_SUBDIRECTORY( "tests/" )
ENDIF()