forked from BRAHMS-SystemML/brahms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BrahmsLibFind.cmake
142 lines (129 loc) · 5.45 KB
/
BrahmsLibFind.cmake
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
#
# Library finding code called from top-level CMakeLists.txt file.
# This locates WX, Xaw and Python includes and libs and allows the
# user to specify paths to their matlab installation
#
# It defines a set of variables which are then used in the top level
# CMakeLists.txt file:
#
# BRAHMS_WX_CXXFLAGS
# BRAHMS_WX_CFLAGS
# BRAHMS_XAW_INCLUDE_DIR
# BRAHMS_XAW_LDFLAGS
#
# We need threads
find_package (Threads)
if(THREADS_FOUND)
message(STATUS "Found Threads with find_package :)")
else()
message(STATUS "Didn't find Threads with find_package, fallback to check_include_files search for pthread.h.")
# This is a fallback for Mac:
include (CheckIncludeFiles)
check_include_files("pthread.h" CMAKE_HAVE_PTHREAD_H)
if(NOT CMAKE_HAVE_PTHREAD_H)
message(FATAL_ERROR " You need a threading library")
endif(NOT CMAKE_HAVE_PTHREAD_H)
endif(THREADS_FOUND)
# We need -lrt on some platforms for clock_gettime (on others, clock_gettime is in libc)
if (UNIX AND NOT APPLE)
include(CheckFunctionExists)
set(CMAKE_EXTRA_INCLUDE_FILES time.h)
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
if(NOT HAVE_CLOCK_GETTIME)
message(STATUS "Didn't find clock_gettime with initial check_function_exists test")
include(CheckLibraryExists)
# On systems with glibc < 2.16 clock_gettime is in rt library
find_library(LIBRT_LIBRARIES rt)
message(STATUS "LIBRT_LIBRARIES ${LIBRT_LIBRARIES}")
set(HAVE_CLOCK_GETTIME_IN_RT 1)
# This doesn't seem to work on Iceberg:
#check_library_exists(${LIBRT_LIBRARIES} clock_gettime "time.h" HAVE_CLOCK_GETTIME_IN_RT)
#if(NOT HAVE_CLOCK_GETTIME_IN_LIBRT)
# message(FATAL_ERROR "clock_gettime not found")
#endif(NOT HAVE_CLOCK_GETTIME_IN_LIBRT)
endif(NOT HAVE_CLOCK_GETTIME)
endif(UNIX AND NOT APPLE)
# brahms-compress requires zlib
find_package(ZLIB REQUIRED)
# If you're going to use matlab bindings, then set the paths here.
if(COMPILE_MATLAB_BINDING)
set(BRAHMS_MATLAB_INCLUDES "/usr/local/MATLAB/R2014b" "/usr/local/MATLAB/R2014b/extern/include")
endif(COMPILE_MATLAB_BINDING)
# Python stuff.
if(COMPILE_PYTHON_BINDING)
find_package(PythonLibs)
if (PYTHONLIBS_FOUND)
set(BRAHMS_PYTHON_INCLUDES ${PYTHON_INCLUDE_DIRS})
set(CMD_ARGS "from numpy import *\; print get_include()")
execute_process(COMMAND /usr/bin/python -c ${CMD_ARGS}
OUTPUT_VARIABLE BRAHMS_NUMPY_INCLUDES
ERROR_VARIABLE BRAHMS_NUMPY_TEST_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(COMPARE EQUAL "${BRAHMS_NUMPY_INCLUDES}" "" NUMPY_NOT_FOUND)
if(NUMPY_NOT_FOUND)
message(FATAL_ERROR " You need numpy. On Debian/Ubuntu try `sudo apt-get install python-numpy`")
endif(NUMPY_NOT_FOUND)
endif(PYTHONLIBS_FOUND)
endif (COMPILE_PYTHON_BINDING)
if(COMPILE_WITH_MPICH2)
# Test for mpicxx. FIXME: `which` is unix-specific.
find_path(BRAHMS_MPICXX_PATH NAMES mpicxx HINTS /usr/bin /usr/local/bin)
find_path(BRAHMS_MPICXX_PATH NAMES mpicxx)
#execute_process(COMMAND which mpicxx
# OUTPUT_VARIABLE BRAHMS_MPICXX_PATH
# ERROR_VARIABLE BRAHMS_MPICXX_TEST_ERR
# OUTPUT_STRIP_TRAILING_WHITESPACE)
string(COMPARE EQUAL "${BRAHMS_MPICXX_PATH}" "" MPICXX_NOT_FOUND)
if(MPICXX_NOT_FOUND)
message(FATAL_ERROR " You need mpicxx to compile brahms-channel-mpich2. Try `sudo apt-get install mpich2`")
endif(MPICXX_NOT_FOUND)
endif(COMPILE_WITH_MPICH2)
if(NO_X11)
else()
# Could use X11_Xt_FOUND X11_Xmu_FOUND etc from find_package(X11). It
# may be that find_package(X11) will much up on Windows.
find_package(X11)
# If we have pkg-config then we can use it:
find_package(PkgConfig)
if(COMPILE_WX_COMPONENT)
# Use find_package as first attempt, then pkg-config as fallback on this system.
# Try sudo apt-get install libwxgtk2.8-dev
find_package(wxWindows)
string(COMPARE EQUAL "${WX_CONFIG_LIBS}" "" WX_NOT_FOUND)
if (WX_NOT_FOUND)
# There's no way to find WX (pkg-config won't find this on my Ubuntu system)
message(FATAL_ERROR "You need WX windows. On Debian/Ubuntu try `sudo apt-get install libwxgtk2.8-dev`")
else()
if (WX_CONFIG_LIBS MATCHES .*gtk.*)
# all is well, seems to be a graphical wxwindows FIXME: May be different on Windows.
else()
message(FATAL_ERROR "You need graphical WX windows. On Debian/Ubuntu try `sudo apt-get install libwxgtk2.8-dev`")
endif()
# We know we have WX, so we should be able to exec wx-config to get
# the compiler flags: FIXME: Windows invocation will be different here.
execute_process(COMMAND wx-config --cxxflags
OUTPUT_VARIABLE BRAHMS_WX_CXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND wx-config --cflags
OUTPUT_VARIABLE BRAHMS_WX_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(WX_NOT_FOUND)
endif(COMPILE_WX_COMPONENT)
if(PKG_CONFIG_FOUND)
# There's no FindXaw script on my Ubuntu system. Can use pkg-config to check it's present:
pkg_check_modules(XAW REQUIRED xaw7)
if (XAW_FOUND)
# We have XAW_LDFLAGS XAW_INCLUDEDIR
find_path(BRAHMS_XAW_INCLUDE_DIR Xaw/XawInit.h HINTS ${XAW_INCLUDEDIR} ${XAW_INCLUDE_DIRS})
set(BRAHMS_XAW_LDFLAGS ${XAW_LDFLAGS})
else()
message(FATAL_ERROR "You need libXaw7. On Debian/Ubuntu try `sudo apt-get install libxaw7-dev`")
endif(XAW_FOUND)
endif()
# Apple/Unix require -lXmu, Windows won't. With the Xaw/X11 ldflags
# above, can do this very simple additional flag:
if(UNIX)
set(XMU_LDFLAG -lXmu)
else()
set(XMU_LDFLAG "")
endif()
endif()
# end of lib finding.