some more work towards modern cmake

This commit is contained in:
suter_a 2018-05-03 15:29:13 +02:00
parent b840bd022b
commit f7ccf79fa8
4 changed files with 182 additions and 24 deletions

View File

@ -12,6 +12,9 @@ option(qt_based_tools "try to install Qt based tools" ON)
#--- check for all the needed packages ----------------------------------------------------------
#--- add path to my own find modules and other stuff
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
#--- check for git ------------------------------------------------------------------------------
find_package(Git REQUIRED)
@ -32,9 +35,7 @@ find_package(Boost REQUIRED)
find_package(GSL REQUIRED)
#--- check for fftw3 ----------------------------------------------------------------------------
#[==[ // needs to be written by as35
find_package(FFTW3 REQUIRED)
#]==]
#--- check for libxml2 --------------------------------------------------------------------------
find_package(LibXml2 REQUIRED)
@ -52,34 +53,23 @@ if (qt_based_tools)
# Find the QtXml library
find_package(Qt5Xml)
# only temporarily needed for debug //as35
if (Qt5Core_FOUND)
message("-- Found Qt5Core")
endif (Qt5Core_FOUND)
if (Qt5Widgets_FOUND)
message("-- Found Qt5Widgets")
endif (Qt5Widgets_FOUND)
if (Qt5Xml_FOUND)
message("-- Found Qt5Xml")
endif (Qt5Xml_FOUND)
# if Qt5 is not found, try Qt4
if (NOT Qt5Core_FOUND)
find_package(Qt4 COMPONENTS QtGui QtWebKit QtXml)
message("Qt4 found: ${Qt4_FOUND} //as35")
endif (NOT Qt5Core_FOUND)
# if Qt5 and Qt4 is not found try Qt3. Hopefully you never reach this point
if (NOT Qt4_FOUND AND NOT Qt5_FOUND)
find_package(Qt3)
message("Qt3 found: ${QT_FOUND} //as35")
endif (NOT Qt4_FOUND AND NOT Qt5_FOUND)
if (NOT Qt5Core_FOUND)
if (NOT Qt4_FOUND)
find_package(Qt3)
endif (NOT Qt4_FOUND)
endif (NOT Qt5Core_FOUND)
endif (qt_based_tools)
#--- if NeXus check also for HDF4, HDF5, and MXML -----------------------------------------------
if (nexus)
find_package(HDF5 REQUIRED)
find_package(HDF4 REQUIRED)
find_package(HDF5 COMPONENTS CXX REQUIRED )
#//as35 - STILL NEEDED?? -> find_package(HDF4 REQUIRED)
find_package(MXML REQUIRED)
find_package(NeXus REQUIRED)
endif (nexus)
@ -106,7 +96,7 @@ message("")
message(" Requirements:")
message(" -------------")
message("")
message(" FFTW3 found in //as35 STILL MISSING")
message(" FFTW3 found in ${FFTW3_INCLUDE_DIR}")
message(" GSL found in ${GSL_INCLUDE_DIRS}")
message(" BOOST found in ${Boost_INCLUDE_DIRS}")
message(" LibXML2 found in ${LIBXML2_INCLUDE_DIR}")
@ -114,9 +104,9 @@ message(" ROOT found in ${ROOT_INCLUDE_DIRS}")
if (nexus)
message("")
message(" HDF4 found in ${HDF4_INCLUDE_DIRS}")
#//as35 message(" HDF4 found in ${HDF4_INCLUDE_DIRS}")
message(" HDF5 found in ${HDF5_INCLUDE_DIRS}")
message(" NeXus found in //as35 STILL MISSING")
message(" NeXus found in ${NEXUS_INCLUDE_DIR}")
endif (nexus)
if (BMWlibs)
@ -125,7 +115,7 @@ if (BMWlibs)
endif (BMWlibs)
message("")
message(" Qt found in ${Qt5Core_INCLUDE_DIRS} (Version: ${Qt5Core_VERSION})")
message(" Qt found in ${Qt5Core_INCLUDE_DIRS} (Version: ${Qt5Core_VERSION})")
message("")
message(" Features:")
message(" ---------")

