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