diff --git a/CMakeLists.txt b/CMakeLists.txt index d4107e8fa..07e2177e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,121 +231,13 @@ ecbuild_info("") # ========================================================================================= include(Dependencies) -# ========================================================================================= -# Dependency: Boost -# ========================================================================================= -message( STATUS "====================================================================================================================" ) -message( STATUS "BOOST" ) -# this can help in some situations: -set (_CMAKE_PREFIX_PATH_BACKUP ${CMAKE_PREFIX_PATH}) # make a backup of CMAKE_PREFIX_PATH -foreach(BOOST_PATH_TO_SEARCH ${BOOST_PATH} ${BOOST_ROOT} $ENV{BOOST_ROOT}) - ecbuild_debug("adding: ${BOOST_PATH_TO_SEARCH} to CMAKE_PREFIX_PATH") - list(APPEND CMAKE_PREFIX_PATH ${BOOST_PATH_TO_SEARCH}) - list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) -endforeach() - -# Ecflow test require statics libs for boost < 1.59, otherwise get double free error. -# To use static boost python ensure that Boost_USE_STATIC_LIBS is set on. -# See: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html -if ( ENABLE_STATIC_BOOST_LIBS ) - set(Boost_USE_STATIC_LIBS ON) - ecbuild_info( "Using STATIC boost libraries : ${BOOST_TEST_DYN_LINK}" ) -else() - set(BOOST_TEST_DYN_LINK "BOOST_TEST_DYN_LINK") - ecbuild_info( "Using SHARED boost libraries setting : ${BOOST_TEST_DYN_LINK}" ) -endif() - -# By default cmake assume boost was built with cmake. Hence looks for package config file BoostConfig.cmake/boost-config.cmake -# This seems to mess up the search for boost python libs. -# if Boost_NO_BOOST_CMAKE is not set, we seem to mess up in finding right python libs(python3 and python2), -# for boost 1.71 and cmake 3.15 or greater -set(Boost_NO_BOOST_CMAKE ON) - -set(Boost_USE_MULTITHREADED ON) -set(Boost_NO_SYSTEM_PATHS ON) -set(Boost_DETAILED_FAILURE_MSG ON) -set(Boost_ARCHITECTURE "-x64") # from boost 1.69 layout=tagged adds libboost_system-mt-x64.a, https://gitlab.kitware.com/cmake/cmake/issues/18908 -#set(Boost_DEBUG ON) # Set to ON to enable debug output from FindBoost - -set(ECFLOW_BOOST_VERSION "1.66.0") - -# need upfront to get a hold of Boost_VERSION_STRING -find_package( Boost ${ECFLOW_BOOST_VERSION} ) - -# HAVE_TESTS is defined if ecbuild ENABLE_TESTS is set, (by default this is set) -if(HAVE_TESTS) - list(APPEND _boost_testlibs unit_test_framework test_exec_monitor ) -endif() - -# Need timer for boost::time::cpu_timer this needs boost:chrono, which need librt These are used in the test only -if ( Boost_VERSION_STRING VERSION_LESS "1.69.0" ) - find_package( Boost ${ECFLOW_BOOST_VERSION} REQUIRED COMPONENTS system timer chrono ${_boost_testlibs} filesystem program_options date_time ) -else() - # for boost version 1.69 or greater Boost.System is now header-only. - find_package( Boost ${ECFLOW_BOOST_VERSION} REQUIRED COMPONENTS timer chrono ${_boost_testlibs} filesystem program_options date_time ) -endif() -ecbuild_info( "Boost_LIBRARIES : ${Boost_LIBRARIES}" ) - - -# ======================================================================================= -# ?? -# ======================================================================================= -if (NOT "${CMAKE_PREFIX_PATH}" EQUAL "${_CMAKE_PREFIX_PATH_BACKUP}") - set (CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH_BACKUP}) # restore CMAKE_PREFIX_PATH - ecbuild_debug("Resetting CMAKE_PREFIX_PATH to ${CMAKE_PREFIX_PATH}") -endif() - - -# See: https://stackoverflow.com/questions/13653361/another-undefined-reference-error-when-linking-boost-libraries -message( STATUS "====================================================================================================================" ) -message( STATUS "LIB RT needed by some test, boost_timer->boost_chrono-> -lrt" ) -find_library(LIBRT rt) -if(LIBRT) - message( STATUS "LIB RT FOUND" ) -else() - # set to empty string to avoid lots of conditional around ecbuild_add_test - message( STATUS "LIB RT NOTFOUND -> LIBRT set to empty string for ecbuild_add_test" ) - set(LIBRT "") -endif() - -message( STATUS "====================================================================================================================" ) -message( STATUS "SSL" ) -if (ENABLE_SSL) - find_package(OpenSSL REQUIRED) - if (OPENSSL_FOUND) - include_directories( ${OPENSSL_INCLUDE_DIR} ) - add_definitions( -DECF_OPENSSL ) - else() - ecbuild_warn("Can *not* find openssl libraries. ecflow will build without ssl support") - endif() -endif() - -# ========================================================================================= -# debug -# ========================================================================================= - -if( CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" ) - - ecbuild_info( "INFO: DEBUG BUILD" ) - - # Tell C/C++ that we're doing a debug build - add_definitions( -DDEBUG ) - -endif() - -# ========================================================================================= -# CLANG: /usr/local/include/boost/type_traits/is_base_and_derived.hpp:226:42: -# fatal error: recursive template instantiation exceeded maximum depth of 256 -# ========================================================================================= -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024") -endif() # ========================================================================================= # enable clang-format # ========================================================================================= find_package(ClangFormat) + # ========================================================================================= # build source code # ========================================================================================= @@ -360,35 +252,6 @@ if (ENABLE_UI) add_subdirectory( share ) endif() -# ========================================================================================= -# DOXYGEN to use: make doxygen -> ${CMAKE_CURRENT_BINARY_DIR}/Doc/doxygen/html/index.html -# ========================================================================================= -find_package(Doxygen) -if (DOXYGEN_FOUND) - ecbuild_info( "DOXYGEN_FOUND - use 'make doxygen' first" ) - - # exclude some dirs not related to documentation - set( DOXYGEN_EXCLUDE_PATTERNS */bin/* */bdir/* */Debug/* */test/* */Doc/* */doc/* */samples/* SCRATCH tools build_scripts cereal ) - - set( DOXYGEN_SOURCE_BROWSER YES) - set( DOXYGEN_EXTRACT_PRIVATE YES) - set( DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Doc/doxygen") - - # this target will only be built if specifically asked to. - # run "make doxygen" to create the doxygen documentation - doxygen_add_docs( - doxygen - ${PROJECT_SOURCE_DIR} - COMMENT "Generate documentation for ecFlow" - ) - - # Add an install target to install the docs, *IF* the use has run 'make doxygen' - if (EXISTS ${DOXYGEN_OUTPUT_DIRECTORY}) - install(DIRECTORY ${DOXYGEN_OUTPUT_DIRECTORY} DESTINATION ${CMAKE_INSTALL_DOCDIR}) - endif() -else () - ecbuild_info("Doxygen need to be installed to generate the doxygen documentation") -endif() # ========================================================================================= # tar ball, by default ecbuild will tar everything apart from hard wired directory called 'build' diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index 397009696..19714e2a5 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -36,6 +36,22 @@ ecbuild_info( "CMAKE_CXX_COMPILER_ID : ${CMAKE_CXX_COMPILER_ID}") ecbuild_info( "CMAKE_CXX_COMPILER_VERSION : ${CMAKE_CXX_COMPILER_VERSION}") +ecbuild_info( "Selected built type: ${CMAKE_BUILD_TYPE}" ) + +if( CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" ) + # Tell C/C++ that we're doing a debug build + add_definitions( -DDEBUG ) +endif() + +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # + # In case of using Clang, we increase the template depth to avoid the following error: + # /usr/local/include/boost/type_traits/is_base_and_derived.hpp:226:42: + # fatal error: recursive template instantiation exceeded maximum depth of 256 + # + ecbuild_add_cxx_flags("-ftemplate-depth=1024") +endif() + if (HAVE_WARNINGS) ecbuild_add_c_flags(-Wall) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index dc745a7bd..9019390f2 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -15,30 +15,241 @@ set(DEPENDENCIES_DIR "${CMAKE_SOURCE_DIR}/3rdparty") # ========================================================================================= find_package(Threads REQUIRED) + # ========================================================================================= # Cereal # ========================================================================================= +ecbuild_info( "Locating Cereal" ) + set(CEREAL_DIR "${DEPENDENCIES_DIR}/cereal") find_package(Cereal REQUIRED) +ecbuild_info( "Cereal details:" ) +ecbuild_info( " * Cereal_FOUND : ${Cereal_FOUND}" ) +ecbuild_info( " * Cereal_INCLUDE_DIRS : ${Cereal_INCLUDE_DIRS}" ) + +ecbuild_info( "Found Cereal at ${Cereal_INCLUDE_DIRS}" ) + + # ========================================================================================= # Json # ========================================================================================= +ecbuild_info( "Locating JSON" ) + set(JSON_DIR "${DEPENDENCIES_DIR}/json") find_package(Json REQUIRED) +ecbuild_info( "JSON details:" ) +ecbuild_info( " * JSON_FOUND : ${JSON_FOUND}" ) +ecbuild_info( " * JSON_INCLUDE_DIRS : ${JSON_INCLUDE_DIRS}" ) + +ecbuild_info( "Found JSON at ${JSON_INCLUDE_DIRS}" ) + + # ========================================================================================= # Httplib # ========================================================================================= +ecbuild_info( "Locating Httplib" ) + set(HTTPLIB_DIR "${DEPENDENCIES_DIR}/cpp-httplib") find_package(Httplib REQUIRED) +ecbuild_info( "Httplib details:" ) +ecbuild_info( " * HTTPLIB_FOUND : ${HTTPLIB_FOUND}" ) +ecbuild_info( " * HTTPLIB_INCLUDE_DIRS : ${HTTPLIB_INCLUDE_DIRS}" ) + +ecbuild_info( "Found Httplib at ${HTTPLIB_INCLUDE_DIRS}" ) + + # ========================================================================================= # zlib # ========================================================================================= if (ENABLE_HTTP_COMPRESSION) - find_package(ZLIB) - if (NOT ZLIB_FOUND) - message(FATAL_ERROR "HTTP compression support requested, but zlib was not found") - endif () + ecbuild_info( "Locating ZLIB" ) + + find_package(ZLIB REQUIRED) + + ecbuild_info("ZLIB details:") + ecbuild_info(" * ZLIB_FOUND : ${ZLIB_FOUND}") + ecbuild_info(" * ZLIB_INCLUDE_DIRS : ${ZLIB_INCLUDE_DIRS}") + ecbuild_info(" * ZLIB_LIBRARIES : ${ZLIB_LIBRARIES}") + + ecbuild_info( "Found ZLIB at ${ZLIB_INCLUDE_DIRS}" ) endif () + + +# ========================================================================================= +# Python3 +# ========================================================================================= +if (ENABLE_PYTHON) + + ecbuild_info( "Locating Python3" ) + + # The python must include the Development packages. As the headers in these packages is used by boost python. + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + + ecbuild_info( "Python3 details:" ) + ecbuild_info( " * Python3_FOUND : ${Python3_FOUND}" ) + ecbuild_info( " * Python3_Interpreter_FOUND : ${Python3_Interpreter_FOUND}" ) + ecbuild_info( " * Python3_EXECUTABLE : ${Python3_EXECUTABLE}" ) + ecbuild_info( " * Python3_STDLIB : ${Python3_STDLIB} (Standard platform independent installation directory)" ) + ecbuild_info( " * Python3_STDARCH : ${Python3_STDARCH} (Standard platform dependent installation directory)" ) + ecbuild_info( " * Python3_Development_FOUND : ${Python3_Development_FOUND}" ) + ecbuild_info( " * Python3_INCLUDE_DIRS : ${Python3_INCLUDE_DIRS}" ) + ecbuild_info( " * Python3_LIBRARIES : ${Python3_LIBRARIES}" ) + ecbuild_info( " * Python3_LIBRARY_DIRS : ${Python3_LIBRARY_DIRS}" ) + ecbuild_info( " * Python3_VERSION : ${Python3_VERSION}" ) + ecbuild_info( " * Python3_VERSION_MAJOR : ${Python3_VERSION_MAJOR}" ) + ecbuild_info( " * Python3_VERSION_MINOR : ${Python3_VERSION_MINOR}" ) + ecbuild_info( " * Python3_VERSION_PATCH : ${Python3_VERSION_PATCH}" ) + + # Set (deprecated) FindPython variables + # These need to be available, as they are used by `ecbuild_add_test(... TYPE PYTHON ...)` + set(PYTHONINTERP_FOUND "${Python3_Interpreter_FOUND}") + set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") + + ecbuild_info( "Found Python3 at ${Python3_INCLUDE_DIRS}" ) + +endif() + + +# ========================================================================================= +# Boost +# ========================================================================================= + +ecbuild_info( "Locating Boost" ) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0") + ecbuild_info( "Using BoostConfig.cmake to find Boost (CMake >= 3.30)" ) + cmake_policy(SET CMP0167 NEW) +else() + ecbuild_info( "Using FindBoost.cmake module to find Boost (CMake < 3.30)" ) +endif() + +# To use static boost python ensure that Boost_USE_STATIC_LIBS is set on. +# See: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html +if ( ENABLE_STATIC_BOOST_LIBS ) + set(Boost_USE_STATIC_LIBS ON) + set(BOOST_TEST_DYN_LINK "") + ecbuild_info( "Using STATIC boost libraries : ${BOOST_TEST_DYN_LINK}" ) +else() + set(Boost_USE_STATIC_LIBS OFF) + set(BOOST_TEST_DYN_LINK "BOOST_TEST_DYN_LINK") + ecbuild_info( "Using SHARED boost libraries : ${BOOST_TEST_DYN_LINK}" ) +endif() + +set(Boost_USE_MULTITHREADED ON) +set(Boost_NO_SYSTEM_PATHS ON) +set(Boost_DETAILED_FAILURE_MSG ON) +set(Boost_ARCHITECTURE "-x64") # from boost 1.69 layout=tagged adds libboost_system-mt-x64.a, https://gitlab.kitware.com/cmake/cmake/issues/18908 + +set(ECFLOW_BOOST_VERSION "1.66.0") # Boost 1.66.0 is the minimum version required (needed to support Rocky 8.6 on CI) + +find_package( Boost ${ECFLOW_BOOST_VERSION} QUIET REQUIRED) # This initial step allows to get a hold of Boost_VERSION_STRING + +if ( Boost_VERSION_STRING VERSION_LESS "1.69.0" ) + # Boost::system is header-only from 1.69.0 + list(APPEND _boost_needed_libs system ) +endif () + +list(APPEND _boost_needed_libs timer chrono filesystem program_options date_time ) + +if (ENABLE_PYTHON) + # The following is used to find Boost.python library, as the library name changes with python version + if ( Boost_MINOR_VERSION GREATER 66 ) + # cmake 3.15 + # see: https://gitlab.kitware.com/cmake/cmake/issues/19656 + # INTERFACE_LIBRARY targets may only have whitelisted properties. + set(_python_base_version "${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + else() + set(_python_base_version "${Python3_VERSION_MAJOR}") + endif() + set(ECFLOW_BOOST_PYTHON_COMPONENT "python${_python_base_version}") + + list(APPEND _boost_needed_libs ${ECFLOW_BOOST_PYTHON_COMPONENT}) +endif() + +if(HAVE_TESTS) # HAVE_TESTS is defined if ecbuild ENABLE_TESTS is set, (by default this is set) + list(APPEND _boost_needed_libs unit_test_framework test_exec_monitor ) +endif() + +find_package( Boost ${ECFLOW_BOOST_VERSION} QUIET REQUIRED COMPONENTS ${_boost_needed_libs}) + +ecbuild_info( " * Boost_FOUND : ${Boost_FOUND}" ) +ecbuild_info( " * Boost_NO_BOOST_CMAKE : ${Boost_NO_BOOST_CMAKE}" ) +ecbuild_info( " * Boost_USE_MULTITHREADED : ${Boost_USE_MULTITHREADED}" ) +ecbuild_info( " * Boost_NO_SYSTEM_PATHS : ${Boost_NO_SYSTEM_PATHS}" ) +ecbuild_info( " * Boost_DETAILED_FAILURE_MSG : ${Boost_DETAILED_FAILURE_MSG}" ) +ecbuild_info( " * Boost_MAJOR_VERSION : ${Boost_MAJOR_VERSION}" ) +ecbuild_info( " * Boost_MINOR_VERSION : ${Boost_MINOR_VERSION}" ) +ecbuild_info( " * Boost_SUBMINOR_VERSION : ${Boost_SUBMINOR_VERSION}" ) +ecbuild_info( " * Boost_INCLUDE_DIRS : ${Boost_INCLUDE_DIRS}" ) +ecbuild_info( " * Boost_LIBRARY_DIR_RELEASE : ${Boost_LIBRARY_DIR_RELEASE}" ) +ecbuild_info( " * Boost Components" ) +foreach(_lib ${_boost_needed_libs}) + string(TOUPPER "${_lib}" _lib_upper) + + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0") + ecbuild_info( " * ${_lib}, found ${Boost_${_lib_upper}_LIBRARY} @ ${Boost_${_lib_upper}_LIBRARY_RELEASE}" ) + else() + ecbuild_info( " * ${_lib}, found ${Boost_${_lib_upper}_LIBRARY_RELEASE}" ) + endif() +endforeach() + +ecbuild_info( "Found Boost at ${Boost_INCLUDE_DIR}" ) +if (ENABLE_PYTHON) + ecbuild_info( "Found Boost.Python at ${Boost_PYTHON${_python_base_version}_LIBRARY_RELEASE}" ) +endif() + + +# ========================================================================================= +# OpenSSL +# ========================================================================================= + +if (ENABLE_SSL) + ecbuild_info( "Locating OpenSSL" ) + + find_package(OpenSSL REQUIRED) + + add_definitions( -DECF_OPENSSL=1 ) + + ecbuild_info( "OpenSSL details:" ) + ecbuild_info( " * OPENSSL_FOUND : ${OpenSSL_FOUND}" ) + ecbuild_info( " * OPENSSL_INCLUDE_DIR : ${OPENSSL_INCLUDE_DIR}" ) + ecbuild_info( " * OpenSSL_LIBRARIES : ${OPENSSL_LIBRARIES}" ) + ecbuild_info( " * OPENSSL_VERSION : ${OPENSSL_VERSION}" ) + + ecbuild_info( "Found OpenSSL at ${OPENSSL_INCLUDE_DIR}" ) +endif() + + +# ========================================================================================= +# Doxygen +# ========================================================================================= +ecbuild_info( "Locating Doxygen" ) +find_package(Doxygen) +if (DOXYGEN_FOUND) + ecbuild_info( "Found Doxygen at ${DOXYGEN_EXECUTABLE}" ) + + # exclude some dirs not related to documentation + set( DOXYGEN_EXCLUDE_PATTERNS */bin/* */bdir/* */Debug/* */test/* */Doc/* */doc/* */samples/* SCRATCH tools build_scripts cereal ) + + set( DOXYGEN_SOURCE_BROWSER YES) + set( DOXYGEN_EXTRACT_PRIVATE YES) + set( DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Doc/doxygen") + + # this target will only be built if specifically asked to. + # run "make doxygen" to create the doxygen documentation + doxygen_add_docs( + doxygen + ${PROJECT_SOURCE_DIR} + COMMENT "Generate documentation for ecFlow" + ) + + # Add an install target to install the docs, *IF* the use has run 'make doxygen' + if (EXISTS ${DOXYGEN_OUTPUT_DIRECTORY}) + install(DIRECTORY ${DOXYGEN_OUTPUT_DIRECTORY} DESTINATION ${CMAKE_INSTALL_DOCDIR}) + endif() +else () + ecbuild_info("Doxygen need to be installed to generate the doxygen documentation") +endif() diff --git a/cmake/FindCereal.cmake b/cmake/FindCereal.cmake index 227782eab..47bce1379 100644 --- a/cmake/FindCereal.cmake +++ b/cmake/FindCereal.cmake @@ -33,9 +33,7 @@ # # -if (CEREAL_DIR) - message(STATUS "Locating Cereal at ${CEREAL_DIR}") -else () +if (NOT DEFINED CEREAL_DIR) message(FATAL_ERROR "Unable to find Cereal. Please provide CEREAL_DIR property.") endif () @@ -44,7 +42,7 @@ endif () # Search for include DIRs # ----------------------------------------------------------------------------- -find_path(CEREAL_INCLUDE_DIRS +find_path(Cereal_INCLUDE_DIRS NAMES cereal/cereal.hpp PATHS ${CEREAL_DIR}/include) @@ -56,7 +54,7 @@ find_path(CEREAL_INCLUDE_DIRS include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Cereal REQUIRED_VARS - CEREAL_INCLUDE_DIRS) + Cereal_INCLUDE_DIRS) # # ----------------------------------------------------------------------------- @@ -69,6 +67,6 @@ add_library(${NAME} INTERFACE IMPORTED GLOBAL) set_target_properties(${NAME} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CEREAL_INCLUDE_DIRS}") + INTERFACE_INCLUDE_DIRECTORIES "${Cereal_INCLUDE_DIRS}") add_library(cereal::cereal ALIAS cereal) diff --git a/cmake/FindHttplib.cmake b/cmake/FindHttplib.cmake index a63f9b34e..6733bcb1d 100644 --- a/cmake/FindHttplib.cmake +++ b/cmake/FindHttplib.cmake @@ -32,9 +32,7 @@ # # -if (HTTPLIB_DIR) - message(STATUS "Locating Httplib at ${HTTPLIB_DIR}") -else () +if (NOT DEFINED HTTPLIB_DIR) message(FATAL_ERROR "Unable to find Httplib. Please provide HTTPLIB_LIB property.") endif () diff --git a/cmake/FindJson.cmake b/cmake/FindJson.cmake index add412a9b..57b5978b9 100644 --- a/cmake/FindJson.cmake +++ b/cmake/FindJson.cmake @@ -32,9 +32,7 @@ # # -if (JSON_DIR) - message(STATUS "Locating JSON at ${JSON_DIR}") -else () +if (NOT DEFINED JSON_DIR) message(FATAL_ERROR "Unable to find JSON. Please provide JSON_DIR property.") endif () diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index a1c0c0ad1..5354ff7ea 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -12,8 +12,11 @@ # Setup Sphinx # +ecbuild_info("Locating Sphinx") + find_package(Sphinx REQUIRED) +ecbuild_info("Sphinx found at ${SPHINX_EXECUTABLE}") # # (Re-)generate ecFlow CLI documentation @@ -46,8 +49,6 @@ add_custom_target(ecflow_client_docs DEPENDS generate_ecflow_client_docs) # (Re-)generate ecFlow Python documentation # -message(STATUS "***> ${SPHINX_EXECUTABLE}") - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build_python_api/rst) add_custom_command( OUTPUT generate_ecflow_python_docs diff --git a/libs/pyext/CMakeLists.txt b/libs/pyext/CMakeLists.txt index 7872e02f3..7ecf930c1 100644 --- a/libs/pyext/CMakeLists.txt +++ b/libs/pyext/CMakeLists.txt @@ -8,7 +8,8 @@ # nor does it submit to any jurisdiction. # -### ecflow python bindings +### ecFlow python bindings +# # NOTES: # 1/ Building multiple python3 versions not supported, since find_python(..) caches variables, Hack: clear cached variable. # https://gitlab.kitware.com/cmake/cmake/issues/19820 @@ -47,7 +48,7 @@ set(SETUP_PY_OUT "${CMAKE_CURRENT_SOURCE_DIR}/setup.py") configure_file(${SETUP_PY_IN} ${SETUP_PY_OUT} ) # ============================================================================== -# source files (paths relative to dirs python2/python3) +# source files (paths relative to dirs .../python3) # ============================================================================== set(srcs # Headers @@ -123,141 +124,6 @@ set(s_tests s_TestPythonChildApi ) - -message( STATUS "====================================================================================================================" ) -message( STATUS "PYTHON2" ) -message( STATUS "====================================================================================================================" ) -if(${CMAKE_VERSION} VERSION_LESS "3.12.0") - # We only support python2 extension for cmake less 3.12.0 - # cmake 3.12.0 or greater allows multiple boost python libs & hence multiple extensions to be built - # Using -DPYTHON_EXECUTABLE=/usr/local/apps/python3/3.6.5-01/bin/python3 is not sufficient as the wrong(python2) libs are found - ecbuild_find_python( VERSION 2.6 REQUIRED ) - message( STATUS " PYTHON_FOUND : ${PYTHON_FOUND}" ) - message( STATUS " PYTHONINTERP_FOUND : ${PYTHONINTERP_FOUND}" ) - message( STATUS " PYTHONLIBS_FOUND : ${PYTHONLIBS_FOUND}" ) - message( STATUS " PYTHON_VERSION_STRING : ${PYTHON_VERSION_STRING}" ) - message( STATUS " PYTHON_VERSION_MAJOR : ${PYTHON_VERSION_MAJOR}" ) - message( STATUS " PYTHON_VERSION_MINOR : ${PYTHON_VERSION_MINOR}" ) - message( STATUS " PYTHON_VERSION_PATCH : ${PYTHON_VERSION_PATCH}" ) - message( STATUS " PYTHON_CONFIG_EXECUTABLE : ${PYTHON_CONFIG_EXECUTABLE}" ) - message( STATUS " PYTHON_EXECUTABLE : ${PYTHON_EXECUTABLE}" ) - message( STATUS " PYTHON_INCLUDE_DIRS : ${PYTHON_INCLUDE_DIRS}" ) - message( STATUS " PYTHON_LIBRARIES : ${PYTHON_LIBRARIES}" ) - if (${PYTHON_VERSION_MAJOR} EQUAL 3) - ecbuild_error("Need cmake version >= 3.12.0 to build ecflow python3 extension, current cmake version is ${CMAKE_VERSION}") - endif() - - find_package( Boost ${ECFLOW_BOOST_VERSION} REQUIRED COMPONENTS python ) - add_subdirectory( python2 ) -else() - # ====================================================================================== - # Attempt to build both python2 *AND/OR* python3 ecflow extension, depending on what is found - # this assumes cmake 3.12.0 min, which added support for boost python2 and python3 - # * NOTICE* that we do *NOT* use REQUIRED when searching for boost python libs - # ====================================================================================== - find_package(Python2 COMPONENTS Interpreter Development) - if (Python2_FOUND) - message( STATUS " Python2_Interpreter_FOUND : ${Python2_Interpreter_FOUND}" ) - message( STATUS " Python2_EXECUTABLE : ${Python2_EXECUTABLE}" ) - message( STATUS " Python2_STDLIB : ${Python2_STDLIB} Standard platform independent installation directory" ) - message( STATUS " Python2_STDARCH : ${Python2_STDARCH} Standard platform dependent installation directory." ) - message( STATUS " Python2_Development_FOUND : ${Python2_Development_FOUND}" ) - message( STATUS " Python2_INCLUDE_DIRS : ${Python2_INCLUDE_DIRS}" ) - message( STATUS " Python2_LIBRARIES : ${Python2_LIBRARIES}" ) - message( STATUS " Python2_LIBRARY_DIRS : ${Python2_LIBRARY_DIRS}" ) - message( STATUS " Python2_VERSION : ${Python2_VERSION}" ) - message( STATUS " Python2_VERSION_MAJOR : ${Python2_VERSION_MAJOR}" ) - message( STATUS " Python2_VERSION_MINOR : ${Python2_VERSION_MINOR}" ) - message( STATUS " Python2_VERSION_PATCH : ${Python2_VERSION_PATCH}" ) - # ***************************************************************************************** - # Although we have found python2 it could be that *ONLY* python3 was module loaded - # Otherwise will build for python2 and test with python3 interpreter - # ***************************************************************************************** - if ( Python2_LIBRARIES ) - ecbuild_find_python( VERSION 2.6 REQUIRED ) # if not included iterpreter not found ? - if ( ${PYTHON_VERSION_MAJOR} EQUAL 2) - message( STATUS " PYTHON_FOUND : ${PYTHON_FOUND}" ) - message( STATUS " PYTHONINTERP_FOUND : ${PYTHONINTERP_FOUND}" ) - message( STATUS " PYTHONLIBS_FOUND : ${PYTHONLIBS_FOUND}" ) - message( STATUS " PYTHON_VERSION_STRING : ${PYTHON_VERSION_STRING}" ) - message( STATUS " PYTHON_VERSION_MAJOR : ${PYTHON_VERSION_MAJOR}" ) - message( STATUS " PYTHON_VERSION_MINOR : ${PYTHON_VERSION_MINOR}" ) - message( STATUS " PYTHON_VERSION_PATCH : ${PYTHON_VERSION_PATCH}" ) - message( STATUS " PYTHON_CONFIG_EXECUTABLE : ${PYTHON_CONFIG_EXECUTABLE}" ) - message( STATUS " PYTHON_EXECUTABLE : ${PYTHON_EXECUTABLE}" ) - message( STATUS " PYTHON_INCLUDE_DIRS : ${PYTHON_INCLUDE_DIRS}" ) - message( STATUS " PYTHON_LIBRARIES : ${PYTHON_LIBRARIES}" ) - - if ( Boost_MINOR_VERSION GREATER 66 ) - # cmake 3.15 - # see: https://gitlab.kitware.com/cmake/cmake/issues/19656 - # INTERFACE_LIBRARY targets may only have whitelisted properties." - set(ECFLOW_BOOST_PYTHON_COMPONENT python${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}) - else() - set(ECFLOW_BOOST_PYTHON_COMPONENT python) - endif() - find_package( Boost ${ECFLOW_BOOST_VERSION} COMPONENTS ${ECFLOW_BOOST_PYTHON_COMPONENT} ) - - if (Boost_PYTHON_FOUND OR Boost_PYTHON${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}_FOUND) - # Indicate that both Python and Boost.Python have been found - set(ECF_PYTHON_FOUND "ECF_PYTHON_FOUND") - add_subdirectory( python2 ) - else() - message( STATUS " Boost python2 libraries *NOT* found" ) - endif() - endif() - else() - message( STATUS " Python2 libraries *NOT* found" ) - endif() - endif() - - message( STATUS "====================================================================================================================" ) - message( STATUS "PYTHON3" ) - message( STATUS "====================================================================================================================" ) - # The python must include the Development packages. As the headers in these packages is used by boost python. - find_package(Python3 COMPONENTS Interpreter Development) - if (Python3_FOUND) - message( STATUS " Python3_Interpreter_FOUND : ${Python3_Interpreter_FOUND}" ) - message( STATUS " Python3_EXECUTABLE : ${Python3_EXECUTABLE}" ) - message( STATUS " Python3_STDLIB : ${Python3_STDLIB} Standard platform independent installation directory" ) - message( STATUS " Python3_STDARCH : ${Python3_STDARCH} Standard platform dependent installation directory." ) - message( STATUS " Python3_Development_FOUND : ${Python3_Development_FOUND}" ) - message( STATUS " Python3_INCLUDE_DIRS : ${Python3_INCLUDE_DIRS}" ) - message( STATUS " Python3_LIBRARIES : ${Python3_LIBRARIES}" ) - message( STATUS " Python3_LIBRARY_DIRS : ${Python3_LIBRARY_DIRS}" ) - message( STATUS " Python3_VERSION : ${Python3_VERSION}" ) - message( STATUS " Python3_VERSION_MAJOR : ${Python3_VERSION_MAJOR}" ) - message( STATUS " Python3_VERSION_MINOR : ${Python3_VERSION_MINOR}" ) - message( STATUS " Python3_VERSION_PATCH : ${Python3_VERSION_PATCH}" ) - - # Set (deprecated) FindPython variables - # These need to be available, as they are used by `ecbuild_add_test(... TYPE PYTHON ...)` - set(PYTHONINTERP_FOUND "${Python3_Interpreter_FOUND}") - set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") - - if ( Boost_MINOR_VERSION GREATER 66 ) - # cmake 3.15 - # see: https://gitlab.kitware.com/cmake/cmake/issues/19656 - # INTERFACE_LIBRARY targets may only have whitelisted properties. - set(ECFLOW_BOOST_PYTHON_COMPONENT python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) - else() - set(ECFLOW_BOOST_PYTHON_COMPONENT python3) - endif() - find_package( Boost ${ECFLOW_BOOST_VERSION} COMPONENTS ${ECFLOW_BOOST_PYTHON_COMPONENT} ) - - if (Boost_PYTHON3_FOUND OR Boost_PYTHON${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}_FOUND) - # Indicate that both Python and Boost.Python have been found - set(ECF_PYTHON_FOUND "ECF_PYTHON_FOUND") - add_subdirectory( python3 ) - else() - message( STATUS " Boost python3 libraries *NOT* found" ) - endif() - endif() - - if (NOT ECF_PYTHON_FOUND) - ecbuild_error("ecflow python extension is enabled, but python2/python3 libraries or python boost libraries not found") - endif() +if (Python3_FOUND AND (Boost_PYTHON3_FOUND OR Boost_PYTHON${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}_FOUND)) + add_subdirectory( python3 ) endif() -message( STATUS "====================================================================================================================" ) -message( STATUS "END PYTHON" ) -message( STATUS "====================================================================================================================" ) diff --git a/libs/pyext/python2/CMakeLists.txt b/libs/pyext/python2/CMakeLists.txt deleted file mode 100644 index f2112ff78..000000000 --- a/libs/pyext/python2/CMakeLists.txt +++ /dev/null @@ -1,176 +0,0 @@ -# -# Copyright 2009- ECMWF. -# -# This software is licensed under the terms of the Apache Licence version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# In applying this licence, ECMWF does not waive the privileges and immunities -# granted to it by virtue of its status as an intergovernmental organisation -# nor does it submit to any jurisdiction. -# - -ecbuild_add_library( - TARGET - ecflow2 - NOINSTALL - TYPE MODULE - SOURCES - ${srcs} - PRIVATE_INCLUDES - ../src - PUBLIC_LIBS - ecflow_all - libsimulator - Python2::Python - Boost::${ECFLOW_BOOST_PYTHON_COMPONENT} - $<$:OpenSSL::SSL> - CXXFLAGS - $<$:-Wno-macro-redefined> -) - -target_clangformat(ecflow2) - -# -# Override default behaviour that add RPATHS during install -# The only thing that seem to work is set INSTALL_RPATH to "" -# Using SKIP_BUILD_RPATH,BUILD_WITH_INSTALL_RPATH,INSTALL_RPATH_USE_LINK_PATH -# had no effect -# -# by default cmake add prefix 'lib', we don't want this hence disable -# -# To avoid duplicate target names we chose to name the targets: ecflow2/ecflow3. -# however test and user code depend on name 'ecflow', hence we rename the output to 'cflow' -set_target_properties(ecflow3 - PROPERTIES - OUTPUT_NAME "ecflow" - PREFIX "" - INSTALL_RPATH "" -) - -# ===================================================================== -# tests - -foreach( test ${u_tests} ) - ecbuild_add_test( - TARGET - py2_${test} - LABELS - python nightly - TYPE PYTHON - ARGS - ${CMAKE_CURRENT_SOURCE_DIR}/../test/${test}.py - ENVIRONMENT - "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - TEST_DEPENDS - u_base - ) -endforeach() - - -if ( ENABLE_ALL_TESTS AND ENABLE_SERVER) - - foreach( test ${s_tests} ) - ecbuild_add_test( - TARGET - py2_${test} - LABELS - python nightly - TYPE PYTHON - ARGS - ${CMAKE_CURRENT_SOURCE_DIR}/../test/${test}.py - ENVIRONMENT - "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - TEST_DEPENDS - u_base - ) - endforeach() - - set_property(TEST py2_s_TestClientApi APPEND PROPERTY DEPENDS s_test) - set_property(TEST py2_s_TestPythonChildApi APPEND PROPERTY DEPENDS py_s_TestClientApi) -endif() - - -# ========================================================================== -# install -# -DCMAKE_PYTHON_INSTALL_TYPE = [ local | setup | not defined ] -# -# local | not defined : this will install to: -# $INSTALL_PREFIX/$release.$major.$minor/lib/python2.7/site-packages/ecflow/ -# setup : experimental only,python way of installing -# -# -DCMAKE_PYTHON_INSTALL_PREFIX should *only* used when using python setup.py (CMAKE_PYTHON_INSTALL_TYPE=setup) -# *AND* for testing python install to local directory -# -# Note: To install only the python module -# cd buildir -# cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCOMPONENT=python -P cmake_install.cmake -- make install -# ========================================================================== - -if( CMAKE_PYTHON_INSTALL_TYPE MATCHES "local" OR NOT DEFINED CMAKE_PYTHON_INSTALL_TYPE ) - - message(STATUS "python install *LOCAL* +++ lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/ecflow +++++++") - if( NOT INSTALL_PYTHON2_DIR ) - set(PYTHON_SITE "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages" ) - else() - # Resolve ${VAR} in the value provided - string(CONFIGURE "${INSTALL_PYTHON2_DIR}" PYTHON_SITE) - endif() - set(PYTHON_DEST "${PYTHON_SITE}/ecflow" ) - - install( - TARGETS - ecflow2 - DESTINATION - ${PYTHON_DEST} - RENAME - ecflow.so - COMPONENT - python - ) - install( - FILES - ../ecflow/__init__.py - ../samples/api/ecf.py - ../samples/api/sms2ecf.py - DESTINATION - ${PYTHON_DEST} - COMPONENT - python - ) - -else() - - message( STATUS "python found, CMAKE_PYTHON_INSTALL_TYPE=${CMAKE_PYTHON_INSTALL_TYPE}") - - # ------------------------------------------------------------------------------------- - # Install using setup.py - # See: http://bloerg.net/2012/11/10/cmake-and-distutils.html - # ------------------------------------------------------------------------------------- - message(STATUS "python install using *setup.py* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") - message(STATUS "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}") - message(STATUS "CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}") - message(STATUS "CMAKE_PYTHON_INSTALL_PREFIX : ${CMAKE_PYTHON_INSTALL_PREFIX}" ) - - set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/../setup.py.in") - set(SETUP_PY "${CMAKE_CURRENT_SOURCE_DIR}/../setup.py") - set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/../ecflow/__init__.py") - set(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/timestamp") - - configure_file(${SETUP_PY_IN} ${SETUP_PY} ) - - add_custom_command( - OUTPUT ${OUTPUT} - COMMAND ${PYTHON} ${SETUP_PY} build - COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} - DEPENDS ${DEPS} - ) - add_custom_target(target ALL DEPENDS ${OUTPUT}) - - install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} build_ext)") - - if( DEFINED CMAKE_PYTHON_INSTALL_PREFIX ) - message(STATUS "custom/*test* python install prefix defined CMAKE_PYTHON_INSTALL_PREFIX=${CMAKE_PYTHON_INSTALL_PREFIX}") - install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install -f --prefix=${CMAKE_PYTHON_INSTALL_PREFIX})") - else() - install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") - endif() -endif() diff --git a/libs/pyext/python3/CMakeLists.txt b/libs/pyext/python3/CMakeLists.txt index 8a8ea5a35..13e3bf4d2 100644 --- a/libs/pyext/python3/CMakeLists.txt +++ b/libs/pyext/python3/CMakeLists.txt @@ -118,7 +118,6 @@ endif() if( CMAKE_PYTHON_INSTALL_TYPE MATCHES "local" OR NOT DEFINED CMAKE_PYTHON_INSTALL_TYPE ) - message(STATUS "python install *LOCAL* +++ lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/ecflow +++++++") if( NOT INSTALL_PYTHON3_DIR ) set(PYTHON_SITE "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" ) else() diff --git a/project_summary.cmake b/project_summary.cmake index 3fe2206e8..e69de29bb 100644 --- a/project_summary.cmake +++ b/project_summary.cmake @@ -1,51 +0,0 @@ -message( STATUS "------------------------------------------------------" ) - -if(Boost_FOUND) - message( STATUS " Boost_NO_BOOST_CMAKE : [${Boost_NO_BOOST_CMAKE}]" ) - message( STATUS " Boost_USE_MULTITHREADED : [${Boost_USE_MULTITHREADED}]" ) - message( STATUS " Boost_NO_SYSTEM_PATHS : [${Boost_NO_SYSTEM_PATHS}]" ) - message( STATUS " Boost_DETAILED_FAILURE_MSG : [${Boost_DETAILED_FAILURE_MSG}]" ) - message( STATUS " Boost_MAJOR_VERSION : [${Boost_MAJOR_VERSION}]" ) - message( STATUS " Boost_MINOR_VERSION : [${Boost_MINOR_VERSION}]" ) - message( STATUS " Boost_SUBMINOR_VERSION : [${Boost_SUBMINOR_VERSION}]" ) - message( STATUS " Boost_INCLUDE_DIRS : [${Boost_INCLUDE_DIRS}]" ) - message( STATUS " Boost_LIBRARY_DIR_RELEASE : [${Boost_LIBRARY_DIR_RELEASE}]" ) - message( STATUS " Boost_TIMER_LIBRARY : [${Boost_TIMER_LIBRARY}]" ) - message( STATUS " Boost_CHRONO_LIBRARY : [${Boost_CHRONO_LIBRARY}]" ) - message( STATUS " Boost_SYSTEM_LIBRARY : [${Boost_SYSTEM_LIBRARY}]" ) - message( STATUS " Boost_FILESYSTEM_LIBRARY : [${Boost_FILESYSTEM_LIBRARY}]" ) - message( STATUS " Boost_PROGRAM_OPTIONS_LIBRARY : [${Boost_PROGRAM_OPTIONS_LIBRARY}]" ) - message( STATUS " Boost_DATE_TIME_LIBRARY : [${Boost_DATE_TIME_LIBRARY}]" ) - message( STATUS " Boost_UNIT_TEST_FRAMEWORK_LIBRARY : [${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}]" ) - message( STATUS " Boost_TEST_EXEC_MONITOR_LIBRARY : [${Boost_TEST_EXEC_MONITOR_LIBRARY}]" ) - message( STATUS " Boost_REGEX_LIBRARY : [${Boost_REGEX_LIBRARY}]" ) - message( STATUS " Boost_PYTHON_LIBRARY : [${Boost_PYTHON_LIBRARY}]" ) - message( STATUS " Boost_PYTHON_LIBRARY_RELEASE : [${Boost_PYTHON_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON3_LIBRARY_RELEASE : [${Boost_PYTHON3_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON27_LIBRARY : [${Boost_PYTHON27_LIBRARY}]" ) - message( STATUS " Boost_PYTHON27_LIBRARY_RELEASE : [${Boost_PYTHON27_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON36_LIBRARY : [${Boost_PYTHON36_LIBRARY}]" ) - message( STATUS " Boost_PYTHON36_LIBRARY_RELEASE : [${Boost_PYTHON36_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON37_LIBRARY : [${Boost_PYTHON37_LIBRARY}]" ) - message( STATUS " Boost_PYTHON37_LIBRARY_RELEASE : [${Boost_PYTHON37_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON38_LIBRARY : [${Boost_PYTHON38_LIBRARY}]" ) - message( STATUS " Boost_PYTHON38_LIBRARY_RELEASE : [${Boost_PYTHON38_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON39_LIBRARY : [${Boost_PYTHON39_LIBRARY}]" ) - message( STATUS " Boost_PYTHON39_LIBRARY_RELEASE : [${Boost_PYTHON39_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON310_LIBRARY : [${Boost_PYTHON310_LIBRARY}]" ) - message( STATUS " Boost_PYTHON310_LIBRARY_RELEASE : [${Boost_PYTHON310_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON311_LIBRARY : [${Boost_PYTHON311_LIBRARY}]" ) - message( STATUS " Boost_PYTHON311_LIBRARY_RELEASE : [${Boost_PYTHON311_LIBRARY_RELEASE}]" ) - message( STATUS " Boost_PYTHON312_LIBRARY : [${Boost_PYTHON312_LIBRARY}]" ) - message( STATUS " Boost_PYTHON312_LIBRARY_RELEASE : [${Boost_PYTHON312_LIBRARY_RELEASE}]" ) -endif() - -if (ENABLE_SSL) - if (OPENSSL_FOUND) - ecbuild_info(" OpenSSL VERSION ${OPENSSL_VERSION}") - ecbuild_info(" LIBS ${OPENSSL_LIBRARIES}") - ecbuild_info(" INCLUDES ${OPENSSL_INCLUDE_DIR}") - else() - ecbuild_warn("Can *not* find openssl libraries. ecflow will build without ssl support") - endif() -endif()