forked from LeMonADE-project/LeMonADE-GPU
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·219 lines (190 loc) · 9.17 KB
/
CMakeLists.txt
File metadata and controls
executable file
·219 lines (190 loc) · 9.17 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
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
# ---------------------------------------------------------------------------------
# ooo L attice-based |
# o\.|./o e xtensible | LeMonADE: An Open Source Implementation of the
# o\.\|/./o Mon te-Carlo | Bond-Fluctuation-Model for Polymers
# oo---0---oo A lgorithm and |
# o/./|\.\o D evelopment | Copyright (C) 2013-2015 by
# o/.|.\o E nvironment | LeMonADE Principal Developers (see AUTHORS)
# ooo |
# ---------------------------------------------------------------------------------
#
# This file is part of LeMonADE.
#
# LeMonADE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LeMonADE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LeMonADE. If not, see <http://www.gnu.org/licenses/>.
#
# --------------------------------------------------------------------------------
#
# Project Properties
#
CMAKE_MINIMUM_REQUIRED (VERSION 3.1 FATAL_ERROR ) # c11 standard required
PROJECT (LeMonADEGPU )
SET (APPLICATION_NAME "LeMonADEGPU")
SET (APPLICATION_CODENAME "${PROJECT_NAME}")
SET (APPLICATION_COPYRIGHT_YEARS "2019")
SET (APPLICATION_VERSION_MAJOR 1)
SET (APPLICATION_VERSION_MINOR 0)
SET (APPLICATION_VERSION_PATCH 0)
SET (APPLICATION_VERSION_TYPE SNAPSHOT)
SET (APPLICATION_VERSION_STRING "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}-${APPLICATION_VERSION_TYPE}")
SET (APPLICATION_ID "${APPLICATION_VENDOR_ID}.${PROJECT_NAME}")
set( CMAKE_CXX_STANDARD 11 ) # needs CMake 3.1. Need C++11 for auto-keyword and list initializers ... I sure have gotten lazy :S
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.0" )
message( FATAL_ERROR "Insufficient gcc version. Need at least 4.7.0 for -std=c++11 flag for 'using T=int;' and at least 4.8.0 for more generalized initializer lists! See also https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/C-Dialect-Options.html#C-Dialect-Options vs. https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/C-Dialect-Options.html#C-Dialect-Options" )
endif()
endif()
#LeMonADE main repo: lib and include path
SET (LEMONADE_INCLUDE_DIR "${LEMONADE_DIR}/include")
SET (LEMONADE_LIBRARY_DIR "${LEMONADE_DIR}/lib")
if (NOT DEFINED LEMONADE_INCLUDE_DIR)
message("LEMONADE_INCLUDE_DIR is not provided. If build fails, use -DLEMONADE_INCLUDE_DIR=/path/to/LeMonADE/headers/ or install to default location")
endif()
MESSAGE("LEMONADE_INCLUDE_DIR is ${LEMONADE_INCLUDE_DIR}")
if (NOT DEFINED LEMONADE_LIBRARY_DIR)
message("LEMONADE_LIBRARY_DIR is not provided. If build fails, use -DLEMONADE_LIBRARY_DIR=/path/to/LeMonADE/lib/ or install to default location")
endif()
MESSAGE("LEMONADE_LIBRARY_DIR is ${LEMONADE_LIBRARY_DIR}")
# include gls library, e.g for fitting (shear)
SET (GSLCBLAS_INCLUDE_DIR "${GSL_DIR}/include/")
if (NOT DEFINED GSLCBLAS_INCLUDE_DIR)
message("GSLCBLAS_INCLUDE_DIR is not provided. If build fails, use -DGSL_DIR=/path/to/gsl/headers/ or install to default location")
endif()
MESSAGE("GSLCBLAS_INCLUDE_DIR is ${GSLCBLAS_INCLUDE_DIR}")
SET (GSLCBLAS_LIBRARY_DIR "${GSL_DIR}/lib64/")
include_directories (${GSLCBLAS_INCLUDE_DIR})
link_directories (${GSLCBLAS_LIBRARY_DIR})
MESSAGE("GSLCBLAS_LIBRARY_DIR is ${GSLCBLAS_LIBRARY_DIR}")
SET (GSL_INCLUDE_DIR "${GSL_DIR}/include/")
MESSAGE("GSL_INCLUDE_DIR is ${GSL_INCLUDE_DIR}")
SET (GSL_LIBRARY_DIR "${GSL_DIR}/lib64/")
MESSAGE("GSL_LIBRARY_DIR is ${GSL_LIBRARY_DIR}")
include_directories (${GSL_INCLUDE_DIR})
link_directories (${GSL_LIBRARY_DIR})
#define possible flags
SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse2 -mssse3 -fexpensive-optimizations -std=c++11 ")
SET (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse2 -mssse3 -fexpensive-optimizations -std=c++11 ")
SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -DDEBUG -std=c++11 ")
SET (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -DDEBUG -std=c++11 ")
# this add the gprof profiler which creates a gmon.out file
# the profile (gmon.out)is created after executaion of the program
# and analyzed by the gprof tool
#>gprof executable ./gmon.out > profile.txt
SET (CMAKE_CXX_FLAGS_PROFIL "${CMAKE_CXX_FLAGS_PROFIL} -O3 -g -pg -msse2 -mssse3 -fexpensive-optimizations -std=c++11 ")
SET (CMAKE_C_FLAGS_PROFIL "${CMAKE_C_FLAGS_PROFIL} -O3 -g -pg -msse2 -mssse3 -fexpensive-optimizations -std=c++11 ")
#define value of CMAKE_BUILD_TYPE depending on input
IF(NOT CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE "Release") #default build type is Release
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Release")
SET (CMAKE_BUILD_TYPE "Release")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET (CMAKE_BUILD_TYPE "Debug")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Profil")
SET (CMAKE_BUILD_TYPE "Profil")
ELSE(NOT CMAKE_BUILD_TYPE)
MESSAGE(FATAL_ERROR "Invalid build type ${CMAKE_BUILD_TYPE} specified.")
ENDIF(NOT CMAKE_BUILD_TYPE)
#output depending on build type
IF(CMAKE_BUILD_TYPE STREQUAL "Release")
SET (CMAKE_VERBOSE_MAKEFILE 0)
MESSAGE("Build type is ${CMAKE_BUILD_TYPE}")
MESSAGE("USING CXX COMPILER FLAGS ${CMAKE_CXX_FLAGS_RELEASE}")
MESSAGE("USING C COMPILER FLAGS ${CMAKE_C_FLAGS_RELEASE}")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET (CMAKE_VERBOSE_MAKEFILE 1)
MESSAGE("Build type is ${CMAKE_BUILD_TYPE}")
MESSAGE("USING CXX COMPILER FLAGS ${CMAKE_CXX_FLAGS_DEBUG}")
MESSAGE("USING C COMPILER FLAGS ${CMAKE_C_FLAGS_DEBUG}")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Profil")
SET (CMAKE_VERBOSE_MAKEFILE 2)
MESSAGE("Build type is ${CMAKE_BUILD_TYPE}")
MESSAGE("USING CXX COMPILER FLAGS ${CMAKE_CXX_FLAGS_PROFIL}")
MESSAGE("USING C COMPILER FLAGS ${CMAKE_C_FLAGS_PROFIL}")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release")
#include cuda and set flags
find_package( CUDA REQUIRED )
if( ${CUDA_VERSION_MAJOR} GREATER 7 )
set( NVCC_EXPERIMENTAL_FLAG "--expt" )
else()
set( NVCC_EXPERIMENTAL_FLAG "-" )
endif()
# set( CUDA_ARCH "60")
set( MINIMAL_CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-Xcompiler -fPIC,-Wno-unused-parameter
-gencode arch=compute_${CUDA_ARCH},code=sm_${CUDA_ARCH}
${NVCC_EXPERIMENTAL_FLAG}-relaxed-constexpr
)
set( CUDA_NVCC_FLAGS ${MINIMAL_CUDA_NVCC_FLAGS} " --compiler-options -Wall,-Wextra" )
###############################################################################
# Project Output Paths
#
SET (LEMONADEGPU_DIR ${PROJECT_SOURCE_DIR})
SET (EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
SET (LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
SET (LEMONADEGPU_INCLUDE_DIR "${LEMONADEGPU_DIR}/include")
SET (LEMONADEGPU_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH})
# SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${LEMONADEGPU_DIR}/bin")
#include directory
LIST (APPEND CMAKE_PREFIX_PATH "${LEMONADEGPU_DIR}")
# LIST (APPEND CMAKE_PREFIX_PATH "${LEMONADEGPU_DIR}")
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include/ ${LEMONADE_INCLUDE_DIR} ${CUDA_INCLUDE_DIRS} )
# LINK_DIRECTORIES (${PROJECT_SOURCE_DIR}/src)
## ############### System Creators ############# ##
add_subdirectory(src)
add_subdirectory(projects)
#
# Add option for building tests
#
option(LEMONADE_TESTS "Build the test" OFF)
if(LEMONADE_TESTS)
add_subdirectory(tests)
endif(LEMONADE_TESTS)
#
# Add Install Targets
#
# Check if INSTALLDIR_LEMONADEGPU is given
if (DEFINED INSTALLDIR_LEMONADEGPU)
message("INSTALLDIR_LEMONADEGPU set to " ${INSTALLDIR_LEMONADEGPU})
SET(CMAKE_INSTALL_PREFIX "${INSTALLDIR_LEMONADEGPU}")
else (DEFINED INSTALLDIR_LEMONADEGPU)
message("INSTALLDIR_LEMONADEGPU set to default" ${CMAKE_INSTALL_PREFIX})
endif()
#
INSTALL(DIRECTORY "${LEMONADEGPU_DIR}/include/" DESTINATION "include")
#
# #
# # Add Documentation Targets
# #
# SET (DOC_INPUT_FILE_PATH "${LEMONADEGPU_DIR}/docs/")
# SET (DOC_OUTPUT_FILE_PATH "${CMAKE_BINARY_DIR}/docs/")
#
# FIND_PACKAGE (Doxygen)
# IF (DOXYGEN_FOUND)
# MESSAGE("Build documentation with: make docs")
# IF (EXISTS ${DOC_INPUT_FILE_PATH})
# MESSAGE("Existing File documentation with doxygen")
# configure_file(${DOC_INPUT_FILE_PATH}doxygen.conf ${DOC_OUTPUT_FILE_PATH}doxygen.conf @ONLY)
# configure_file(${DOC_INPUT_FILE_PATH}mainpage.dox ${DOC_OUTPUT_FILE_PATH}mainpage.dox @ONLY)
# configure_file(${DOC_INPUT_FILE_PATH}figures/ProgramStructure.jpg ${DOC_OUTPUT_FILE_PATH}figures/ProgramStructure.jpg COPYONLY)
# ADD_CUSTOM_TARGET(
# docs
# ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_FILE_PATH}doxygen.conf
# WORKING_DIRECTORY ${DOC_OUTPUT_FILE_PATH}
# COMMENT "Generating doxygen project documentation." VERBATIM
# )
# ELSE (EXISTS ${DOC_INPUT_FILE_PATH})
# ADD_CUSTOM_TARGET(docs COMMENT "Doxyfile not found. Please generate a doxygen configuration file to use this target." VERBATIM)
# ENDIF (EXISTS ${DOC_INPUT_FILE_PATH})
# ELSE (DOXYGEN_FOUND)
# ADD_CUSTOM_TARGET(docs COMMENT "Doxygen not found. Please install doxygen to use this target." VERBATIM)
# ENDIF (DOXYGEN_FOUND)