-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathCMakeLists.txt
244 lines (223 loc) · 7.22 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#
cmake_minimum_required(VERSION 2.8)
PROJECT( nvFx )
set(VERSION "1.2.0")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
if(WIN32)
SET( USE_NSIGHT OFF CACHE BOOL "Use NSight" )
SET( MEMORY_LEAKS_CHECK OFF CACHE BOOL "Build the project for Memory leaks check" )
endif(WIN32)
SET( NVFXVERBOSE OFF CACHE BOOL "allow the runtime to output lots of debug log messages" )
SET( BUILD_SAMPLES ON CACHE BOOL "Build the test samples" )
SET( USE_CUDA OFF CACHE BOOL "Use CUDA" )
SET( USE_OPTIX OFF CACHE BOOL "Use OPTIX" )
if(WIN32)
SET( USE_D3D OFF CACHE BOOL "Use D3D" )
endif()
#SET( USE_DLLSO OFF CACHE BOOL "nvFx as .dll or .so" )
SET( USE_OPENGL ON CACHE BOOL "Use OpenGL" )
SET( USE_SVCUI ON CACHE BOOL "Use the optional UI" )
SET( USE_GLUT OFF CACHE BOOL "Use Glut or not(in the case of Windows)" )
SET( NVFXCC_ON_EFFECTS OFF CACHE BOOL "compile effects of samples with nvFxcc cmd-line during project builds" )
#SET( GLUT_LOCATION "" CACHE PATH "Path for Glut, if cmake didn't find it" )
#SET( GLEW_LOCATION "" CACHE PATH "Path for Glew, if cmake didn't find it" )
# Specify the list of directories to search for cmake modules.
set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
)
set( CMAKE_PROGRAM_PATH "$ENV{PATH}")
# Macro for adding files close to the executable
macro(_copy_files_to_target target thefiles)
if(WIN32)
foreach (FFF ${thefiles} )
add_custom_command(
TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${FFF}"
$<TARGET_FILE_DIR:${target}>
VERBATIM
)
endforeach()
endif()
endmacro()
if ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
set(ARCH "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "CPU Architecture" )
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set (ARCH "x64" CACHE STRING "CPU Architecture")
set (ARCHSUFFIX "64")
else ()
set (ARCH "x86" CACHE STRING "CPU Architecture")
endif()
if(MSVC90)
set (CRT "crt90")
set ( COMPILER_ARCH "win32-msvc2008-${ARCH}" )
#enable multiprocessor build on visual studio 2008
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP ${MSVC_CXX_FLAGS}")
elseif(MSVC10)
set (CRT "crt100")
set ( COMPILER_ARCH "win32-msvc2010-${ARCH}" )
#enable multiprocessor build on visual studio 2010
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP ${MSVC_CXX_FLAGS}")
endif(MSVC90)
if(UNIX)
set(OS "linux")
add_definitions(-DLINUX)
else(UNIX)
if(APPLE)
else(APPLE)
if(WIN32)
set(OS "win")
add_definitions(-DNOMINMAX)
endif(WIN32)
endif(APPLE)
endif(UNIX)
# ===============> bison
find_package(BISON)
find_package(FLEX)
if((NOT BISON_FOUND) OR (NOT FLEX_FOUND))
message(WARNING "
No Bison and/or Flex available. FxParser will only use the already generated code.
You can try to set BISON_EXECUTABLE & FLEX_EXECUTABLE"
)
set(BISON_EXECUTABLE "" CACHE PATHFILE "bison")
set(FLEX_EXECUTABLE "" CACHE PATHFILE "flex")
MARK_AS_ADVANCED(CLEAR BISON_EXECUTABLE)
MARK_AS_ADVANCED(CLEAR FLEX_EXECUTABLE)
endif()
# ===============> D3D
if(USE_D3D AND (WIN32))
find_package(DXSDK MODULE)
endif()
#=============> Only in OpenGL Case
if(USE_OPENGL)
find_package(OpenGL)
message(STATUS "OpenGL Libraries: ${OPENGL_LIBRARIES}")
# ===============> GLUT
if(USE_GLUT)
find_package(GLUT)
if(NOT GLUT_FOUND)
message(WARNING "Try to set GLUT_LOCATION")
endif()
endif()
# ===============> GLEW
if (NOT APPLE)
find_package(GLEW REQUIRED)
endif()
# ===============> OPTIX
if(USE_OPTIX)
find_package(OPTIX)
if(OPTIX_FOUND)
add_definitions(
-DUSEOPTIX
)
else()
message(WARNING "OPTIX was not found")
endif()
endif()
# ===============> CUDA
if(USE_CUDA)
find_package(CUDA)
MARK_AS_ADVANCED(CUDA_SDK_ROOT_DIR)
if(CUDA_FOUND)
add_definitions(
-DUSECUDA
)
else()
message(WARNING "CUDA was not found")
endif()
endif()
endif() # OpenGL
# ===============> Memory leak check: define
if( MEMORY_LEAKS_CHECK)
add_definitions(
-DMEMORY_LEAKS_CHECK
)
endif()
# ===============> Other general options
if( NVFXVERBOSE)
add_definitions(
-DNVFXVERBOSE
)
endif()
# ===============
if ("${CMAKE_GENERATOR}" MATCHES "^(Visual Studio).*")
set (NVFX_CONFIG "$(ConfigurationName)")
else()
if( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
set (NVFX_CONFIG "release")
endif()
endif()
#set binary directory
if(WIN32 AND "${CMAKE_GENERATOR}" MATCHES "^(Visual Studio).*")
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" )
else()
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/${NVFX_CONFIG}" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NVFX_CONFIG}" )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NVFX_CONFIG}" )
endif()
set(NVFX_BINARY_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${NVFX_CONFIG}" CACHE STRING "Devtech Platform binary path")
#####################################################################################
# NSIGHT
#
if(USE_NSIGHT)
add_definitions(-DUSE_NSIGHT)
include_directories(NSight)
if( ARCH STREQUAL "x64" )
set(NSIGHT_LIB "${PROJECT_SOURCE_DIR}/NSight/nvToolsExt64_1.lib")
set(NSIGHT_DLL "${PROJECT_SOURCE_DIR}/NSight/nvToolsExt64_1.dll")
else()
set(NSIGHT_LIB "${PROJECT_SOURCE_DIR}/NSight/nvToolsExt32_1.lib")
set(NSIGHT_DLL "${PROJECT_SOURCE_DIR}/NSight/nvToolsExt32_1.dll")
endif()
#MARK_AS_ADVANCED(NSIGHT_LIB)
else()
set(NSIGHT_LIB, "")
endif()
#include_directories(${NVFX_HOME})
set(NVFX_LIBS FxLib)
set(NVFX_BASE_LIBS FxLib)
add_subdirectory( FxLib )
# add this library to the list
if(USE_OPENGL)
add_subdirectory( FxLibGL )
list(APPEND NVFX_LIBS FxLibGL)
# For now, CUDA makes sense only for OpenGL...
# later, we shall expose it to D3D
# or even allow to use CUDA without any Gfx API...
if(USE_CUDA AND CUDA_FOUND)
add_subdirectory( FxLibCUDA )
list(APPEND NVFX_LIBS FxLibCUDA) # FxLib refers to it when cmake allowed CUDA... so we need it for all :-(
endif()
# for now, Optix makes sense only for OpenGL, too
if(USE_OPTIX AND OPTIX_FOUND)
add_subdirectory( FxLibOPTIX )
list(APPEND NVFX_LIBS FxLibOPTIX)
endif()
endif()
if(USE_D3D AND WIN32)
add_subdirectory( FxLibD3D )
set(NVFX_D3D_LIB FxLibD3D)
list(APPEND NVFX_LIBS FxLibD3D)
endif()
add_subdirectory( FxParser )
list(APPEND NVFX_LIBS FxParser)
list(APPEND NVFX_BASE_LIBS FxParser)
# for now, only available in Windows
if(WIN32)
add_subdirectory( nvFxcc )
else()
message(STATUS "cmd line compiler only available for Windows")
endif()
if(BUILD_SAMPLES)
add_subdirectory( samples )
endif()
##################################################################
# INSTALL
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
file(GLOB PUBLIC_HDRS "." "include/*.h")
install(FILES ${PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
endif()