89
cmake/FindFFTW3.cmake Normal file
View File

@ -0,0 +1,89 @@
# - Find fftw3 library
# Find the native FFTW3 includes and library
# This module defines
# FFTW3_INCLUDE_DIR, where to find fftw3.h, etc.
# ---
# FFTW3_LIBRARY, library to link against to use FFTW3
# FFTW3_OMP_LIBRARY, library to link against to use FFTW3_omp
# FFTW3_THREADS_LIBRARY, library to link against to use FFTW3_threads
# FFTW3_FOUND, if false, do not try to use FFTW3.
# ---
# FFTW3L_LIBRARY, library to link against to use FFTW3l
# FFTW3L_OMP_LIBRARY, library to link against to use FFTW3l_omp
# FFTW3L_THREADS_LIBRARY, library to link against to use FFTW3l_threads
# FFTW3L_FOUND, if false, do not try to use FFTW3l.
# ---
# FFTW3F_LIBRARY, library to link against to use FFTW3f
# FFTW3F_OMP_LIBRARY, library to link against to use FFTW3f_omp
# FFTW3F_THREADS_LIBRARY, library to link against to use FFTW3f_threads
# FFTW3F_FOUND, if false, do not try to use FFTW3f.
# ---
# FFTW3Q_LIBRARY, library to link against to use FFTW3q
# FFTW3Q_OMP_LIBRARY, library to link against to use FFTW3q_omp
# FFTW3Q_THREADS_LIBRARY, library to link against to use FFTW3q_threads
# FFTW3Q_FOUND, if false, do not try to use FFTW3q.
find_path(FFTW3_INCLUDE_DIR fftw3.h
HINTS "/usr/include" "/opt/local/include"
)
# find position of fftw3.h from the end
string(FIND "${FFTW3_INCLUDE_DIR}" "/fftw3.h" pos REVERSE)
# truncate the string
string(SUBSTRING "${FFTW3_INCLUDE_DIR}" 0 ${pos} substr)
set(FFTW3_INCLUDE_DIR ${substr})
unset(substr)
find_library(FFTW3_LIBRARY fftw3)
find_library(FFTW3_OMP_LIBRARY fftw3_omp)
find_library(FFTW3_THREAD_LIBRARY fftw3_threads)
find_library(FFTW3L_LIBRARY fftw3l)
find_library(FFTW3L_OMP_LIBRARY fftw3l_omp)
find_library(FFTW3L_THREAD_LIBRARY fftw3l_threads)
find_library(FFTW3F_LIBRARY fftw3f)
find_library(FFTW3F_OMP_LIBRARY fftw3f_omp)
find_library(FFTW3F_THREAD_LIBRARY fftw3f_threads)
find_library(FFTW3Q_LIBRARY fftw3q)
find_library(FFTW3Q_OMP_LIBRARY fftw3q_omp)
find_library(FFTW3Q_THREAD_LIBRARY fftw3q_threads)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(FFTW3
REQUIRED_VARS FFTW3_LIBRARY FFTW3_INCLUDE_DIR
VERSION_VAR "3")
find_package_handle_standard_args(FFTW3L
REQUIRED_VARS FFTW3L_LIBRARY FFTW3_INCLUDE_DIR
VERSION_VAR "3")
find_package_handle_standard_args(FFTW3F
REQUIRED_VARS FFTW3F_LIBRARY FFTW3_INCLUDE_DIR
VERSION_VAR "3")
find_package_handle_standard_args(FFTW3Q
REQUIRED_VARS FFTW3Q_LIBRARY FFTW3_INCLUDE_DIR
VERSION_VAR "3")
if (NOT FFTW3_FOUND)
unset(FFTW3_LIBRARY)
endif()
if (NOT FFTW3L_FOUND)
unset(FFTW3L_LIBRARY)
endif()
if (NOT FFTW3F_FOUND)
unset(FFTW3F_LIBRARY)
endif()
if (NOT FFTW3Q_FOUND)
unset(FFTW3Q_LIBRARY)
endif()
mark_as_advanced(
FFTW3_INCLUDE_DIR
FFTW3_LIBRARY FFTW3_OMP_LIBRARY FFTW3_THREAD_LIBRARY
FFTW3L_LIBRARY FFTW3L_OMP_LIBRARY FFTW3L_THREAD_LIBRARY
FFTW3F_LIBRARY FFTW3F_OMP_LIBRARY FFTW3F_THREAD_LIBRARY
FFTW3Q_LIBRARY FFTW3Q_OMP_LIBRARY FFTW3Q_THREAD_LIBRARY
)
if (FFTW3_FOUND)
message("-- Found FFTW3: ${FFTW3_INCLUDE_DIR}")
endif (FFTW3_FOUND)

