forked from cudpp/cudpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
166 lines (142 loc) · 4.77 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
project(cudpp)
set(cudpp_VERSION_MAJOR 2)
set(cudpp_VERSION_MINOR 3)
set(cudpp_VERSION_PATCH 0)
cmake_minimum_required(VERSION 2.8)
find_package(CUDA REQUIRED)
option(CUDPP_BUILD_SHARED_LIBS
"On to build shared libraries, off for static libraries."
OFF
)
option(CUDPP_BUILD_APPLICATIONS
"If on, builds the sample applications."
OFF
)
option(CUDA_VERBOSE_PTXAS
"On to enable verbose output from the PTXAS assembler."
OFF
)
## Set the directory where the binaries will be stored
set(EXECUTABLE_OUTPUT_PATH
${PROJECT_BINARY_DIR}/bin
CACHE PATH
"Directory where all executables will be stored"
)
## Set the directory where the libraries will be stored
set(LIBRARY_OUTPUT_PATH
${PROJECT_BINARY_DIR}/lib
CACHE PATH
"Directory where all the libraries will be stored"
)
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
)
set(cudpp_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/ext/moderngpu/include/
${CMAKE_SOURCE_DIR}/ext/cub/
)
include_directories(${cudpp_INCLUDE_DIRS})
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(bits 64)
else ()
set(bits 32)
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" configs)
foreach (config ${configs})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} "${EXECUTABLE_OUTPUT_PATH}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${config} "${LIBRARY_OUTPUT_PATH}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${config} "${LIBRARY_OUTPUT_PATH}")
set(CMAKE_${config}_POSTFIX ${bits})
endforeach(config {configs})
set(CMAKE_DEBUG_POSTFIX "${bits}d")
if(CUDPP_BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
set(LIB_TYPE SHARED)
else()
set(LIB_TYPE STATIC)
set(CUDPP_STATIC_LIB 1)
endif(CUDPP_BUILD_SHARED_LIBS)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/cudpp_config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/cudpp_config.h
)
set (CUDPP_APP_DATA_DIR
"${CMAKE_SOURCE_DIR}/apps/data/"
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/apps/common/include/common_config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/apps/common/include/common_config.h
)
# copy WIN32 DLLs
if (WIN32)
if (bits EQUAL 64)
file(COPY bin/win32/glut32.dll bin/win64/glew64.dll DESTINATION bin/)
elseif (bits EQUAL 32)
file(COPY bin/win32/glut32.dll bin/win32/glew32.dll DESTINATION bin/)
endif (bits EQUAL 64)
endif (WIN32)
# copy data files
#file(COPY apps/data DESTINATION apps)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
# message(STATUS "Detected Darwin kernel version: ${DARWIN_VERSION}")
if ((DARWIN_VERSION GREATER 13) OR (DARWIN_VERSION EQUAL 13))
set(APPLE_MAVERICKS_OR_LATER 1 INTERNAL)
set(CMAKE_CXX_FLAGS -stdlib=libstdc++)
set(CMAKE_C_FLAGS -stdlib=libstdc++)
if(CUDA_VERSION_MAJOR EQUAL 6 AND CUDA_VERSION_MINOR LESS 5)
set(CUDA_6_0 1)
endif(CUDA_VERSION_MAJOR EQUAL 6 AND CUDA_VERSION_MINOR LESS 5)
if(CUDA_VERSION_MAJOR LESS 6 OR CUDA_6_0)
if(NOT CUDA_NVCC_FLAGS MATCHES "ccbin")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -ccbin;/usr/bin/clang)
endif(NOT CUDA_NVCC_FLAGS MATCHES "ccbin")
endif(CUDA_VERSION_MAJOR LESS 6 OR CUDA_6_0)
endif ((DARWIN_VERSION GREATER 13) OR (DARWIN_VERSION EQUAL 13))
# current CUDA on Mavericks uses libstdc++, not libc++
# https://github.com/cudpp/cudpp/wiki/BuildingCUDPPWithMavericks
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_subdirectory(src/cudpp)
add_subdirectory(src/cudpp_hash)
if (CUDPP_BUILD_APPLICATIONS)
add_subdirectory(apps/cudpp_testrig)
add_subdirectory(apps/cudpp_hash_testrig)
add_subdirectory(apps/simpleCUDPP)
#add_subdirectory(apps/satGL)
endif (CUDPP_BUILD_APPLICATIONS)
# Make files that store configuration to help dependent CMake files use
# these libraries.
export(
TARGETS cudpp cudpp_hash
FILE ${LIBRARY_OUTPUT_PATH}/cudpp-targets.cmake
)
set(cudpp_INCLUDE_DIRS_CONFIG ${cudpp_INCLUDE_DIRS})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cudpp-config.cmake.in
${LIBRARY_OUTPUT_PATH}/cudpp-config.cmake
@ONLY
)
set(cudpp_INCLUDE_DIRS_CONFIG "\${_install_dir}/include")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cudpp-config.cmake.in
${LIBRARY_OUTPUT_PATH}/cudpp-config.cmake.install
@ONLY
)
install(FILES ${LIBRARY_OUTPUT_PATH}/cudpp-config.cmake.install
DESTINATION lib
RENAME cudpp-config.cmake
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cudpp-config-version.cmake.in
${LIBRARY_OUTPUT_PATH}/cudpp-config-version.cmake
@ONLY
)
install(FILES ${LIBRARY_OUTPUT_PATH}/cudpp-config-version.cmake
DESTINATION lib
)
set(CPACK_PACKAGE_VERSION_MAJOR ${cudpp_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${cudpp_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${cudpp_VERSION_PATCH})
include(CPack)