Skip to content

Commit abc1546

Browse files
committed
Modernise CMake
- Prevent dev warning related to CMake Policy CMP0167 - Move finding Boost and Python into Dependencies.cmake - Display relevant variables for all packages - Deprecate support for Python2 Re ECFLOW-1972 Re ECFLOW-1974
1 parent 2c7d1bf commit abc1546

11 files changed

+246
-523
lines changed

CMakeLists.txt

+1-138
Original file line numberDiff line numberDiff line change
@@ -231,121 +231,13 @@ ecbuild_info("")
231231
# =========================================================================================
232232
include(Dependencies)
233233

234-
# =========================================================================================
235-
# Dependency: Boost
236-
# =========================================================================================
237-
message( STATUS "====================================================================================================================" )
238-
message( STATUS "BOOST" )
239-
# this can help in some situations:
240-
set (_CMAKE_PREFIX_PATH_BACKUP ${CMAKE_PREFIX_PATH}) # make a backup of CMAKE_PREFIX_PATH
241-
foreach(BOOST_PATH_TO_SEARCH ${BOOST_PATH} ${BOOST_ROOT} $ENV{BOOST_ROOT})
242-
ecbuild_debug("adding: ${BOOST_PATH_TO_SEARCH} to CMAKE_PREFIX_PATH")
243-
list(APPEND CMAKE_PREFIX_PATH ${BOOST_PATH_TO_SEARCH})
244-
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
245-
endforeach()
246-
247-
# Ecflow test require statics libs for boost < 1.59, otherwise get double free error.
248-
# To use static boost python ensure that Boost_USE_STATIC_LIBS is set on.
249-
# See: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html
250-
if ( ENABLE_STATIC_BOOST_LIBS )
251-
set(Boost_USE_STATIC_LIBS ON)
252-
ecbuild_info( "Using STATIC boost libraries : ${BOOST_TEST_DYN_LINK}" )
253-
else()
254-
set(BOOST_TEST_DYN_LINK "BOOST_TEST_DYN_LINK")
255-
ecbuild_info( "Using SHARED boost libraries setting : ${BOOST_TEST_DYN_LINK}" )
256-
endif()
257-
258-
# By default cmake assume boost was built with cmake. Hence looks for package config file BoostConfig.cmake/boost-config.cmake
259-
# This seems to mess up the search for boost python libs.
260-
# if Boost_NO_BOOST_CMAKE is not set, we seem to mess up in finding right python libs(python3 and python2),
261-
# for boost 1.71 and cmake 3.15 or greater
262-
set(Boost_NO_BOOST_CMAKE ON)
263-
264-
set(Boost_USE_MULTITHREADED ON)
265-
set(Boost_NO_SYSTEM_PATHS ON)
266-
set(Boost_DETAILED_FAILURE_MSG ON)
267-
set(Boost_ARCHITECTURE "-x64") # from boost 1.69 layout=tagged adds libboost_system-mt-x64.a, https://gitlab.kitware.com/cmake/cmake/issues/18908
268-
#set(Boost_DEBUG ON) # Set to ON to enable debug output from FindBoost
269-
270-
set(ECFLOW_BOOST_VERSION "1.66.0")
271-
272-
# need upfront to get a hold of Boost_VERSION_STRING
273-
find_package( Boost ${ECFLOW_BOOST_VERSION} )
274-
275-
# HAVE_TESTS is defined if ecbuild ENABLE_TESTS is set, (by default this is set)
276-
if(HAVE_TESTS)
277-
list(APPEND _boost_testlibs unit_test_framework test_exec_monitor )
278-
endif()
279-
280-
# Need timer for boost::time::cpu_timer this needs boost:chrono, which need librt These are used in the test only
281-
if ( Boost_VERSION_STRING VERSION_LESS "1.69.0" )
282-
find_package( Boost ${ECFLOW_BOOST_VERSION} REQUIRED COMPONENTS system timer chrono ${_boost_testlibs} filesystem program_options date_time )
283-
else()
284-
# for boost version 1.69 or greater Boost.System is now header-only.
285-
find_package( Boost ${ECFLOW_BOOST_VERSION} REQUIRED COMPONENTS timer chrono ${_boost_testlibs} filesystem program_options date_time )
286-
endif()
287-
ecbuild_info( "Boost_LIBRARIES : ${Boost_LIBRARIES}" )
288-
289-
290-
# =======================================================================================
291-
# ??
292-
# =======================================================================================
293-
if (NOT "${CMAKE_PREFIX_PATH}" EQUAL "${_CMAKE_PREFIX_PATH_BACKUP}")
294-
set (CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH_BACKUP}) # restore CMAKE_PREFIX_PATH
295-
ecbuild_debug("Resetting CMAKE_PREFIX_PATH to ${CMAKE_PREFIX_PATH}")
296-
endif()
297-
298-
299-
# See: https://stackoverflow.com/questions/13653361/another-undefined-reference-error-when-linking-boost-libraries
300-
message( STATUS "====================================================================================================================" )
301-
message( STATUS "LIB RT needed by some test, boost_timer->boost_chrono-> -lrt" )
302-
find_library(LIBRT rt)
303-
if(LIBRT)
304-
message( STATUS "LIB RT FOUND" )
305-
else()
306-
# set to empty string to avoid lots of conditional around ecbuild_add_test
307-
message( STATUS "LIB RT NOTFOUND -> LIBRT set to empty string for ecbuild_add_test" )
308-
set(LIBRT "")
309-
endif()
310-
311-
message( STATUS "====================================================================================================================" )
312-
message( STATUS "SSL" )
313-
if (ENABLE_SSL)
314-
find_package(OpenSSL REQUIRED)
315-
if (OPENSSL_FOUND)
316-
include_directories( ${OPENSSL_INCLUDE_DIR} )
317-
add_definitions( -DECF_OPENSSL )
318-
else()
319-
ecbuild_warn("Can *not* find openssl libraries. ecflow will build without ssl support")
320-
endif()
321-
endif()
322-
323-
# =========================================================================================
324-
# debug
325-
# =========================================================================================
326-
327-
if( CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" )
328-
329-
ecbuild_info( "INFO: DEBUG BUILD" )
330-
331-
# Tell C/C++ that we're doing a debug build
332-
add_definitions( -DDEBUG )
333-
334-
endif()
335-
336-
# =========================================================================================
337-
# CLANG: /usr/local/include/boost/type_traits/is_base_and_derived.hpp:226:42:
338-
# fatal error: recursive template instantiation exceeded maximum depth of 256
339-
# =========================================================================================
340-
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
341-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
342-
endif()
343234

344235
# =========================================================================================
345236
# enable clang-format
346237
# =========================================================================================
347238
find_package(ClangFormat)
348239

240+
349241
# =========================================================================================
350242
# build source code
351243
# =========================================================================================
@@ -360,35 +252,6 @@ if (ENABLE_UI)
360252
add_subdirectory( share )
361253
endif()
362254

363-
# =========================================================================================
364-
# DOXYGEN to use: make doxygen -> ${CMAKE_CURRENT_BINARY_DIR}/Doc/doxygen/html/index.html
365-
# =========================================================================================
366-
find_package(Doxygen)
367-
if (DOXYGEN_FOUND)
368-
ecbuild_info( "DOXYGEN_FOUND - use 'make doxygen' first" )
369-
370-
# exclude some dirs not related to documentation
371-
set( DOXYGEN_EXCLUDE_PATTERNS */bin/* */bdir/* */Debug/* */test/* */Doc/* */doc/* */samples/* SCRATCH tools build_scripts cereal )
372-
373-
set( DOXYGEN_SOURCE_BROWSER YES)
374-
set( DOXYGEN_EXTRACT_PRIVATE YES)
375-
set( DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Doc/doxygen")
376-
377-
# this target will only be built if specifically asked to.
378-
# run "make doxygen" to create the doxygen documentation
379-
doxygen_add_docs(
380-
doxygen
381-
${PROJECT_SOURCE_DIR}
382-
COMMENT "Generate documentation for ecFlow"
383-
)
384-
385-
# Add an install target to install the docs, *IF* the use has run 'make doxygen'
386-
if (EXISTS ${DOXYGEN_OUTPUT_DIRECTORY})
387-
install(DIRECTORY ${DOXYGEN_OUTPUT_DIRECTORY} DESTINATION ${CMAKE_INSTALL_DOCDIR})
388-
endif()
389-
else ()
390-
ecbuild_info("Doxygen need to be installed to generate the doxygen documentation")
391-
endif()
392255

393256
# =========================================================================================
394257
# tar ball, by default ecbuild will tar everything apart from hard wired directory called 'build'

cmake/CompilerOptions.cmake

+16
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ ecbuild_info( "CMAKE_CXX_COMPILER_ID : ${CMAKE_CXX_COMPILER_ID}")
3636
ecbuild_info( "CMAKE_CXX_COMPILER_VERSION : ${CMAKE_CXX_COMPILER_VERSION}")
3737

3838

39+
ecbuild_info( "Selected built type: ${CMAKE_BUILD_TYPE}" )
40+
41+
if( CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" )
42+
# Tell C/C++ that we're doing a debug build
43+
add_definitions( -DDEBUG )
44+
endif()
45+
46+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
47+
#
48+
# In case of using Clang, we increase the template depth to avoid the following error:
49+
# /usr/local/include/boost/type_traits/is_base_and_derived.hpp:226:42:
50+
# fatal error: recursive template instantiation exceeded maximum depth of 256
51+
#
52+
ecbuild_add_cxx_flags("-ftemplate-depth=1024")
53+
endif()
54+
3955
if (HAVE_WARNINGS)
4056

4157
ecbuild_add_c_flags(-Wall)

0 commit comments

Comments
 (0)