34
cmake/FindMXML.cmake Normal file
View File

@ -0,0 +1,34 @@
# - find MXML
# find the MXML lib and includes
# This module defines
# LIBMXML_INCLUDE_DIR, where to find mxml.h
# LIBMXML_LIBRARY, library to link against
# LIBMXML_FOUND, if false, do not try to use the MXML lib
find_path(LIBMXML_INCLUDE_DIR mxml.h
HINT "/usr/include"
)
# find position of mxml.h from the end
string(FIND "${LIBMXML_INCLUDE_DIR}" "/mxml.h" pos REVERSE)
# truncate the string
string(SUBSTRING "${LIBMXML_INCLUDE_DIR}" 0 ${pos} substr)
set(LIBMXML_INCLUDE_DIR ${substr})
unset(substr)
find_library(LIBMXML_LIBRARY mxml)
# get version string
# currently do not know from where to get it automatically
# handle the QUIETLY and REQUIRED arguments and set LIBMXML_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MXML
REQUIRED_VARS LIBMXML_LIBRARY LIBMXML_INCLUDE_DIR)
if (NOT LIBMXML_FOUND)
unset(LIBMXML_LIBRARY)
endif()
mark_as_advanced(LIBMXML_INCLUDE_DIR LIBMXML_LIBRARY)

45
cmake/FindNeXus.cmake Normal file
View File

@ -0,0 +1,45 @@
# - Find NeXus library
# Find the native NEXUS includes and library
# This module defines
# NEXUS_INCLUDE_DIR, where to find NeXus.h, etc.
# NEXUS_LIBRARY, library to link against to use NEXUS
# NEXUS_FOUND, if false, do not try to use NEXUS.
find_path(NEXUS_INCLUDE_DIR napi.h
HINTS "/usr/local/include" "/opt/nexus/include" "/usr/local/include/nexus"
)
# find position of napi.h from the end
string(FIND "${NEXUS_INCLUDE_DIR}" "/napi.h" pos REVERSE)
# truncate the string
string(SUBSTRING "${NEXUS_INCLUDE_DIR}" 0 ${pos} substr)
set(NEXUS_INCLUDE_DIR ${substr})
unset(substr)
find_library(NEXUS_LIBRARY NeXus
HINTS "/usr/lib" "/usr/lib64" "/usr/local/lib" "/usr/local/lib64" "/opt/nexus/lib")
# get version string
if (NEXUS_INCLUDE_DIR AND EXISTS ${NEXUS_INCLUDE_DIR}/napi.h)
file(STRINGS "${NEXUS_INCLUDE_DIR}/napi.h" NEXUS_version_str
REGEX "^#define[\t ]+NEXUS_VERSION[\t ].*")
string(REGEX REPLACE "^#define[\t ]+NEXUS_VERSION[\t ]+\"([^\"]*).*"
"\\1" NEXUS_VERSION_STRING "${NEXUS_version_str}")
unset(NEXUS_version_str)
endif()
# handle the QUIETLY and REQUIRED arguments and set NEXUS_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NEXUS
REQUIRED_VARS NEXUS_LIBRARY NEXUS_INCLUDE_DIR
VERSION_VAR NEXUS_VERSION_STRING)
if (NOT NEXUS_FOUND)
unset(NEXUS_LIBRARY)
endif()
mark_as_advanced(NEXUS_INCLUDE_DIR NEXUS_LIBRARY)