1313# For this, you need to have a complete casacore installation, built with shared
1414# libraries, at your disposal.
1515#
16- # The dependencies in this macro were generated against casacore release 1.7 .0.
16+ # The dependencies in this macro were generated against casacore release 2 .0.
1717#
1818# Variables used by this module:
1919# CASACORE_ROOT_DIR - Casacore root directory.
2424# CASACORE_FOUND - System has Casacore, which means that the
2525# include dir was found, as well as all
2626# libraries specified (not cached)
27+ # CASACORE_VERSION - Found version, e.g. "3.6.1" (not cached)
2728# CASACORE_INCLUDE_DIR - Casacore include directory (cached)
2829# CASACORE_INCLUDE_DIRS - Casacore include directories (not cached)
2930# identical to CASACORE_INCLUDE_DIR
@@ -112,13 +113,11 @@ endmacro(casacore_find_library _name)
112113# Usage: casacore_find_package(name [REQUIRED])
113114#
114115macro (casacore_find_package _name )
115- if ("${ARGN} " MATCHES "^REQUIRED$" AND
116- Casacore_FIND_REQUIRED AND
117- NOT CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL)
118- find_package (${_name} REQUIRED )
119- else ()
120- find_package (${_name} )
116+ set (_arg_list ${ARGN} )
117+ if (NOT Casacore_FIND_REQUIRED OR CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL)
118+ list (REMOVE_ITEM _arg_list "REQUIRED" )
121119 endif ()
120+ find_package (${_name} ${_arg_list} )
122121 if (${_name} _FOUND)
123122 list (APPEND CASACORE_INCLUDE_DIRS ${${_name} _INCLUDE_DIRS})
124123 list (APPEND CASACORE_LIBRARIES ${${_name} _LIBRARIES})
@@ -150,12 +149,12 @@ set(Casacore_coordinates_DEPENDENCIES fits measures casa)
150149set (Casacore_derivedmscal_DEPENDENCIES ms measures tables casa)
151150set (Casacore_fits_DEPENDENCIES measures tables casa)
152151set (Casacore_images_DEPENDENCIES coordinates mirlib lattices fits measures scimath tables casa)
153- set (Casacore_lattices_DEPENDENCIES scimath tables casa)
152+ set (Casacore_lattices_DEPENDENCIES tables scimath casa)
154153set (Casacore_meas_DEPENDENCIES measures tables casa)
155154set (Casacore_measures_DEPENDENCIES tables casa)
156155set (Casacore_mirlib_DEPENDENCIES)
157156set (Casacore_ms_DEPENDENCIES measures scimath tables casa)
158- set (Casacore_msfits_DEPENDENCIES ms fits measures scimath tables casa)
157+ set (Casacore_msfits_DEPENDENCIES ms fits measures tables casa)
159158set (Casacore_python3_DEPENDENCIES casa)
160159set (Casacore_scimath_DEPENDENCIES scimath_f casa)
161160set (Casacore_scimath_f_DEPENDENCIES)
@@ -166,6 +165,7 @@ set(CASACORE_FOUND FALSE)
166165set (CASACORE_DEFINITIONS)
167166set (CASACORE_LIBRARIES)
168167set (CASACORE_MISSING_COMPONENTS)
168+ set (CASACORE_VERSION)
169169
170170# Search for the header file first.
171171if (NOT CASACORE_INCLUDE_DIR)
@@ -209,7 +209,7 @@ else(NOT CASACORE_INCLUDE_DIR)
209209 foreach (_comp ${_find_components} )
210210 casacore_find_library (casa_${_comp} )
211211 if (${_comp} STREQUAL casa)
212- casacore_find_package (HDF5 )
212+ casacore_find_package (HDF5 COMPONENTS CXX )
213213 casacore_find_library (m )
214214 list (APPEND CASACORE_LIBRARIES ${CMAKE_DL_LIBS} )
215215 elseif (${_comp} STREQUAL coordinates)
@@ -242,6 +242,25 @@ if(CASACORE_FOUND)
242242 set (HAVE_AIPSPP TRUE CACHE INTERNAL "Define if AIPS++/Casacore is installed" )
243243endif (CASACORE_FOUND )
244244
245+ # Check version requirements
246+ file (WRITE ${CMAKE_BINARY_DIR} /casacore_version.cpp "#include <iostream>\n #include <casacore/casa/version.h>\n int main(int argc,char *argv[]) { std::cout << CASACORE_VERSION; return 0; }\n " )
247+ try_run (CASACORE_VERSION_RUN_RESULT CASACORE_VERSION_COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR} /casacore_version.cpp
248+ RUN_OUTPUT_VARIABLE CASACORE_VERSION
249+ COMPILE_DEFINITIONS "-I${CASACORE_INCLUDE_DIR} " )
250+ if (CASACORE_FOUND AND CASACORE_VERSION)
251+ if (Casacore_FIND_VERSION)
252+ if (Casacore_FIND_VERSION_EXACT)
253+ if (NOT CASACORE_VERSION VERSION_EQUAL Casacore_FIND_VERSION)
254+ message (FATAL_ERROR "Found Casacore version ${CASACORE_VERSION} , but EXACT version ${Casacore_FIND_VERSION} is required." )
255+ endif ()
256+ else ()
257+ if (CASACORE_VERSION VERSION_LESS Casacore_FIND_VERSION)
258+ message (FATAL_ERROR "Found Casacore version ${CASACORE_VERSION} , but at least version ${Casacore_FIND_VERSION} is required." )
259+ endif ()
260+ endif ()
261+ endif ()
262+ endif ()
263+
245264# Compose diagnostic message if not all necessary components were found.
246265if (CASACORE_MISSING_COMPONENTS)
247266 set (CASACORE_ERROR_MESSAGE "Casacore: the following components could not be found:\n ${CASACORE_MISSING_COMPONENTS} " )
@@ -250,7 +269,7 @@ endif(CASACORE_MISSING_COMPONENTS)
250269# Print diagnostics.
251270if (CASACORE_FOUND)
252271 if (NOT Casacore_FIND_QUIETLY)
253- message (STATUS "Found the following Casacore components: " )
272+ message (STATUS "Found Casacore (version ${CASACORE_VERSION} ) with the following components:" )
254273 foreach (_comp ${_find_components} )
255274 string (TOUPPER casa_${_comp} _COMP)
256275 message (STATUS " ${_comp} : ${${_COMP} _LIBRARY}" )
0 commit comments