forked from ComputationalRadiationPhysics/liFFT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
154 lines (135 loc) · 5.7 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
# This file is part of libLiFFT.
#
# libLiFFT is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# libLiFFT 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with libLiFFT. If not, see <www.gnu.org/licenses/>.
# Hack for C++11 Support in eclipse
# https://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=15316&graph=relation
# The CMAKE_CXX_COMPILER_ARG1 must be set before the project() call to have cmake set up
# the correct flags that are later used by eclipse
if (${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4")
set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE)
set(CMAKE_ECLIPSE_VERSION "4.4" CACHE STRING "Eclipse version" FORCE)
endif ()
include(CheckCXXCompilerFlag)
macro(CheckAndAddFlag flag)
set(VarName ${flag})
string(REPLACE "+" "X" VarName ${VarName})
CHECK_CXX_COMPILER_FLAG(${flag} FLAG_${VarName}_SUPPORTED)
if(FLAG_${VarName}_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler ${flag}")
endif()
endmacro()
project(libLiFFT)
cmake_minimum_required(VERSION 3.1)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{HOME}/Software/tiff $ENV{HOME}/Software/FFTW)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
###############################################################################
# TIFF
###############################################################################
find_package(TIFF REQUIRED)
set(LIBS ${LIBS} ${TIFF_LIBRARIES})
include_directories(${TIFF_INCLUDE_DIR})
###############################################################################
# OpenCL+clFFT
###############################################################################
find_package(OpenCL)
if(OpenCL_FOUND)
find_package(clFFT)
set(LiFFT_ENABLE_OPENCL ${CLFFT_FOUND} CACHE BOOL "Use OpenCL/clFFT")
if(CLFFT_FOUND AND LiFFT_ENABLE_OPENCL)
message(">> OpenCL/clFFT enabled.")
set(LIBS ${LIBS} ${CLFFT_LIBRARIES} ${OpenCL_LIBRARIES})
include_directories(${OpenCL_INCLUDE_DIRS} ${CLFFT_INCLUDE_DIRS})
endif()
endif()
###############################################################################
# CUDA
###############################################################################
find_package(CUDA)
set(LiFFT_ENABLE_CUDA ${CUDA_FOUND} CACHE BOOL "Use CUDA")
if(CUDA_FOUND AND LiFFT_ENABLE_CUDA)
if(LiFFT_ENABLE_OPENCL)
message(FATAL_ERROR "cuFFT as well as clFFT have been found and you have enabled both of them, please use e.g. -DLiFFT_ENABLE_CUDA=0 -DLiFFT_ENABLE_OPENCL=1.")
endif()
list(APPEND CUDA_NVCC_FLAGS_RELEASE "-O3 -DNDEBUG")
list(APPEND CUDA_NVCC_FLAGS_DEBUG "-O0 -g")
# Older cmakes used the default compiler, not the CMAKE C compiler
if(${CMAKE_VERSION} VERSION_LESS 2.8.10)
list(APPEND CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}")
endif()
# http://stackoverflow.com/questions/34996295/trying-to-get-cuda-7-5-to-work-with-gcc-5-x
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CUDA_VERSION_STRING} EQUAL "7.5")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
list(APPEND CUDA_NVCC_FLAGS "-D_MWAITXINTRIN_H_INCLUDED")
message(WARNING "CUDA 7.5 and gcc5+ probably will fail to compile liFFT/cufft, try gcc4.8.2.")
endif()
endif()
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
endif(CUDA_FOUND AND LiFFT_ENABLE_CUDA)
###############################################################################
# FFTW
###############################################################################
if((CUDA_FOUND AND LiFFT_ENABLE_CUDA)
OR (CLFFT_FOUND AND LiFFT_ENABLE_OPENCL))
find_package(FFTW)
else()
find_package(FFTW REQUIRED)
endif()
if(FFTW_FOUND)
set(LIBS ${LIBS} ${FFTW_LIB} ${FFTW_F_LIB})
include_directories(${FFTW_INCLUDE_DIRS})
endif()
###############################################################################
# Boost
###############################################################################
find_package(Boost 1.48.0 COMPONENTS program_options system filesystem REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
# Use the CMake variable available at 3.1 and up
if(${CMAKE_VERSION} VERSION_LESS 3.1)
add_definitions(-std=c++11)
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
# Required by CUDA w/o CUDA_PROPAGATE_HOST_FLAGS=ON
list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
CheckAndAddFlag(-Wall)
CheckAndAddFlag(-Wextra)
CheckAndAddFlag(-Wshadow)
CheckAndAddFlag(/W3)
if(CUDA_FOUND AND LiFFT_ENABLE_CUDA)
add_definitions(-DWITH_CUDA)
cuda_add_executable(fftTiffImg fftTiffImg/main.cu)
CUDA_ADD_CUFFT_TO_TARGET(fftTiffImg)
cuda_add_executable(reportVolumes reportVolumes/main.cu)
CUDA_ADD_CUFFT_TO_TARGET(reportVolumes)
else()
if(CLFFT_FOUND AND LiFFT_ENABLE_OPENCL)
add_definitions(-DWITH_OPENCL)
endif()
add_executable(fftTiffImg fftTiffImg/main.cpp)
add_executable(reportVolumes reportVolumes/main.cpp)
endif()
add_executable(tiff2PDF tiff2Pdf/tiff2pdf.cpp)
target_link_libraries(tiff2PDF ${TIFF_LIBRARIES})
target_link_libraries(fftTiffImg ${LIBS})
target_link_libraries(reportVolumes ${LIBS})
add_subdirectory(test)
enable_testing()
add_test(NAME Main_Test COMMAND Test)