CMakeLists.txt 3.57 KB
Newer Older
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
123
124
######################################
#      CMake version checks
######################################
if(COMMAND cmake_minimum_required)
   cmake_minimum_required(VERSION 2.4)
endif(COMMAND cmake_minimum_required)

if(COMMAND cmake_policy)
	if(POLICY CMP0003)
		cmake_policy(SET CMP0003 OLD)
	endif(POLICY CMP0003)
	if(POLICY CMP0005)
		cmake_policy(SET CMP0005 OLD)
	endif(POLICY CMP0005)
	if(POLICY CMP0011)
		cmake_policy(SET CMP0011 OLD) # or NEW
	endif(POLICY CMP0011)
endif(COMMAND cmake_policy)


######################################
#              Project
######################################
PROJECT(OpenNL3)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")

#SET(GEEX_BUILD_PATH ${PROJECT_BINARY_DIR})
#SET(BINARIES_RELATIVE_PATH /binaries/bin/)

#IF (WIN32)
#    SET(LIBRARIES_RELATIVE_PATH /binaries/bin/)
#ELSE(WIN32)
#    SET(LIBRARIES_RELATIVE_PATH /binaries/lib/)
#ENDIF(WIN32)

#IF(WIN32)
#    SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})
#ELSE(WIN32)
#    SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}${LIBRARIES_RELATIVE_PATH})
#ENDIF(WIN32)

#SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})


IF (EXISTS ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
   MESSAGE(INFO: "Using local options file: " ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
   INCLUDE(${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)

IF(USE_CNC)
    ADD_DEFINITIONS(-DNL_USE_CNC)
    
    IF(CUDA_BUILD_EMULATION)
        ADD_DEFINITIONS(-D__DEVICE_EMULATION__)
    ENDIF(CUDA_BUILD_EMULATION)


    IF(WIN32)
        ADD_DEFINITIONS(-DOS_WIN)
    ELSE(WIN32)
        ADD_DEFINITIONS(-DOS_LINUX)
    ENDIF(WIN32)

	INCLUDE(${CMAKE_SOURCE_DIR}/OpenNL/CMakeModules/FindCUDA.cmake)
    
    IF (CMAKE_BUILD_TYPE MATCHES Debug)
        SET(CUDA_COMPILE_TIME_EXTRA_FLAGS -G)
    ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
    
    IF(CNC_OPTIMIZE_FOR_THIS_MACHINE)
        IF(COMMAND CUDA_DISCOVER_DEVICE_FLAGS)
        ELSE(COMMAND CUDA_DISCOVER_DEVICE_FLAGS)
	        TRY_COMPILE(COMPILE_OK ${PROJECT_BINARY_DIR}/CMake ${PROJECT_SOURCE_DIR}/CMake CUDA_DISCOVER_DEVICE_FLAGS)
	        IF(NOT COMPILE_OK)
		        IF(WIN32)
			        MESSAGE("error compiling CUDA_DISCOVER_DEVICE_FLAGS extention")
		        ELSE(WIN32)
			        MESSAGE(FATAL_ERROR "error compiling CUDA_DISCOVER_DEVICE_FLAGS extention")
		        ENDIF(WIN32)
	        ENDIF(NOT COMPILE_OK)
	        LOAD_COMMAND(CUDA_DISCOVER_DEVICE_FLAGS ${PROJECT_BINARY_DIR}/CMake ${PROJECT_BINARY_DIR}/CMake/Debug)
        ENDIF(COMMAND CUDA_DISCOVER_DEVICE_FLAGS)
        CUDA_DISCOVER_DEVICE_FLAGS()
        
        SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${CUDA_DEVICE_FLAGS} )
        ADD_DEFINITIONS(${CUDA_DEVICE_FLAGS})
    ELSE(CNC_OPTIMIZE_FOR_THIS_MACHINE)
      SET(CUDA_NVCC_FLAGS ${CNC_NVCC_FLAGS})
    ENDIF(CNC_OPTIMIZE_FOR_THIS_MACHINE)
    
ENDIF(USE_CNC)

IF (CMAKE_BUILD_TYPE MATCHES Debug)
    ADD_DEFINITIONS(-DNL_DEBUG)
    IF(PARANOID_DEBUG)
        ADD_DEFINITIONS(-DNL_PARANOID)
    ENDIF(PARANOID_DEBUG)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)


#########################################
# ADD HERE ADDITIONAL INCLUDE DIRECTORIES
#########################################
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
INCLUDE_DIRECTORIES(src)

#########################################
# ADD HERE SUBDIRECTORIES
#########################################
ADD_SUBDIRECTORY(src)

IF(BUILD_EXAMPLES)
    ADD_SUBDIRECTORY(examples)
ENDIF(BUILD_EXAMPLES)


IF(WIN32)
  MESSAGE("Configure done. You may need to click on configure again if the OK button is disabled")
ENDIF(WIN32)