CMakeLists.txt
4.39 KB
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
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 3.12)
#Name your project here
project(siproc)
#set the module directory
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
#default to release mode
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
#build the executable in the binary directory on MS Visual Studio
if ( MSVC )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
SET( LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif ( MSVC )
#MAYBE REMOVE-----------------
#set C++11 flags if using GCC
if( CMAKE_COMPILER_IS_GNUCC )
SET( CMAKE_CXX_FLAGS "-std=c++11")
SET( CUDA_NVCC_FLAGS "-std=c++11")
endif( CMAKE_COMPILER_IS_GNUCC )
#-----------------------------
#find packages-----------------------------------
#find the pthreads package
find_package(Threads)
#find the X11 package
find_package(X11)
#find the STIM library
find_package(STIM REQUIRED)
#find CUDA, mostly for LA stuff using cuBLAS
find_package(CUDA REQUIRED)
#find Boost for Unix-based file lists
if( CMAKE_COMPILER_IS_GNUCC )
find_package(Boost COMPONENTS filesystem system)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
add_definitions(-DBOOST_PRECOMPILED)
else()
message(FATAL_ERROR "SIproc requires Boost::filesystem and Boost::system when using GCC")
endif()
else()
find_package(Boost)
endif()
#find the GLUT library for visualization
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
if(WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIR})
endif(WIN32)
#find LAPACK and supporting link_libraries
find_package(clapack CONFIG REQUIRED)
find_package(OpenBLAS CONFIG REQUIRED)
#if(MSVC)
# message("Warning: VS2015 made a change to printf and scanf functions that requires linking to legacy_stdio_definitions.lib")
#endif()
#include include directories
include_directories(${CUDA_INCLUDE_DIRS}
${CLAPACK_INCLUDE_DIR}
${STIM_INCLUDE_DIRS}
${OpenGL_INCLUDE_DIRS}
${GLUT_INCLUDE_DIR}
"${CMAKE_SOURCE_DIR}/src"
)
#Assign source files to the appropriate variables to easily associate them with executables
file(GLOB HSIGLOBAL_SRC "${CMAKE_SOURCE_DIR}/src/*.cpp")
file(GLOB HSIPROC_SRC "${CMAKE_SOURCE_DIR}/src/proc/*.cpp")
file(GLOB STIM_CU "${STIM_INCLUDE_DIRS}/stim/envi/*.cu")
file(GLOB HSIVIEW_SRC "${CMAKE_SOURCE_DIR}/src/view/*.cpp")
file(GLOB CARY_FTIR_SRC "${CMAKE_SOURCE_DIR}/src/cary-ftir/*.cpp")
file(GLOB SPERO_SRC "${CMAKE_SOURCE_DIR}/src/spero/*.cpp")
file(GLOB PROGRESS_SRC "${CMAKE_SOURCE_DIR}/src/progress_t.cpp")
#create the PROC executable----------------------------------------------
add_executable(siproc
${HSIPROC_SRC}
${HSIGLOBAL_SRC}
)
target_link_libraries(siproc ${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_CUFFT_LIBRARIES}
${CLAPACK_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${X11_LIBRARIES}
OpenBLAS::OpenBLAS
f2c lapack
)
#create the VIEW executable----------------------------------------------
add_executable(siview
${HSIVIEW_SRC}
)
target_link_libraries(siview
${CMAKE_THREAD_LIBS_INIT}
${X11_LIBRARIES}
${OPENGL_LIBRARIES}
${GLUT_LIBRARIES}
)
if(WIN32)
target_link_libraries(siview ${GLEW_LIBRARIES})
endif(WIN32)
#create instrument-specific subroutine executables
add_executable(cary-ftir
${CARY_FTIR_SRC}
${PROGRESS_SRC}
)
target_link_libraries(cary-ftir
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_CUFFT_LIBRARIES}
)
#create the Agilent system-specific subroutine executable
add_executable(spero
${SPERO_SRC}
${PROGRESS_SRC}
)
target_link_libraries(spero
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_CUFFT_LIBRARIES}
)
#if Boost is found, set an environment variable to use with preprocessor directives
if(Boost_FILESYSTEM_FOUND)
target_link_libraries(siproc ${Boost_FILESYSTEM_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
)
target_link_libraries(siview
${Boost_FILESYSTEM_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
)
target_link_libraries(spero
${Boost_FILESYSTEM_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
)
target_link_libraries(cary-ftir
${Boost_FILESYSTEM_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
)
endif(Boost_FILESYSTEM_FOUND)