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