diff --git a/CMakeLists.txt b/CMakeLists.txt index 22a5795e833d0c73367045777d56c5b4969292de..cceaf3cc385497a0ce53b79aba5cac6b2b29e745 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ add_subdirectory(Fit/Test/Minimizer) ## recurse into the given subdirectories -# BornAgain components are build as separate shared libraries +# BornAgain components are built as separate shared libraries set(CoreComponents "Base;Param;Sample;Device;Core") set(AllComponents "${CoreComponents};GUI") diff --git a/cmake/BornAgain/Dependences.cmake b/cmake/BornAgain/Dependences.cmake index a820e7da0560469996d81c2170354db636f61fe1..7abc04fb478b302b2d3ea5d908de9788f5ffd371 100644 --- a/cmake/BornAgain/Dependences.cmake +++ b/cmake/BornAgain/Dependences.cmake @@ -8,7 +8,7 @@ find_package(Threads REQUIRED) find_package(FFTW3 REQUIRED) find_package(GSL REQUIRED) -message(STATUS "GSL found=${GSL_FOUND} libs=${GSL_LIBRARIES} inc=${GSL_INCLUDE_DIR} version={GSL_VERSION}") +message(STATUS "GSL found=${GSL_FOUND} libs=${GSL_LIBRARIES} inc=${GSL_INCLUDE_DIR} version=${GSL_VERSION}") if(WIN32) set(EIGEN3_INCLUDE_DIR ${CMAKE_INCLUDE_PATH}) @@ -152,7 +152,7 @@ if(WIN32) set(DLL "${DIR}/cerfcpp.dll") if (NOT EXISTS ${DLL}) - message(FATAL_ERROR "Dynamic load library ${DLL} (needed for cerf) does not exist") + message(FATAL_ERROR "Dynamic link library ${DLL} (needed for cerf) does not exist") endif() install(FILES ${DLL} DESTINATION ${destination_lib} COMPONENT Libraries) message(STATUS "Cerf dll: ${DLL} - installed in ${destination_lib}") @@ -161,7 +161,7 @@ if(WIN32) foreach(LIB IN LISTS FFTW3_LIBRARIES TIFF_LIBRARIES) string(REPLACE ".lib" ".dll" DLL "${LIB}") if (NOT EXISTS ${DLL}) - message(FATAL_ERROR "Dynamic load library ${DLL} (derived from ${LIB}) does not exist") + message(FATAL_ERROR "Dynamic link library ${DLL} (derived from ${LIB}) does not exist") endif() install(FILES ${DLL} DESTINATION ${destination_lib} COMPONENT Libraries) string(APPEND DLL_MSG " ${DLL}") diff --git a/cmake/BornAgain/SwigLib.cmake b/cmake/BornAgain/SwigLib.cmake index f83a942e54c7c53b1b81eb561962d069f6fc274b..8495507f5abb54507c8e5ca21633058447a9ee0e 100644 --- a/cmake/BornAgain/SwigLib.cmake +++ b/cmake/BornAgain/SwigLib.cmake @@ -28,7 +28,7 @@ function(SwigLib name lib TMP_DIR) # Run Swig. # Please keep -Werror, in order not to overlook critical warnings. - # Dispensable warnings are disabled in Wrap/swig/warnigs.i. + # Dispensable warnings are disabled in Wrap/swig/warnings.i. # Joachim, oct20. set(SWIG_FLAGS "-c++;-python;-Werror;-o;${AUTO_DIR}/lib${lib}_wrap.cpp;-outdir;${TMP_DIR}" ";-I${CMAKE_SOURCE_DIR};-I${CMAKE_BINARY_DIR}/inc") diff --git a/cmake/find/FindCerf.cmake b/cmake/find/FindCerf.cmake index 67fc5f4f4eb30a3e04a667a9fc1ca6fc0ec2e02a..37c5567cff912b066a7ef453bdf1d163201f6ce6 100644 --- a/cmake/find/FindCerf.cmake +++ b/cmake/find/FindCerf.cmake @@ -32,32 +32,50 @@ find_package_handle_standard_args(Cerf REQUIRED_VARS Cerf_LIBRARIES Cerf_INCLUDE_DIR VERSION_VAR Cerf_VERSION) -if(NOT Cerf_FOUND) +# If CERF was found, then either it has been found because the C version is present and was freshly +# found, or because the variables have been found in the cache (which then can be because of +# a formerly found C or C++ version) +# If not found at this point, the C version has not been found and no cache variables exist +# => Search for the C++ version + +if(Cerf_FOUND) + # Either we freshly found the C version, which also means Cerf_IS_CPP is not present in the + # cache and we set it. Or we found any formerly found version (C or C++) from the cache, then + # Cerf_IS_CPP is also already in the cache and will not be changed by the following command + set(Cerf_IS_CPP OFF CACHE BOOL "Define whether CERF shall be used as C++") +else() + # C version not found and cache is empty => search for C++ version unset(Cerf_FOUND) unset(Cerf_LIBRARIES) find_library(Cerf_LIBRARIES NAMES cerfcpp) find_package_handle_standard_args(Cerf REQUIRED_VARS Cerf_LIBRARIES Cerf_INCLUDE_DIR VERSION_VAR Cerf_VERSION) - if(NOT Cerf_FOUND) - message(STATUS "libcerf: FOUND=${Cerf_FOUND}, VERSION=${Cerf_VERSION}, " - "LIB=${Cerf_LIBRARIES}, IS_CPP=${Cerf_IS_CPP}") - if(${Cerf_ULTIMATELY_REQUIRED}) - message(FATAL_ERROR "Found neither libcerf nor libcerfcpp") - endif() - message(STATUS "Found neither libcerf nor libcerfcpp") - return() - endif() - message(STATUS "Found libcerf, language=CPP, version=${Cerf_VERSION}, lib=${Cerf_LIBRARIES}," + if(Cerf_FOUND) + set(Cerf_IS_CPP ON CACHE BOOL "Define whether CERF shall be used as C++") + endif() +endif() + +# If still not found, then check whether it is ultimately required or not. +if(NOT Cerf_FOUND) + message(STATUS "libcerf: FOUND=${Cerf_FOUND}, VERSION=${Cerf_VERSION}, " + "LIB=${Cerf_LIBRARIES}, IS_CPP=${Cerf_IS_CPP}") + if(${Cerf_ULTIMATELY_REQUIRED}) + message(FATAL_ERROR "Found neither C nor C++ version of cerf") + endif() + message(STATUS "Found neither C nor C++ version of cerf") + return() +endif() + +if(Cerf_IS_CPP) + message(STATUS "Found libcerf, language=CPP, version=${Cerf_VERSION}, lib=${Cerf_LIBRARIES}," " include_dir=${Cerf_INCLUDE_DIR}.") - set(Cerf_IS_CPP ON) else() message(STATUS "Found libcerf, language=C, version=${Cerf_VERSION}, lib=${Cerf_LIBRARIES}," " include_dir=${Cerf_INCLUDE_DIR}.") - set(Cerf_IS_CPP OFF) endif() - -mark_as_advanced(Cerf_INCLUDE_DIR Cerf_LIBRARIES) + +mark_as_advanced(Cerf_INCLUDE_DIR Cerf_LIBRARIES Cerf_IS_CPP) include(AssertLibraryFunction) assert_library_function(Cerf cerf "")