forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindGTS.cmake
191 lines (164 loc) · 5.24 KB
/
FindGTS.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
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
# Try to find gnu triangulation library GTS
# See
# http://gts.sf.net
#
# Once run this will define:
#
# GTS_FOUND = system has GTS lib
#
# GTS_LIBRARIES = full path to the libraries
# on Unix/Linux with additional linker flags from "gts-config --libs"
#
# CMAKE_GTS_CXX_FLAGS = Unix compiler flags for GTS, essentially "`gts-config --cxxflags`"
#
# GTS_INCLUDE_DIR = where to find headers
#
# GTS_LINK_DIRECTORIES = link directories, useful for rpath on Unix
# GTS_EXE_LINKER_FLAGS = rpath on Unix
#
#
# GTS modyfication by
# A.Khalatyan 05/2009
#
# www.aip.de/~arm2arm
#
# This script is based on GSL script by
# Felix Woelk 07/2004
# and Jan Woetzel
# www.mip.informatik.uni-kiel.de
# --------------------------------
if(GTS_FIND_REQUIRED)
set(_gts_output_type FATAL_ERROR)
set(_gts_output 1)
else()
set(_gts_output_type STATUS)
if(NOT GTS_FIND_QUIETLY)
set(_gts_output 1)
endif()
endif()
IF(WIN32)
# JW tested with gsl-1.8, Windows XP, MSVS 7.1, MSVS 8.0
SET(GTS_POSSIBLE_ROOT_DIRS
${GTS_ROOT_DIR}
$ENV{GTS_ROOT_DIR}
${GTS_DIR}
${GTS_HOME}
$ENV{GTS_DIR}
$ENV{GTS_HOME}
$ENV{EXTERN_LIBS_DIR}/gts
$ENV{EXTRA}
# "C:/home/arm2arm/SOFTWARE/gts-0.7.6"
)
FIND_PATH(GTS_INCLUDE_DIR
NAMES gts.h gtsconfig.h
PATHS ${GTS_POSSIBLE_ROOT_DIRS}
PATH_SUFFIXES include
DOC "GTS header include dir"
)
FIND_LIBRARY(GTS_GTS_LIBRARY
NAMES gts libgts
PATHS ${GTS_POSSIBLE_ROOT_DIRS}
PATH_SUFFIXES lib
DOC "GTS library dir" )
# FIND_LIBRARY(GTS_GLIB_LIBRARY
# NAMES glib libgslcblas
# PATHS ${GSL_POSSIBLE_ROOT_DIRS}
# PATH_SUFFIXES lib
# DOC "GSL cblas library dir" )
SET(GTS_LIBRARIES ${GTS_GTS_LIBRARY})
#MESSAGE("DBG\n"
# "GSL_GSL_LIBRARY=${GSL_GSL_LIBRARY}\n"
# "GSL_GSLCBLAS_LIBRARY=${GSL_GSLCBLAS_LIBRARY}\n"
# "GSL_LIBRARIES=${GSL_LIBRARIES}")
ELSE(WIN32)
IF(UNIX)
SET(GSL_CONFIG_PREFER_PATH
"$ENV{GTS_DIR}/bin"
"$ENV{GTS_DIR}"
"$ENV{GTS_HOME}/bin"
"$ENV{GTS_HOME}"
CACHE STRING "preferred path to GTS (gts-config)")
FIND_PROGRAM(GTS_CONFIG gts-config
${GTS_CONFIG_PREFER_PATH}
/work2/arm2arm/SOFTWARE/bin/
)
#MESSAGE("DBG GTS_CONFIG ${GTS_CONFIG}")
IF (GTS_CONFIG)
if(_gts_output)
MESSAGE(STATUS "GTS using gts-config ${GTS_CONFIG}")
endif()
# set CXXFLAGS to be fed into CXX_FLAGS by the user:
EXEC_PROGRAM(${GTS_CONFIG}
ARGS --cflags
OUTPUT_VARIABLE GTS_CXX_FLAGS )
#SET(GTS_CXX_FLAGS "`${GTS_CONFIG} --cflags`")
SET(CMAKE_GTS_CXX_FLAGS ${GTS_CXX_FLAGS})
# MESSAGE("DBG ${GTS_CXX_FLAGS}")
# set INCLUDE_DIRS to prefix+include
EXEC_PROGRAM(${GTS_CONFIG}
ARGS --prefix
OUTPUT_VARIABLE GTS_PREFIX)
SET(GTS_INCLUDE_DIR ${GTS_PREFIX}/include CACHE STRING INTERNAL)
# set link libraries and link flags
#SET(GSL_LIBRARIES "`${GSL_CONFIG} --libs`")
# extract link dirs for rpath
EXEC_PROGRAM(${GTS_CONFIG}
ARGS --libs
OUTPUT_VARIABLE GTS_CONFIG_LIBS )
SET(GTS_LIBRARIES "${GTS_CONFIG_LIBS}")
# split off the link dirs (for rpath)
# use regular expression to match wildcard equivalent "-L*<endchar>"
# with <endchar> is a space or a semicolon
STRING(REGEX MATCHALL "[-][L]([^ ;])+"
GTS_LINK_DIRECTORIES_WITH_PREFIX
"${GTS_CONFIG_LIBS}" )
# MESSAGE("DBG GSL_LINK_DIRECTORIES_WITH_PREFIX=${GSL_LINK_DIRECTORIES_WITH_PREFIX}")
# remove prefix -L because we need the pure directory for LINK_DIRECTORIES
IF (GTS_LINK_DIRECTORIES_WITH_PREFIX)
STRING(REGEX REPLACE "[-][L]" "" GTS_LINK_DIRECTORIES ${GTS_LINK_DIRECTORIES_WITH_PREFIX} )
ENDIF (GTS_LINK_DIRECTORIES_WITH_PREFIX)
SET(GTS_EXE_LINKER_FLAGS "-Wl,-rpath,${GTS_LINK_DIRECTORIES}" CACHE STRING INTERNAL)
# MESSAGE("DBG GSL_LINK_DIRECTORIES=${GSL_LINK_DIRECTORIES}")
# MESSAGE("DBG GSL_EXE_LINKER_FLAGS=${GSL_EXE_LINKER_FLAGS}")
# ADD_DEFINITIONS("-DHAVE_GSL")
# SET(GSL_DEFINITIONS "-DHAVE_GSL")
MARK_AS_ADVANCED(
GTS_CXX_FLAGS
GTS_INCLUDE_DIR
GTS_LIBRARIES
GTS_LINK_DIRECTORIES
GTS_DEFINITIONS
)
if(_gts_output)
MESSAGE(STATUS "Using GTS from ${GTS_PREFIX}")
endif()
ELSE(GTS_CONFIG)
INCLUDE(UsePkgConfig) #needed for PKGCONFIG(...)
if(_gts_output)
MESSAGE(STATUS "GSL using pkgconfig")
endif()
# PKGCONFIG(gsl includedir libdir linkflags cflags)
PKGCONFIG(gts GTS_INCLUDE_DIR GTS_LINK_DIRECTORIES GTS_LIBRARIES GTS_CXX_FLAGS)
IF(GTS_INCLUDE_DIR)
MARK_AS_ADVANCED(
GTS_CXX_FLAGS
GTS_INCLUDE_DIR
GTS_LIBRARIES
GTS_LINK_DIRECTORIES
)
ELSEIF(_gts_output)
MESSAGE(${_gts_output_type}
"FindGTS.cmake: gts-config/pkg-config gts not found. Please set it manually. GTS_CONFIG=${GTS_CONFIG}")
ENDIF()
ENDIF(GTS_CONFIG)
ENDIF(UNIX)
ENDIF(WIN32)
IF(GTS_LIBRARIES)
IF(GTS_INCLUDE_DIR OR GTS_CXX_FLAGS)
SET(GTS_FOUND 1)
ENDIF(GTS_INCLUDE_DIR OR GTS_CXX_FLAGS)
ENDIF(GTS_LIBRARIES)
# ==========================================
IF(NOT GTS_FOUND AND _gts_output)
MESSAGE(${_gts_output_type} "GTS was not found.")
ENDIF()