1 | ###
|
---|
2 | # CMakeLists.txt for ASAP module
|
---|
3 | ###
|
---|
4 |
|
---|
5 | # minimum requirement for cmake version
|
---|
6 | cmake_minimum_required( VERSION 2.8 )
|
---|
7 |
|
---|
8 | # options
|
---|
9 | option( USE_LIBCASACORE
|
---|
10 | "set ON to use libcasacore.so instead of libcasa_*.so"
|
---|
11 | OFF )
|
---|
12 | option( STANDALONE
|
---|
13 | "set ON to build standalone mode"
|
---|
14 | OFF )
|
---|
15 | option( PKSMS
|
---|
16 | "set ON to diable to build PKSMS2reader/writer"
|
---|
17 | OFF )
|
---|
18 | message( STATUS "USE_LIBCASACORE = " ${USE_LIBCASACORE} )
|
---|
19 | message( STATUS "STANDALONE = " ${STANDALONE} )
|
---|
20 | message( STATUS "PKSMS = " ${PKSMS} )
|
---|
21 |
|
---|
22 | # Use casapy's fork of casacore
|
---|
23 | if ( NOT STANDALONE )
|
---|
24 | add_definitions( -DUSE_CASAPY )
|
---|
25 | endif ()
|
---|
26 |
|
---|
27 | # Define compiler paths on OSX 10.5. This must be done before invoking project()
|
---|
28 | if( APPLE )
|
---|
29 | if( EXISTS /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran )
|
---|
30 | set( CMAKE_Fortran_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran )
|
---|
31 | set( CMAKE_CXX_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/g++ )
|
---|
32 | elseif( EXISTS /opt/local/bin/gfortran )
|
---|
33 | set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran )
|
---|
34 | elseif( EXISTS /opt/local/bin/gfortran-mp-4.4 )
|
---|
35 | set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran-mp-4.4 )
|
---|
36 | if( EXISTS /opt/local/bin/g++-mp-4.4 )
|
---|
37 | set( CMAKE_CXX_COMPILER /opt/local/bin/g++-mp-4.4 )
|
---|
38 | endif()
|
---|
39 | endif()
|
---|
40 | endif()
|
---|
41 |
|
---|
42 |
|
---|
43 | # project name is ASAP
|
---|
44 | project( ASAP )
|
---|
45 |
|
---|
46 |
|
---|
47 | #
|
---|
48 | # build type and their flags
|
---|
49 | #
|
---|
50 | # CMAKE_BUILD_TYPE (Release, Debug, RelWithDebInfo, MinSizeRel, Profile)
|
---|
51 | # default is RelWithDebInfo
|
---|
52 | #
|
---|
53 | if ( NOT CMAKE_BUILD_TYPE )
|
---|
54 | set( CMAKE_BUILD_TYPE RelWithDebInfo )
|
---|
55 | endif()
|
---|
56 | message( STATUS "CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE} )
|
---|
57 |
|
---|
58 | # flags for Debug build
|
---|
59 | if ( CMAKE_BUILD_TYPE STREQUAL Debug )
|
---|
60 | add_definitions( -DAIPS_DEBUG )
|
---|
61 | endif()
|
---|
62 | set( CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -O0 -fno-omit-frame-pointer" )
|
---|
63 |
|
---|
64 | # flags for Profile build
|
---|
65 | set( CMAKE_CXX_FLAGS_PROFILE "-g -O2 -pg -fprofile-arcs -fno-omit-frame-pointer" )
|
---|
66 |
|
---|
67 | # flags for Release build
|
---|
68 | set( CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-s" )
|
---|
69 | set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-s" )
|
---|
70 |
|
---|
71 | # flags for MinSizeRel build
|
---|
72 | set( CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "-Wl,-s" )
|
---|
73 | set( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-Wl,-s" )
|
---|
74 |
|
---|
75 | if ( DEFINED CXX_FLAGS_TAIL_END )
|
---|
76 | set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CXX_FLAGS_TAIL_END}" )
|
---|
77 | set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CXX_FLAGS_TAIL_END}" )
|
---|
78 | set( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${CXX_FLAGS_TAIL_END}" )
|
---|
79 | set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CXX_FLAGS_TAIL_END}" )
|
---|
80 | set( CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} ${CXX_FLAGS_TAIL_END}" )
|
---|
81 | endif()
|
---|
82 |
|
---|
83 | # default flags
|
---|
84 | set( DEFAULT_CXX_FLAGS
|
---|
85 | "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment" )
|
---|
86 |
|
---|
87 | find_package( OpenMP )
|
---|
88 | if( OPENMP_FOUND )
|
---|
89 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
|
---|
90 | endif()
|
---|
91 |
|
---|
92 | # environment dependent settings
|
---|
93 | message( STATUS "CMAKE_SYSTEM = " ${CMAKE_SYSTEM} )
|
---|
94 | message( STATUS "CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
|
---|
95 | if( APPLE )
|
---|
96 | set( SO dylib )
|
---|
97 | if( CMAKE_SYSTEM MATCHES ^Darwin-10 OR
|
---|
98 | CMAKE_SYSTEM MATCHES ^Darwin-11 )
|
---|
99 | if( NOT archflag )
|
---|
100 | if( EXISTS /opt/casa/01 )
|
---|
101 | set( archflag x86_64 )
|
---|
102 | elseif( EXISTS /opt/casa/darwin11 )
|
---|
103 | set( archflag x86_64 )
|
---|
104 | elseif( EXISTS /opt/casa/darwin10-64b )
|
---|
105 | set( archflag x86_64 )
|
---|
106 | elseif( EXISTS /opt/casa/core2-apple-darwin10 )
|
---|
107 | set( archflag i386 )
|
---|
108 | else()
|
---|
109 | set( archflag x86_64 )
|
---|
110 | endif()
|
---|
111 | endif()
|
---|
112 | if( archflag STREQUAL x86_64 )
|
---|
113 | add_definitions( -DAIPS_64B )
|
---|
114 | endif()
|
---|
115 | execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version
|
---|
116 | COMMAND head -1
|
---|
117 | COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|"
|
---|
118 | OUTPUT_VARIABLE _cxx_version
|
---|
119 | OUTPUT_STRIP_TRAILING_WHITESPACE )
|
---|
120 | if( NOT _cxx_version STREQUAL "4.4" )
|
---|
121 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" )
|
---|
122 | endif()
|
---|
123 | endif()
|
---|
124 | elseif( CMAKE_SYSTEM_NAME STREQUAL Linux )
|
---|
125 | set( SO so )
|
---|
126 | add_definitions( -DAIPS_LINUX )
|
---|
127 | if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 )
|
---|
128 | add_definitions( -DAIPS_64B )
|
---|
129 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" )
|
---|
130 | else()
|
---|
131 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" )
|
---|
132 | endif()
|
---|
133 | endif()
|
---|
134 |
|
---|
135 | # set flags for cpp compiler
|
---|
136 | set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
|
---|
137 |
|
---|
138 |
|
---|
139 | #
|
---|
140 | # casacore definitions
|
---|
141 | #
|
---|
142 | set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
|
---|
143 | -DCASA_USECASAPATH
|
---|
144 | -DCASACORE_NEEDS_RETHROW
|
---|
145 | -DAIPS_STDLIB
|
---|
146 | -DAIPS_AUTO_STL
|
---|
147 | -D_GNU_SOURCE )
|
---|
148 |
|
---|
149 | if( CMAKE_SYSTEM_NAME STREQUAL Linux )
|
---|
150 | set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
|
---|
151 | -D_FILE_OFFSET_BITS=64
|
---|
152 | -D_LARGEFILE_SOURCE
|
---|
153 | )
|
---|
154 | endif()
|
---|
155 |
|
---|
156 | add_definitions( ${CASACORE_DEFINITIONS} )
|
---|
157 |
|
---|
158 | #
|
---|
159 | # mode specific settings
|
---|
160 | #
|
---|
161 | # STANDALONE=ON standalone build
|
---|
162 | # STANDALONE=OFF build with casa
|
---|
163 | #
|
---|
164 | set( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake" )
|
---|
165 | message( STATUS "CMAKE_MODULE_PATH = " ${CMAKE_MODULE_PATH} )
|
---|
166 | if( STANDALONE )
|
---|
167 | include( standalone )
|
---|
168 | else()
|
---|
169 | include( withcasa )
|
---|
170 | endif()
|
---|
171 |
|
---|
172 | message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
|
---|
173 |
|
---|
174 |
|
---|
175 | #
|
---|
176 | # casacore
|
---|
177 | #
|
---|
178 | unset( CASACORE_INCLUDE_DIR CACHE )
|
---|
179 | unset( CASACORE_LIBRARIES CACHE )
|
---|
180 | if( NOT USE_LIBCASACORE )
|
---|
181 | # use casacore libraries
|
---|
182 | set( _includename casa/aipsdef.h )
|
---|
183 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
---|
184 | PATHS ${CASACORE_PATHS}
|
---|
185 | PATH_SUFFIXES include include/casacore
|
---|
186 | NO_DEFAULT_PATH )
|
---|
187 | find_path( CASACORE_INCLUDE_DIR ${_includename} )
|
---|
188 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
189 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
---|
190 | endif()
|
---|
191 | set( CASACORE_LIBS casa
|
---|
192 | coordinates
|
---|
193 | fits
|
---|
194 | images
|
---|
195 | lattices
|
---|
196 | measures
|
---|
197 | mirlib
|
---|
198 | ms
|
---|
199 | msfits
|
---|
200 | scimath
|
---|
201 | scimath_f
|
---|
202 | tables )
|
---|
203 | set( _casacore_libs "" )
|
---|
204 | foreach( _a ${CASACORE_LIBS} )
|
---|
205 | set( _libname libcasa_${_a}.${SO} )
|
---|
206 | unset( _casacore_lib CACHE )
|
---|
207 | find_library( _casacore_lib ${_libname}
|
---|
208 | PATHS ${CASACORE_PATHS}
|
---|
209 | PATH_SUFFIXES lib64 lib )
|
---|
210 | if( _casacore_lib MATCHES "NOTFOUND$" )
|
---|
211 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
---|
212 | else()
|
---|
213 | #list( APPEND _casacore_libs casa_${_a} )
|
---|
214 | list( APPEND _casacore_libs ${_casacore_lib} )
|
---|
215 | endif()
|
---|
216 | endforeach()
|
---|
217 | set ( _libname libcomponents.${SO} )
|
---|
218 | unset( _casacore_lib CACHE )
|
---|
219 | find_library( _casacore_lib ${_libname}
|
---|
220 | PATHS ${CASACORE_PATHS}
|
---|
221 | PATH_SUFFIXES lib64 lib )
|
---|
222 | if( _casacore_lib MATCHES "NOTFOUND$" )
|
---|
223 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
---|
224 | else()
|
---|
225 | list( APPEND _casacore_libs ${_casacore_lib} )
|
---|
226 | endif()
|
---|
227 | set( CASACORE_LIBRARIES ${_casacore_libs} )
|
---|
228 | else()
|
---|
229 | # use libcasacore
|
---|
230 | set( _libname libcasacore.${SO} )
|
---|
231 | find_library( CASACORE_LIBRARIES ${_libname}
|
---|
232 | PATHS ${CASACORE_PATHS}
|
---|
233 | PATH_SUFFIXES lib64 lib )
|
---|
234 | if( CASACORE_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
235 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
---|
236 | endif()
|
---|
237 | set( _includename casa/aipsdef.h )
|
---|
238 | string( REGEX REPLACE /[^/]+/[^/]+/?$ "" _coreroot ${CASACORE_LIBRARIES} )
|
---|
239 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
---|
240 | PATHS ${_coreroot}
|
---|
241 | PATH_SUFFIXES include include/casacore
|
---|
242 | NO_DEFAULT_PATH )
|
---|
243 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
---|
244 | PATHS ${CASACORE_PATHS}
|
---|
245 | PATH_SUFFIXES include include/casacore
|
---|
246 | NO_DEFAULT_PATH )
|
---|
247 | find_path( CASACORE_INCLUDE_DIR ${_includename} )
|
---|
248 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
249 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
---|
250 | endif()
|
---|
251 | endif()
|
---|
252 | message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
|
---|
253 | message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
|
---|
254 | unset( USE_LIBCASACORE CACHE )
|
---|
255 |
|
---|
256 |
|
---|
257 | #
|
---|
258 | # Python
|
---|
259 | #
|
---|
260 | if( STANDALONE )
|
---|
261 | include( FindPythonLibs )
|
---|
262 | if( NOT PYTHONLIBS_FOUND )
|
---|
263 | message( FATAL_ERROR "Python could not be found. Please check!" )
|
---|
264 | endif()
|
---|
265 |
|
---|
266 | # Define pyroot
|
---|
267 | string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_INCLUDE_DIRS} )
|
---|
268 |
|
---|
269 | # find numpy
|
---|
270 | string( REGEX MATCH [0-9].[0-9] PYTHONV ${PYTHON_INCLUDE_DIRS} )
|
---|
271 | string( REPLACE "." "" PV ${PYTHONV} )
|
---|
272 | find_path( NUMPY_INCLUDE_DIR numpy/npy_interrupt.h
|
---|
273 | PATHS
|
---|
274 | ${pyroot}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
275 | ${pyroot}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
|
---|
276 | ${pyroot}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
277 | PATH_SUFFIXES include )
|
---|
278 | if( NUMPY_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
279 | message( FATAL_ERROR "numpy/npy_interrupt.h could not be found. Please check!" )
|
---|
280 | endif()
|
---|
281 | list( APPEND PYTHON_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR} )
|
---|
282 |
|
---|
283 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
|
---|
284 | -DPYTHONROOT=\"${pyroot}\"
|
---|
285 | -DPYTHONVER=\"${PYTHONV}\"
|
---|
286 | -DPYVERSION=${PV} )
|
---|
287 | else()
|
---|
288 | # with CASA
|
---|
289 | if( NOT PYTHON_FOUND )
|
---|
290 | if ( NOT PYTHON_LIBNAME )
|
---|
291 | #set( _names 2.9 2.8 2.7 2.6 2.5.2 2.5 )
|
---|
292 | set( _names 2.7 2.6 2.5.2 2.5 )
|
---|
293 | # OSX 10.7 has Python2.7 by default. CASA has't yet supported python > 2.6 anyway.
|
---|
294 | # (The library named libpython.2.5.2.dylib seems to exist only in the CASA world.)
|
---|
295 | else()
|
---|
296 | set( _names ${PYTHON_LIBNAME} )
|
---|
297 | endif()
|
---|
298 |
|
---|
299 | set( _found False )
|
---|
300 | foreach( _v ${_names} )
|
---|
301 |
|
---|
302 | casa_find(
|
---|
303 | PYTHON${_v}
|
---|
304 | #PREFIX_HINTS ${PYTHON_ROOT_DIR}
|
---|
305 | LIBS python${_v}
|
---|
306 | NO_REQUIRE
|
---|
307 | )
|
---|
308 |
|
---|
309 | if( PYTHON${_v}_FOUND )
|
---|
310 | set( PYTHON_LIBNAME ${_v} )
|
---|
311 | set( _found True )
|
---|
312 | break()
|
---|
313 | endif()
|
---|
314 |
|
---|
315 | endforeach()
|
---|
316 |
|
---|
317 | if( NOT _found )
|
---|
318 | message( FATAL_ERROR "Could not find any PYTHON library with version one of ${_names}. Please check!" )
|
---|
319 | endif()
|
---|
320 |
|
---|
321 | endif()
|
---|
322 |
|
---|
323 | if( NOT PYTHON_LIBNAME )
|
---|
324 | # Found Python, but PYTHON_LIBNAME is undefined, that is impossible.
|
---|
325 | message( FATAL_ERROR "The variable PYTHON_LIBNAME is undefined. Most likely, CMake's cache is out of date and you need to redetect your PYTHON installation (\"cmake -U PYTHON*\")")
|
---|
326 | endif()
|
---|
327 |
|
---|
328 | string( SUBSTRING ${PYTHON_LIBNAME} 0 3 PYTHONV )
|
---|
329 | string( REPLACE "." "" PV ${PYTHONV} )
|
---|
330 | set( python_library python${PYTHON_LIBNAME} )
|
---|
331 |
|
---|
332 | # Form the Python install prefix by stripping away "lib/libpython2.5.2.dylib" (example) from
|
---|
333 | # the full python library path
|
---|
334 | string( REGEX MATCH "/lib(64)?/lib${python_library}" _match ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
|
---|
335 | if( _match )
|
---|
336 | string( REGEX REPLACE "/lib(64)?/lib${python_library}.*" "" python_prefix ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
|
---|
337 | else()
|
---|
338 | # Python library was not in a lib(64) directory!
|
---|
339 | message( WARNING "Python library path \"${PYTHON${PYTHON_LIBNAME}_LIBRARIES}\" does not contain \"/lib(64)/lib${python_library}\"" )
|
---|
340 | set( python_prefix ${casa_packages} )
|
---|
341 | endif()
|
---|
342 |
|
---|
343 | #
|
---|
344 | # For some unknown reason cmake sets the /usr for Lion
|
---|
345 | #
|
---|
346 | if( APPLE )
|
---|
347 | set( python_prefix ${casa_packages} )
|
---|
348 | endif()
|
---|
349 |
|
---|
350 | # The python version and prefix is known, do the actual search
|
---|
351 | if( NOT PYTHON_FOUND )
|
---|
352 | message( STATUS "Looking for PYTHON version ${PYTHONV}.x in ${python_prefix}" )
|
---|
353 | endif()
|
---|
354 |
|
---|
355 | casa_find( PYTHON
|
---|
356 | VERSION 2.5 # minimum required
|
---|
357 | INCLUDES Python.h
|
---|
358 | numpy/npy_interrupt.h # for numpy
|
---|
359 | INCLUDES_SUFFIXES python${PYTHONV}
|
---|
360 | PREFIX_HINTS
|
---|
361 | ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
362 | ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
|
---|
363 | ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
364 | LIBS ${python_library}
|
---|
365 | CPP_VERSION PY_VERSION )
|
---|
366 |
|
---|
367 | # Store PYTHON_LIBNAME in the cache
|
---|
368 | set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
|
---|
369 |
|
---|
370 | # Define pyroot to two directory levels above Python.h.
|
---|
371 | string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
|
---|
372 |
|
---|
373 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
|
---|
374 | -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
|
---|
375 | -DAIPSARCH=\"${arch}\"
|
---|
376 | -DAIPSSITE=\"garching\"
|
---|
377 | -DPYTHONROOT=\"${pyroot}\"
|
---|
378 | -DPYTHONVER=\"${PYTHONV}\"
|
---|
379 | -DPYVERSION=${PV} )
|
---|
380 | endif()
|
---|
381 | message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} )
|
---|
382 | message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
|
---|
383 | message( STATUS "PYTHONV = " ${PYTHONV} )
|
---|
384 |
|
---|
385 |
|
---|
386 | #
|
---|
387 | # DL
|
---|
388 | #
|
---|
389 | set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE )
|
---|
390 | if( DL_LIBRARIES STREQUAL "dl" )
|
---|
391 | set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE )
|
---|
392 | endif()
|
---|
393 | message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} )
|
---|
394 |
|
---|
395 |
|
---|
396 | #
|
---|
397 | # BLAS
|
---|
398 | #
|
---|
399 | find_library( BLAS_LIBRARIES libblas.${SO} )
|
---|
400 | if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
401 | message( FATAL_ERROR "blas could not be found. Please check!" )
|
---|
402 | endif()
|
---|
403 | message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} )
|
---|
404 |
|
---|
405 |
|
---|
406 | #
|
---|
407 | # LAPACK
|
---|
408 | #
|
---|
409 | find_library( LAPACK_LIBRARIES liblapack.${SO} )
|
---|
410 | if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
411 | message( FATAL_ERROR "lapack could not be found. Please check!" )
|
---|
412 | endif()
|
---|
413 | message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} )
|
---|
414 |
|
---|
415 |
|
---|
416 | #
|
---|
417 | # Boost
|
---|
418 | #
|
---|
419 | set( boost_components python )
|
---|
420 | if( NOT STANDALONE )
|
---|
421 | set( boost_components ${boost_components} system )
|
---|
422 | endif()
|
---|
423 | find_package( Boost REQUIRED ${boost_components} )
|
---|
424 | if( NOT Boost_FOUND )
|
---|
425 | message( FATAL_ERROR "Boost could not be found. Please check!" )
|
---|
426 | endif()
|
---|
427 | message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
|
---|
428 | message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
|
---|
429 |
|
---|
430 |
|
---|
431 | #
|
---|
432 | # cfitsio
|
---|
433 | #
|
---|
434 | if( STANDALONE )
|
---|
435 | find_path( CFITSIO_INCLUDE_DIRS fitsio.h
|
---|
436 | PATH_SUFFIXES cfitsio )
|
---|
437 | if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
---|
438 | message( FATAL_ERROR "fitsio.h could not be found. Please check!" )
|
---|
439 | endif()
|
---|
440 | string( REGEX REPLACE "/[^/]+/?$" "" CFITSIO_ROOT ${CFITSIO_INCLUDE_DIRS} )
|
---|
441 | message( STATUS "CFITSIO_ROOT=" ${CFITSIO_ROOT} )
|
---|
442 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
---|
443 | PATHS ${CFITSIO_ROOT}
|
---|
444 | PATH_SUFFIXES lib64 lib
|
---|
445 | NO_DEFAULT_PATH )
|
---|
446 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
447 | find_library( CFITSIO_LIBRARIES libcfitsio.a
|
---|
448 | PATHS ${CFITSIO_ROOT}
|
---|
449 | PATH_SUFFIXES lib64 lib
|
---|
450 | NO_DEFAULT_PATH )
|
---|
451 | endif()
|
---|
452 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
---|
453 | PATHS /usr/local /usr
|
---|
454 | PATH_SUFFIXES lib64 lib )
|
---|
455 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
456 | message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" )
|
---|
457 | endif()
|
---|
458 | else()
|
---|
459 | casa_find( CFITSIO
|
---|
460 | VERSION 3.006
|
---|
461 | INCLUDES fitsio.h fitsio2.h
|
---|
462 | INCLUDES_SUFFIXES cfitsio
|
---|
463 | LIBS cfitsio
|
---|
464 | CPP_VERSION CFITSIO_VERSION
|
---|
465 | RUN_VERSION "(ffvers(&v), v)" )
|
---|
466 | endif()
|
---|
467 | message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
|
---|
468 | message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
|
---|
469 |
|
---|
470 |
|
---|
471 | #
|
---|
472 | # Fortran
|
---|
473 | #
|
---|
474 | if( NOT FORTRAN_LIBRARIES )
|
---|
475 |
|
---|
476 | message( STATUS "Looking for Fortran runtime libraries" )
|
---|
477 | set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc )
|
---|
478 | file( WRITE ${_try}
|
---|
479 | "int main() { return 0; }\n"
|
---|
480 | )
|
---|
481 |
|
---|
482 | execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-search-dirs
|
---|
483 | COMMAND perl -e "$found = 0; while(<>) { s|\n||g; if( m|^libraries:\\s*=(.*?$)| ) { foreach $d (split(':',$1) ) { if ( -e \"$d/libgfortran${CMAKE_SHARED_LIBRARY_SUFFIX}\" ) { print \"$d/libgfortran${CMAKE_SHARED_LIBRARY_SUFFIX}\"; $found = 1; break; }} break if $found; } break if $found;}"
|
---|
484 | OUTPUT_VARIABLE _gfortran_lib_path
|
---|
485 | OUTPUT_STRIP_TRAILING_WHITESPACE )
|
---|
486 |
|
---|
487 | if( _gfortran_lib_path )
|
---|
488 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
---|
489 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
|
---|
490 | )
|
---|
491 | else()
|
---|
492 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
---|
493 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
|
---|
494 | )
|
---|
495 | endif()
|
---|
496 | try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
|
---|
497 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
|
---|
498 | )
|
---|
499 |
|
---|
500 | if( _have_gfortran )
|
---|
501 | if( _gfortran_lib_path )
|
---|
502 | set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
|
---|
503 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
504 | else()
|
---|
505 | set( FORTRAN_LIBRARIES -lgfortran
|
---|
506 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
507 | endif()
|
---|
508 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
---|
509 | elseif( _have_g2c )
|
---|
510 | set( FORTRAN_LIBRARIES -lg2c
|
---|
511 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
512 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
---|
513 | else()
|
---|
514 | set( FORTRAN_LIBRARIES ""
|
---|
515 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
516 | message( STATUS "Looking for Fortran runtime libraries -- <none>" )
|
---|
517 | # Not a fatal error because it might work, if all Fortran dependencies were
|
---|
518 | # already linked statically to the Fortran runtime...
|
---|
519 | endif()
|
---|
520 | endif()
|
---|
521 |
|
---|
522 | # X11.
|
---|
523 | if( NOT APPLE )
|
---|
524 | find_package( X11 REQUIRED )
|
---|
525 | # Rename
|
---|
526 | set( X11_INCLUDE_DIRS ${X11_INCLUDE_DIR} )
|
---|
527 | endif()
|
---|
528 |
|
---|
529 | # PGPLOT (FORTRAN plotting package).
|
---|
530 | # depends on X11
|
---|
531 | # not require in standalone mode
|
---|
532 | if( NOT STANDALONE )
|
---|
533 | if( APPLE )
|
---|
534 | set( _deps FORTRAN )
|
---|
535 | else()
|
---|
536 | set( _deps X11 FORTRAN )
|
---|
537 | endif()
|
---|
538 | if (CMAKE_SYSTEM MATCHES ^Darwin-11 AND NOT LLVMCOMPILER )
|
---|
539 | set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit -lgfortran" )
|
---|
540 | else()
|
---|
541 | if (APPLE)
|
---|
542 | set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit" )
|
---|
543 | else()
|
---|
544 | set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error" )
|
---|
545 | endif()
|
---|
546 | endif()
|
---|
547 | casa_find( PGPLOT
|
---|
548 | VERSION 5.3.1
|
---|
549 | PREFIX_HINTS ${PGPLOT_ROOT_DIR}
|
---|
550 | INCLUDES cpgplot.h
|
---|
551 | LIBS pgplot${pgplot_ext} cpgplot${pgplot_ext}
|
---|
552 | DEPENDS ${_deps} )
|
---|
553 |
|
---|
554 | add_definitions( -DENABLE_PLOTTER2 )
|
---|
555 | endif()
|
---|
556 |
|
---|
557 | #
|
---|
558 | # RPFITS
|
---|
559 | #
|
---|
560 | if ( STANDALONE )
|
---|
561 | find_path( RPFITS_INCLUDE_DIRS RPFITS.h
|
---|
562 | PATHS /usr/local /usr
|
---|
563 | PATH_SUFFIXES include )
|
---|
564 | if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
---|
565 | message( FATAL_ERROR "RPFITS.h could not be found. Please check!" )
|
---|
566 | endif()
|
---|
567 | find_library( RPFITS_LIBRARIES librpfits.so
|
---|
568 | PATHS /usr/local /usr
|
---|
569 | PATH_SUFFIXES lib64 lib )
|
---|
570 | if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
571 | message( FATAL_ERROR "librpfits.so could not be found. Please check!" )
|
---|
572 | endif()
|
---|
573 | list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} )
|
---|
574 | else()
|
---|
575 | casa_find( RPFITS
|
---|
576 | VERSION 2.11
|
---|
577 | INCLUDES RPFITS.h
|
---|
578 | LIBS rpfits
|
---|
579 | RUN_VERSION names_.rpfitsversion
|
---|
580 | DEPENDS FORTRAN )
|
---|
581 | endif()
|
---|
582 | message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
|
---|
583 | message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
|
---|
584 |
|
---|
585 |
|
---|
586 | #
|
---|
587 | # wcslib
|
---|
588 | #
|
---|
589 | set( _wcslib libwcs.${SO} )
|
---|
590 | set( _wcs_version 4.3 )
|
---|
591 | find_library( WCSLIB ${_wcslib}
|
---|
592 | PATHS ${WCSLIB_PATHS}
|
---|
593 | PATH_SUFFIXES lib64 lib )
|
---|
594 | if( WCSLIB MATCHES "NOTFOUND$" )
|
---|
595 | message( STATUS "${_wcslib} could not be found." )
|
---|
596 | unset( _wcslib CACHE )
|
---|
597 | unset( WCSLIB CACHE )
|
---|
598 | set( _wcslib libwcs.${_wcs_version}.${SO} )
|
---|
599 | message( STATUS "Try to find ${_wcslib}..." )
|
---|
600 | find_library( WCSLIB ${_wcslib}
|
---|
601 | PATHS ${WCSLIB_PATHS}
|
---|
602 | PATH_SUFFIXES lib64 lib )
|
---|
603 | if( WCSLIB MATCHES "NOTFOUND$" )
|
---|
604 | message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
|
---|
605 | endif()
|
---|
606 | endif()
|
---|
607 | message( STATUS "WCSLIB = " ${WCSLIB} )
|
---|
608 | find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
|
---|
609 | PATHS ${WCSLIB_PATHS}
|
---|
610 | PATH_SUFFIXES include )
|
---|
611 | if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
612 | message( FATAL_ERROR "wcs.h could not be found. Please check!" )
|
---|
613 | endif()
|
---|
614 | message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
|
---|
615 |
|
---|
616 |
|
---|
617 | #
|
---|
618 | # common include path
|
---|
619 | #
|
---|
620 | include_directories( ${CASACORE_INCLUDE_DIR}
|
---|
621 | ${Boost_INCLUDE_DIR}
|
---|
622 | ${X11_INCLUDE_DIRS}
|
---|
623 | ${PGPLOT_INCLUDE_DIRS}
|
---|
624 | ${PYTHON_INCLUDE_DIRS}
|
---|
625 | ${WCSLIB_INCLUDE_DIR}
|
---|
626 | ${CFITSIO_INCLUDE_DIRS}
|
---|
627 | ${RPFITS_INCLUDE_DIRS} )
|
---|
628 |
|
---|
629 |
|
---|
630 | #
|
---|
631 | # install directory
|
---|
632 | #
|
---|
633 | set( EXEC_INSTALL_DIR bin )
|
---|
634 | set( LIB_INSTALL_DIR lib )
|
---|
635 | set( PYTHON_INSTALL_DIR python/${PYTHONV}/asap )
|
---|
636 | set( SHARED_INSTALL_DIR share/asap )
|
---|
637 |
|
---|
638 | #
|
---|
639 | # execute getsvnrev.sh to create/update svninfo.txt
|
---|
640 | # run chmod to make sure the script has executable
|
---|
641 | #
|
---|
642 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/getsvnrev.sh )
|
---|
643 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh )
|
---|
644 | exec_program( ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh ARGS ${ASAP_SOURCE_DIR})
|
---|
645 |
|
---|
646 | # Add the modules to be built.
|
---|
647 | #
|
---|
648 | # Choose to have correct RPATHs both in the build tree and
|
---|
649 | # in the install tree (at the cost of having to change the
|
---|
650 | # rpath when installing)
|
---|
651 | #
|
---|
652 | set( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib )
|
---|
653 | set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
---|
654 | set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib )
|
---|
655 |
|
---|
656 | #
|
---|
657 | # PKSMS
|
---|
658 | #
|
---|
659 | if ( NOT PKSMS )
|
---|
660 | add_definitions( -DNOPKSMS )
|
---|
661 | endif()
|
---|
662 |
|
---|
663 | #
|
---|
664 | # libraries and executables
|
---|
665 | #
|
---|
666 | set( ASAPPYLIB _asap )
|
---|
667 | set( ASAPLIB asap )
|
---|
668 | set( PYRAPLIB pyrap )
|
---|
669 | set( ATNFLIB atnf )
|
---|
670 | set( ASAP2TO3 asap2to3 )
|
---|
671 | if ( NOT STANDALONE )
|
---|
672 | # set( ASDM2ASAP_OLD oldasdm2ASAP )
|
---|
673 | set( ASDM2ASAP asdm2ASAP )
|
---|
674 | endif()
|
---|
675 |
|
---|
676 | #
|
---|
677 | # always install by default
|
---|
678 | #
|
---|
679 | add_custom_target( inst ALL ${CMAKE_BUILD_TOOL} install/fast )
|
---|
680 |
|
---|
681 | #
|
---|
682 | # subdirectories
|
---|
683 | #
|
---|
684 | asap_add_subdirectory()
|
---|