Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require CMake >= 3.10, fix #338 #620

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions GNUInstallDirs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ Macros
absolute paths where necessary, using the same logic.
#]=======================================================================]

cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced

# Convert a cache variable to PATH type

macro(_GNUInstallDirs_cache_convert_to_path var description)
Expand Down Expand Up @@ -380,5 +377,3 @@ foreach(dir
)
GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_${dir} CMAKE_INSTALL_${dir})
endforeach()

cmake_policy(POP)
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Shared CMake submodule
======================
# Shared CMake submodule

[![Documentation Status](https://readthedocs.org/projects/jrl-cmakemodules/badge/?version=master)](https://jrl-cmakemodules.readthedocs.io/en/master/?badge=master)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/jrl-umi3218/jrl-cmakemodules/master.svg)](https://results.pre-commit.ci/latest/github/jrl-umi3218/jrl-cmakemodules/master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)


This repository is meant to be used as a submodule for any project
from CNRS LAAS/HPP or JRL.

Expand All @@ -20,7 +20,11 @@ You can also checkout the more complete [documentation] of the modules.

[documentation]: http://jrl-cmakemodules.readthedocs.io/en/master/

# pre-commit
## Supported CMake versions

We currently support CMake >= 3.10

## pre-commit

This project use [pre-commit](https://pre-commit.com) and [pre-commit.ci](https://pre-commit.ci).

Expand Down
1 change: 0 additions & 1 deletion _unittests/test_pkg-config.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include(cmake/pkg-config.cmake)

cmake_policy(SET CMP0054 NEW)
# cmake -P
macro(EXPECT_STREQUAL _lhs _rhs)
if(NOT "${_lhs}" STREQUAL ${_rhs})
Expand Down
39 changes: 11 additions & 28 deletions base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
# ------
#

if(${CMAKE_VERSION} VERSION_LESS 3.10)
message(FATAL_ERROR "JRL-CMakemodules require CMake >= 3.10")
endif()

set(PROJECT_JRL_CMAKE_MODULE_DIR
${CMAKE_CURRENT_LIST_DIR}
CACHE INTERNAL "")
Expand Down Expand Up @@ -257,19 +261,9 @@ endmacro(
# LIST : the list. VALUE : the value to be appended.
#
macro(_ADD_TO_LIST_IF_NOT_PRESENT LIST VALUE)
if(CMAKE_VERSION VERSION_GREATER "3.3.0")
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW)
# To be more robust, value should be stripped
if(NOT "${VALUE}" IN_LIST ${LIST})
list(APPEND ${LIST} "${VALUE}")
endif()
cmake_policy(POP)
else()
list(FIND LIST "${VALUE}" _index)
if(${_index} EQUAL -1)
list(APPEND LIST "${VALUE}")
endif()
# To be more robust, value should be stripped
if(NOT "${VALUE}" IN_LIST ${LIST})
list(APPEND ${LIST} "${VALUE}")
endif()
endmacro(
_ADD_TO_LIST_IF_NOT_PRESENT
Expand Down Expand Up @@ -355,22 +349,11 @@ macro(COMPUTE_PROJECT_ARGS _project_VARIABLE)
set(_project_LANGUAGES "CXX")
endif()

if(CMAKE_VERSION VERSION_GREATER "3.0.0")
# CMake >= 3.0
cmake_policy(SET CMP0048 NEW)
set(${_project_VARIABLE} VERSION ${PROJECT_VERSION_FULL} LANGUAGES
${_project_LANGUAGES})

# Append description for CMake >= 3.9
if(CMAKE_VERSION VERSION_GREATER "3.9.0")
set(${_project_VARIABLE} ${${_project_VARIABLE}} DESCRIPTION
${PROJECT_DESCRIPTION})
endif(CMAKE_VERSION VERSION_GREATER "3.9.0")
else(CMAKE_VERSION VERSION_GREATER "3.0.0")
set(${_project_VARIABLE} VERSION ${PROJECT_VERSION_FULL} LANGUAGES
${_project_LANGUAGES})

# CMake < 3.0
set(${_project_VARIABLE} ${_project_LANGUAGES})
endif(CMAKE_VERSION VERSION_GREATER "3.0.0")
set(${_project_VARIABLE} ${${_project_VARIABLE}} DESCRIPTION
${PROJECT_DESCRIPTION})
nim65s marked this conversation as resolved.
Show resolved Hide resolved
endmacro(COMPUTE_PROJECT_ARGS)

# .rst: .. ifmode:: user
Expand Down
4 changes: 0 additions & 4 deletions boost/FindBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake.
include(FindPackageHandleStandardArgs)

# Save project's policies
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
if(POLICY CMP0102)
cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var)
endif()
Expand Down Expand Up @@ -628,8 +626,6 @@ if (NOT Boost_NO_BOOST_CMAKE)
find_package_handle_standard_args(Boost HANDLE_COMPONENTS CONFIG_MODE)
_boost_set_legacy_variables_from_config()

# Restore project's policies
cmake_policy(POP)
return()
endif()
endif()
Expand Down
1 change: 0 additions & 1 deletion cmake_reinstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_policy(SET CMP0007 NEW)
if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
execute_process(COMMAND "@CMAKE_COMMAND@" --build "@PROJECT_BINARY_DIR@" --target uninstall --config $<CONFIGURATION>)
endif()
Expand Down
1 change: 0 additions & 1 deletion cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This files comes from the CMake FAQ: http://www.cmake.org/Wiki/CMake_FAQ
cmake_policy(SET CMP0007 NEW)
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
RETURN()
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
Expand Down
48 changes: 6 additions & 42 deletions cxx11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,16 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.

include(CheckCXXCompilerFlag)

# .rst: .. ifmode:: user
#
# .. command:: CHECK_CXX11_SUPPORT
#
# Set ouput variable CXX11_SUPPORTED to TRUE if C++11 is supported by the
# current compiler. Set to FALSE otherwise.
#
function(CHECK_CXX11_SUPPORT CXX11_SUPPORTED)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)

if(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11)
set(${CXX11_SUPPORTED}
TRUE
PARENT_SCOPE)
else()
set(${CXX11_SUPPORTED}
FALSE
PARENT_SCOPE)
endif()
endfunction(CHECK_CXX11_SUPPORT)

# .rst: .. ifmode:: user
#
# .. command:: PROJECT_USE_CXX11
#
# This macro set up the project to compile the whole project with C++11
# standards.
# DEPRECATED. This macro set up the project to compile the whole project with
# C++11 standards.
#
macro(PROJECT_USE_CXX11)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11)
if(CMAKE_VERSION VERSION_LESS "3.1")
if(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
else()
set(CMAKE_CXX_STANDARD 11)
set(CXX_STANDARD_REQUIRED ON)
endif()
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
message(
DEPRECATION
"This macro is deprecated. Use CHECK_MINIMAL_CXX_STANDARD instead.")
check_minimal_cxx_standard(11 REQUIRED)
endmacro(PROJECT_USE_CXX11)
2 changes: 1 addition & 1 deletion cython/python/FindPython/Support.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This file is a "template" file used by various FindPython modules.
#

cmake_policy (VERSION 3.5)
cmake_policy (VERSION 3.10)

#
# Initial configuration
Expand Down
7 changes: 0 additions & 7 deletions find-external/OpenMP/FindOpenMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ should use the ``OpenMP_<lang>_INCLUDE_DIRS`` _output_ variable if it needs
to know what include directories are needed.
#]=======================================================================]

cmake_policy(PUSH)
cmake_policy(SET CMP0012 NEW) # if() recognizes numbers and booleans
cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
cmake_policy(SET CMP0057 NEW) # if IN_LIST

function(_OPENMP_FLAG_CANDIDATES LANG)
if(NOT OpenMP_${LANG}_FLAG)
unset(OpenMP_FLAG_CANDIDATES)
Expand Down Expand Up @@ -775,5 +770,3 @@ unset(OpenMP_Fortran_TEST_SOURCE)
unset(OpenMP_C_CXX_CHECK_VERSION_SOURCE)
unset(OpenMP_Fortran_CHECK_VERSION_SOURCE)
unset(OpenMP_Fortran_INCLUDE_LINE)

cmake_policy(POP)
6 changes: 1 addition & 5 deletions logging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ endif(UNIX)
#
function(LOGGING_INITIALIZE)
# Retrieve interesting information.
if(${CMAKE_VERSION} VERSION_LESS 2.8)
set(HOSTNAME "unknown (CMake >= 2.8 required)")
else()
site_name(HOSTNAME)
endif()
site_name(HOSTNAME)

# Write logging file.
file(REMOVE ${JRL_CMAKEMODULE_LOGGING_FILENAME})
Expand Down
4 changes: 0 additions & 4 deletions msvc-specific.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ macro(REQUIRE_MINIMUM_MSVC_VERSION VERSION)
endif(${MSVC_TOOLS_VERSION})
endmacro(REQUIRE_MINIMUM_MSVC_VERSION)

if(${CMAKE_VERSION} VERSION_LESS "3.5.0")
include(CMakeParseArguments)
endif()

# GENERATE_MSVC_DOT_USER_FILE(<name> [<additional_path>])
# GENERATE_MSVC_DOT_USER_FILE(NAME <name> [COMMAND <command>] [COMMAND_ARGS
# <args>] [WORKING_DIRECTORY <dir>] [ADDITIONAL_PATH <additional_path>])
Expand Down
8 changes: 0 additions & 8 deletions python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@
# nothing for CMake < 3.12 which doesn't have those. This also export: -
# `FIND_NUMPY` and/or `SEARCH_FOR_BOOST_PYTHON` if necessary.

if(CMAKE_VERSION VERSION_LESS "3.2")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/python ${CMAKE_MODULE_PATH})
message(
STATUS
"CMake versions older than 3.2 do not properly find Python. Custom macros are used to find it."
)
endif(CMAKE_VERSION VERSION_LESS "3.2")

macro(FINDPYTHON)
if(DEFINED FINDPYTHON_ALREADY_CALLED)
message(
Expand Down
Loading