Newer
Older
# Search for installed software required by BornAgain
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .dll.a .lib)
endif()
message(STATUS "LibHeinz: found=${LibHeinz_FOUND}, include_dirs=${LibHeinz_INCLUDE_DIR}, "
"version=${LibHeinz_VERSION}")
#message(STATUS "formfactor: found=${formfactor_FOUND}, version=${formfactor_VERSION}")
message(STATUS "GSL found=${GSL_FOUND} libs=${GSL_LIBRARIES} inc=${GSL_INCLUDE_DIR} version=${GSL_VERSION}")
set(EIGEN3_INCLUDE_DIR ${CMAKE_INCLUDE_PATH})
message(STATUS "Eigen3 include_dir=${EIGEN3_INCLUDE_DIR}(hard-coded)")
find_package(Eigen3 3.3 REQUIRED)
message(STATUS "Eigen3 include_dir=${EIGEN3_INCLUDE_DIR} version=${EIGEN3_VERSION_STRING}")
Pospelov, Gennady
committed
t.knopff
committed
if(NOT Cerf_IS_CPP)
message(STATUS "Compiling test program to determine additional libcerf flags")
t.knopff
committed
try_compile(COMPILE_OK
"${CMAKE_BINARY_DIR}/temp"
"${CMAKE_SOURCE_DIR}/cmake/tests/test_libcerf.cpp"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${Cerf_INCLUDE_DIR};${CMAKE_SOURCE_DIR}"
LINK_LIBRARIES ${Cerf_LIBRARIES}
OUTPUT_VARIABLE COMPILE_OUT)
if(NOT COMPILE_OK)
try_compile(COMPILE_OK
"${CMAKE_BINARY_DIR}/temp"
"${CMAKE_SOURCE_DIR}/cmake/tests/test_libcerf.cpp"
COMPILE_DEFINITIONS "-DLIBCERF_WITHOUT_TYPEDEF"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${Cerf_INCLUDE_DIR};${CMAKE_SOURCE_DIR}"
if(COMPILE_OK)
add_definitions("-DLIBCERF_WITHOUT_TYPEDEF")
else()
message(FATAL_ERROR "Compilation of libcerf test program failed with "
"the following output:\n" "${COMPILE_OUT}\n")
endif()
t.knopff
committed
endif()
endif()
if(Cerf_IS_CPP)
add_compile_definitions(CERF_AS_CPP=ON)
endif()
set(Boost_NO_BOOST_CMAKE ON) # prevent shortcut
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
Pospelov, Gennady
committed
add_definitions(-DBOOST_ALL_DYN_LINK) # line is needed for MSVC
add_definitions(-DBOOST_UUID_FORCE_AUTO_LINK) # line is needed to link bcrypt for MSVC
# amends problems with bimap and MSVC, serialization of bimap is currently not needed
add_definitions(-DBOOST_BIMAP_DISABLE_SERIALIZATION)
# Boost component libraries (do not list headers here)
set(boost_libraries_required iostreams program_options)
# NOTE: `FindBoost` CMake module internally adds Boost::regex as an extra dependency for Boost::iostream
# On Windows, additional libaries are required for Boost::iostream
list(APPEND boost_libraries_required zlib bzip2)
message(STATUS "Boost required libraries: ${boost_libraries_required}")
find_package(Boost 1.65.1 COMPONENTS ${boost_libraries_required})
message(STATUS "Boost: includes at ${Boost_INCLUDE_DIRS}, libraries at ${Boost_LIBRARY_DIRS}")
message(STATUS "Boost libraries: ${Boost_LIBRARIES}; ${Boost_Additional_Libraries}")
if(NOT Boost_FOUND)
message(FATAL_ERROR "Not all required Boost component libraries were found")
# === optional packages ===
Van Herck, Walter
committed
# --- MPI support ---
if(BORNAGAIN_MPI)
message(STATUS "Configuring with MPI support")
Van Herck, Walter
committed
message(STATUS "MPI_CXX_INCLUDE_PATH: ${MPI_CXX_INCLUDE_PATH}")
message(STATUS "MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
if(BORNAGAIN_TIFF_SUPPORT)

Wuttke, Joachim
committed
message(STATUS "Looking for libtiff (use -DBORNAGAIN_TIFF_SUPPORT=OFF to disable)")
find_package(TIFF 4.0.2 REQUIRED COMPONENTS CXX)
endif()
find_package(Python3 COMPONENTS Interpreter Development)

Wuttke, Joachim
committed
if(NOT Python3_FOUND)
message(FATAL_ERROR "Python3 not found.")
endif()
message(STATUS " Python3_VERSION : ${Python3_VERSION}")
message(STATUS " Python3_INTERPRETER_ID : ${Python3_INTERPRETER_ID}")
message(STATUS " Python3_EXECUTABLE : ${Python3_EXECUTABLE}")
message(STATUS " Python3_STDLIB : ${Python3_STDLIB} Python3_STDARCH: ${Python3_STDARCH}")
message(STATUS " Python3_SITELIB : ${Python3_SITELIB} Python3_SITEARCH: ${Python3_SITEARCH}")
message(STATUS " Python3_INCLUDE_DIRS : ${Python3_INCLUDE_DIRS}")
message(STATUS " Python3_LIBRARIES : ${Python3_LIBRARIES}")
message(STATUS " Python3_LIBRARY_DIRS : ${Python3_LIBRARY_DIRS}")
Van Herck, Walter
committed

Wuttke, Joachim
committed
find_package(Python3 COMPONENTS Interpreter)

Wuttke, Joachim
committed
message(FATAL_ERROR "Python3 interpreter not found.")
Pospelov, Gennady
committed

Wuttke, Joachim
committed
find_package(Python3 COMPONENTS Interpreter Development)

Wuttke, Joachim
committed
message(FATAL_ERROR
"Python.h not found. Probably you need to install package libpython3-dev (or similar).")
Pospelov, Gennady
committed

Wuttke, Joachim
committed
find_package(Python3 COMPONENTS Interpreter Development NumPy)

Wuttke, Joachim
committed
message(FATAL_ERROR "Python3-NumPy not found.")

Wuttke, Joachim
committed
message(STATUS " Python3_NumPy_VERSION : ${Python3_NumPy_VERSION}")
message(STATUS " Python3_NumPy_INCLUDE_DIRS : ${Python3_NumPy_INCLUDE_DIRS}")
if(CONFIGURE_BINDINGS)
find_package(SWIG 4.0 REQUIRED)
include(${SWIG_USE_FILE})
message(STATUS "Found SWIG version ${SWIG_VERSION} at ${SWIG_EXECUTABLE} with flags '${SWIG_FLAGS}'; CMake definitions in ${SWIG_USE_FILE}")
if(CONFIGURE_PYTHON_DOCS)
find_package(Doxygen REQUIRED)
endif()
endif()
endif()
# --- man page generation ---
if(CONFIGURE_MANPAGE)
find_program(POD2MAN pod2man)
message(FATAL_ERROR "FATAL: cannot satisfy CONFIGURE_MANPAGE: pod2man not found")
message(STATUS "Found pod2man: ${POD2MAN}")
Jonathan Fisher
committed
endif()
# === install Windows DLLs ===
if(WIN32)
# The list ${Boost_LIBRARIES} can contain either only dll names (if e.g. debug dlls are
# not found), or keyword/dll pairs (if debug and release dlls have been found). This has
# to be taken care of in the iteration over the list.
# debug DLLs are ignored for installation
message(STATUS "Installation of Boost libraries:")
set(entryShallBeSkipped false)
foreach(Boost_lib ${Boost_LIBRARIES})
if(entryShallBeSkipped)
set(entryShallBeSkipped false)
continue()
endif()
if(${Boost_lib} STREQUAL "debug")
set(entryShallBeSkipped true)
continue()
endif()
if(${Boost_lib} STREQUAL "optimized")
set(entryShallBeSkipped false)
continue()
endif()
get_filename_component(UTF_BASE_NAME ${Boost_lib} NAME_WE)
get_filename_component(UTF_PATH ${Boost_lib} PATH)
install(FILES ${UTF_PATH}/${UTF_BASE_NAME}.dll
DESTINATION ${destination_lib} COMPONENT Libraries
CONFIGURATIONS [Release|MinSizeRel|RelWithDebInfo])
message(" ${UTF_PATH}/${UTF_BASE_NAME}.dll - will be installed in ${destination_lib}")
endforeach()
## Libraries needed in addition (for boost)
message(STATUS "Installation of libraries needed in addition to Boost:")
foreach(lib ${Boost_Additional_Libraries})
get_filename_component(UTF_BASE_NAME ${lib} NAME_WE)
get_filename_component(UTF_PATH ${lib} PATH)
install(FILES ${UTF_PATH}/${UTF_BASE_NAME}.dll
DESTINATION ${destination_lib} COMPONENT Libraries
CONFIGURATIONS [Release|MinSizeRel|RelWithDebInfo])
message(" ${UTF_PATH}/${UTF_BASE_NAME}.dll - will be installed in ${destination_lib}")
set(win_python_lib
"${Python3_LIBRARY_DIRS}/python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}.lib")
get_filename_component(UTF_BASE_NAME ${win_python_lib} NAME_WE)
get_filename_component(UTF_PATH ${Python3_EXECUTABLE} PATH)
message(STATUS "Python dll: ${UTF_PATH}/${UTF_BASE_NAME}.dll"
" - will be installed in ${destination_lib}")
install(FILES ${UTF_PATH}/${UTF_BASE_NAME}.dll
DESTINATION ${destination_lib} COMPONENT Libraries
CONFIGURATIONS [Release|MinSizeRel|RelWithDebInfo])
set(Cerf_LIB ${Cerf_LIBRARIES}) # we take for granted that there is only one cerf.lib
get_filename_component(DIR ${Cerf_LIB} DIRECTORY)
get_filename_component(cerf ${Cerf_LIB} NAME_WE)
if(NOT EXISTS ${Cerf_DLL})
message(FATAL_ERROR "Dynamic link library ${Cerf_DLL} (needed for cerf) does not exist")
install(FILES ${Cerf_DLL} DESTINATION ${destination_lib} COMPONENT Libraries)
message(STATUS "Cerf dll: ${Cerf_DLL} - will be installed in ${destination_lib}")
## FFTW3
message(STATUS "Installation of FFTW3:")
foreach(lib ${FFTW3_LIBRARIES})
get_filename_component(UTF_BASE_NAME ${lib} NAME_WE)
get_filename_component(UTF_PATH ${lib} PATH)
install(FILES ${UTF_PATH}/${UTF_BASE_NAME}.dll
DESTINATION ${destination_lib} COMPONENT Libraries
CONFIGURATIONS [Release|MinSizeRel|RelWithDebInfo])
message(" ${UTF_PATH}/${UTF_BASE_NAME}.dll - will be installed in ${destination_lib}")
if(BORNAGAIN_TIFF_SUPPORT)
## Same as for Boost above: list can contain
# mixture of debug/optimized libs
message(STATUS "Installation of TIFF:")
set(entryShallBeSkipped false)
foreach(LIB ${TIFF_LIBRARIES})
if(entryShallBeSkipped)
set(entryShallBeSkipped false)
continue()
endif()
if(${LIB} STREQUAL "debug")
set(entryShallBeSkipped true)
continue()
endif()
if(${LIB} STREQUAL "optimized")
set(entryShallBeSkipped false)
continue()
endif()
get_filename_component(UTF_NAME ${LIB} NAME)
if(${UTF_NAME} STREQUAL "tiff.lib")
message(" No installation for ${UTF_NAME}: This is the static TIFF library")
continue()
endif()
string(REPLACE ".lib" ".dll" DLL "${LIB}")
if(NOT EXISTS ${DLL})
message(FATAL_ERROR
"Dynamic link library ${DLL} (derived from ${LIB}) does not exist")
endif()
install(FILES ${DLL} COMPONENT Libraries
DESTINATION ${destination_lib}
CONFIGURATIONS [Release|MinSizeRel|RelWithDebInfo])
message(" ${DLL} - will be installed in ${destination_lib}")
endforeach()
endif()