Skip to content

Commit

Permalink
Suppressing cmake warning issued by cmake > V3.11
Browse files Browse the repository at this point in the history
- factored out cmake_policy
  • Loading branch information
hkaiser committed Feb 22, 2018
1 parent 6fbd8e1 commit aa296ff
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
35 changes: 16 additions & 19 deletions CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2007-2017 Hartmut Kaiser
# Copyright (c) 2007-2018 Hartmut Kaiser
# Copyright (c) 2011-2014 Thomas Heller
# Copyright (c) 2007-2008 Chirag Dekate
# Copyright (c) 2011 Bryce Lelbach
Expand All @@ -15,17 +15,6 @@
# We require at least CMake V3.3.2
cmake_minimum_required(VERSION 3.3.2 FATAL_ERROR)

# explicitly set certain policies
cmake_policy(VERSION 3.3.2)
macro(hpx_set_cmake_policy policy value)
if(POLICY ${policy})
cmake_policy(SET ${policy} ${value})
endif()
endmacro()
hpx_set_cmake_policy(CMP0042 NEW)
hpx_set_cmake_policy(CMP0054 OLD)
hpx_set_cmake_policy(CMP0060 NEW)

# Overrides must go before the project() statement, otherwise they are ignored.

################################################################################
Expand Down Expand Up @@ -60,25 +49,33 @@ set(HPX_LIBRARY_VERSION "${HPX_VERSION}")
set(HPX_SOVERSION ${HPX_MAJOR_VERSION})
set(HPX_PACKAGE_NAME HPX)

if(MSVC)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

################################################################################
# CMake configuration
################################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

# We safe the passed compiler flag to a special variable. This is needed for our
# build system unit tests. Some flags might influence the created symbols (
# _GLIBCXX_DEBUG i look at you)
include(HPX_Utils)

# explicitly set certain policies
cmake_policy(VERSION 3.3.2)
hpx_set_cmake_policy(CMP0042 NEW)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
# the old behavior not supported for newer cmake versions anymore
hpx_set_cmake_policy(CMP0054 OLD)
endif()
hpx_set_cmake_policy(CMP0060 NEW)

# We save the passed compiler flag to a special variable. This is needed for our
# build system unit tests. Some flags might influence the created symbols
# (_GLIBCXX_DEBUG i look at you)
set(CMAKE_CXX_FLAGS_SAFE ${CMAKE_CXX_FLAGS})

include(CheckCXXCompilerFlag)
include(CMakeDependentOption)

# include additional macro definitions
include(HPX_Utils)
include(HPX_ExportTargets)
include(HPX_Libraries)
include(HPX_LibraryDir)
Expand Down
10 changes: 10 additions & 0 deletions cmake/HPX_SetCMakePolicy.cmake
@@ -0,0 +1,10 @@
# Copyright (c) 2018 Hartmut Kaiser
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

macro(hpx_set_cmake_policy policy value)
if(POLICY ${policy})
cmake_policy(SET ${policy} ${value})
endif()
endmacro()
17 changes: 6 additions & 11 deletions cmake/HPX_SetupTarget.cmake
@@ -1,14 +1,13 @@
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2007-2017 Hartmut Kaiser
# Copyright (c) 2007-2018 Hartmut Kaiser
# Copyright (c) 2011 Bryce Lelbach
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

cmake_policy(PUSH)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()

hpx_set_cmake_policy(CMP0054 NEW)

function(hpx_setup_target target)
# retrieve arguments
Expand Down Expand Up @@ -81,16 +80,12 @@ function(hpx_setup_target target)
if(HPX_WITH_STATIC_LINKING)
set(target_STATIC_LINKING ON)
else()
if(POLICY CMP0045)
cmake_policy(PUSH)
cmake_policy(SET CMP0045 OLD)
endif()
cmake_policy(PUSH)
hpx_set_cmake_policy(CMP0045 OLD)

get_target_property(_hpx_library_type hpx TYPE)

if(POLICY CMP0045)
cmake_policy(POP)
endif()
cmake_policy(POP)

if("${_hpx_library_type}" STREQUAL "STATIC_LIBRARY")
set(target_STATIC_LINKING ON)
Expand Down
1 change: 1 addition & 0 deletions cmake/HPX_Utils.cmake
Expand Up @@ -26,6 +26,7 @@ hpx_include(
IsTarget
HandleComponentDependencies
ForceOutOfTreeBuild
SetCMakePolicy
SetLibName
SetupTarget
)
Expand Down

0 comments on commit aa296ff

Please sign in to comment.