-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
105 lines (83 loc) · 2.83 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
cmake_minimum_required(VERSION 3.5)
project(opensc)
enable_language(Fortran)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
## set(dialect "-Wall -ffree-form -ffree-line-length-none -std=f2008 -fimplicit-none")
set(dialect "-Wconversion -ffree-form -ffree-line-length-none -cpp -std=f2008 -fimplicit-none")
set(bounds "-fbounds-check")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(dialect "-stand f08 -free -implicitnone")
set(bounds "-check bounds")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
set(dialect "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03")
set(bounds "-C")
endif()
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif()
#--------------------------------------------
#--------------------------------------------
option(use_fftw "USE_FFTW" Off)
if(use_fftw)
add_definitions(-DUSE_FFTW)
message(STATUS "Using FFTW")
#--------------------------------------------
option(GetFFTW "GetFFTW" ON)
if(GetFFTW)
# FFTW3
include(ExternalProject)
ExternalProject_Add(project_fftw
URL http://www.fftw.org/fftw-3.3.9.tar.gz
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fftw
CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fftw/src/project_fftw/configure --enable-openmp --prefix=<INSTALL_DIR>
BUILD_COMMAND make -j 8
INSTALL_COMMAND make install
PREFIX=${CMAKE_CURRENT_BINARY_DIR}/fftw
)
ExternalProject_Get_Property(project_fftw install_dir)
message(STATUS "fftw install_dir: " ${install_dir})
# Libraries
add_library(fftw STATIC IMPORTED)
set_property(TARGET fftw PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libfftw3.a)
add_library(fftw_omp STATIC IMPORTED)
set_property(TARGET fftw_omp PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libfftw3_omp.a)
add_dependencies(fftw project_fftw)
include_directories(${install_dir}/include)
endif(GetFFTW)
#--------------------------------------------
endif()
#--------------------------------------------
#--------------------------------------------
#
# Compile.
#
#file(GLOB_RECURSE sources code/*.f90 code/*.h)
set(sources
code/fast_fourier_am.f90
code/fft_interface_mod.f90
code/open_spacecharge_core_mod.f90
code/open_spacecharge_mod.f90
code/test_mod.f90
code/test_opensc.f90
)
add_executable(test_opensc ${sources})
install(TARGETS test_opensc DESTINATION bin)
# Link FFTW
#
if(GetFFTW)
add_dependencies(test_opensc fftw)
target_link_libraries(test_opensc fftw fftw_omp)
endif()
# Library
add_library(openspacecharge STATIC
code/fast_fourier_am.f90
code/fft_interface_mod.f90
code/open_spacecharge_core_mod.f90
code/open_spacecharge_mod.f90)
# Install
install(TARGETS openspacecharge DESTINATION lib)