-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (119 loc) · 4.07 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
# Copyright (C) 2013
# James Tappin
# This 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, or (at your option)
# any later version.
# This software 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
# this program; see the files COPYING3 and COPYING.RUNTIME respectively.
# If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.1)
project(graffer Fortran C)
include(CheckCSourceCompiles)
# Disable GDL routine installation with -DGDL=0, renable with
# -DGDL=1
set(GDL ON CACHE BOOL "GRAFFER: Install gdl routines?")
# Enable installation of GDL/IDL gui with -DGDL_GUI=1
set(GDL_GUI OFF CACHE BOOL "GRAFFER: Install GDL GUI?")
# Note that we override the lib directory here because most
# 64-bit systems don't actually work if we use the default.
include(GNUInstallDirs)
set(CMAKE_INSTALL_LIBDIR lib)
# Uncomment this to debug or use "cmake -D CMAKE_BUILD_TYPE=debug .."
# set(CMAKE_BUILD_TYPE debug)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE release)
endif()
message(STATUS "Build type is: ${CMAKE_BUILD_TYPE}")
# Removed -ffpe-trap=invalid,zero,overflow as it gives a lot of crashes deep
# in the call stack in Gtk3
set(CMAKE_Fortran_FLAGS_DEBUG
"-g -pthread -Wall -Wtabs -fcheck=all -fbacktrace -Wno-unused-dummy-argument -no-pie")
set(CMAKE_Fortran_FLAGS_RELEASE
"-pthread -O3 -mtune=native -march=native -no-pie")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# uninstall target
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# Find Gtk-Fortran, if Gtk3 is preferred, then switch the order of
# the scans below, or to use only one version use -DGTK=2 or -DGTK=3
if (GTK EQUAL 2)
find_package(Gtk2Fortran)
if (NOT GTK2FORTRAN_FOUND)
message (FATAL_ERROR "Gtk2Fortran not found, aborting")
endif()
add_definitions("-DGTK2")
elseif (GTK EQUAL 3)
find_package(Gtk3Fortran)
if (NOT GTK3FORTRAN_FOUND)
message (FATAL_ERROR "Gtk3Fortran not found, aborting")
endif()
add_definitions("-DGTK3")
else ()
find_package(Gtk3Fortran)
if (NOT GTK3FORTRAN_FOUND)
message(STATUS "Gtk3Fortran not found, trying Gtk2Fortran")
find_package(Gtk2Fortran)
if (NOT GTK2FORTRAN_FOUND)
message (FATAL_ERROR "Gtk2Fortran not found either, aborting")
endif()
add_definitions("-DGTK2")
else (GTK2FORTRAN_FOUND)
add_definitions("-DGTK3")
endif()
endif()
find_package(PlplotF95)
if(NOT PLPLOT_FOUND)
message(FATAL_ERROR "PLPLOT not found")
endif()
set(CMAKE_REQUIRED_LIBRARIES "${PLPLOT_LIBRARIES}")
set(CMAKE_REQUIRED_INCLUDES "${PLPLOT_INCLUDE_DIR}")
check_c_source_compiles("
#include <plplot/plplot.h>
int main(int argc, void *argv[])
{
PLFLT w = 0.5;
plinit();
plwidth(w);
}" HAVE_PLWIDTH)
if(HAVE_PLWIDTH)
add_definitions("-DHAVE_PLWIDTH")
endif(HAVE_PLWIDTH)
if (GDL)
find_program(HAVE_GDL "gdl")
if (NOT HAVE_GDL)
find_program(HAVE_GDL "idl")
if (NOT HAVE_GDL)
message("Neither 'gdl' nor 'idl' was found, graffer will not be able to evaluate functions")
else()
message("Found 'idl' in path")
endif()
else()
message("Found 'gdl' in path")
endif()
endif()
find_program(PDFLATEX "pdflatex")
if (NOT PDFLATEX)
message(WARNING "pdflatex, not found cannot generate PDF manuals")
endif()
include_directories(${GTKFORTRAN_MODULE_DIR})
include_directories(${PLPLOT_MODULE_DIR})
link_directories(${GTKFORTRAN_LIBRARY_DIRS})
link_directories(${PLPLOT_LIBRARY_DIRS})
link_directories(/usr/local/lib)
add_subdirectory(src)
add_subdirectory(data)
if (GDL)
add_subdirectory(gdl)
endif()
if (PDFLATEX)
add_subdirectory(Docs)
endif()