Skip to content

Commit

Permalink
Silence CMake warnings ECFLOW-1936
Browse files Browse the repository at this point in the history
Silence CMake warnings regarding the policies: CMP0046, CMP0144 and CMP0148
  • Loading branch information
marcosbento authored Jan 3, 2024
2 parents 21f37df + c742571 commit b192f43
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ option( ENABLE_HTTP "Enable HTTP server (experimental)" ON )
option( ENABLE_UDP "Enable UDP server (experimental)" ON )
option( ENABLE_DOCS "Enable Documentation" OFF )

include(Policies NO_POLICY_SCOPE)

# =========================================================================================
# Dependency: Qt
Expand Down
18 changes: 10 additions & 8 deletions Pyext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ else()
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()
Expand Down Expand Up @@ -226,6 +227,11 @@ else()
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
Expand All @@ -235,15 +241,11 @@ 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)
if ( Python3_LIBRARIES )
ecbuild_find_python( VERSION ${Python3_VERSION} REQUIRED )
set(ECF_PYTHON_FOUND "ECF_PYTHON_FOUND")
add_subdirectory( python3 )
else()
message( STATUS " python3 libraries *NOT* found" )
endif()
# 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()
Expand Down
15 changes: 0 additions & 15 deletions Viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,5 @@
# nor does it submit to any jurisdiction.
#

# avoid warning about dependency targets that don't exist
#
# CMake Warning (dev) at Viewer/src/CMakeLists.txt:261 (ADD_DEPENDENCIES):
# Policy CMP0046 is not set: Error on non-existent dependency in
# add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
# Use the cmake_policy command to set the policy and suppress this warning.
#
# The dependency target
# "/tmp/ma0/workspace/ecflow/Viewer/src/../images/zombie_dock.svg" of target
# "Qt_resource_cpp" does not exist.

if (POLICY CMP0046)
cmake_policy(SET CMP0046 OLD)
endif()

add_subdirectory( libViewer)
add_subdirectory( ecflowUI)
3 changes: 1 addition & 2 deletions Viewer/ecflowUI/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,7 @@ endif()
# add all the images as dependencies of the resource file so that it is
# automatically recompiled when an image changes
file(GLOB image_files "${CMAKE_CURRENT_SOURCE_DIR}/../images/*.*")
add_custom_target(Qt_resource_cpp DEPENDS ${VIEWER_RES})
add_dependencies(Qt_resource_cpp ${image_files})
add_custom_target(Qt_resource_cpp DEPENDS ${VIEWER_RES} ${image_files})

ecbuild_add_executable(
TARGET
Expand Down
27 changes: 27 additions & 0 deletions cmake/Policies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# 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.
#

# =========================================================================================
# Setup project-wide CMake Policies
# =========================================================================================

#
# CMake Policy CMP0144 (CMake >=3.27)
#
# OLD behaviour:
# find_package(PackageName) used only case-preserved <PackageName>_ROOT variables
#
# NEW behaviour:
# find_package(PackageName) uses upper-case <PACKAGENAME>_ROOT variables,
# in addition to <PackageName>_ROOT variables.
#
if(POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()

0 comments on commit b192f43

Please sign in to comment.