Skip to content

Commit

Permalink
Adapting build system for CMake V3.27
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Aug 7, 2023
1 parent 0e95981 commit 4db1508
Show file tree
Hide file tree
Showing 60 changed files with 966 additions and 651 deletions.
33 changes: 22 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ hpx_option(
)
if(HPX_WITH_EXAMPLES_TBB)
find_package(TBB)
if(NOT TBB_FOUND)
if(NOT Tbb_FOUND)
set(HPX_WITH_EXAMPLES_TBB OFF)
endif()
endif()
Expand All @@ -1277,7 +1277,7 @@ hpx_option(
)
if(HPX_WITH_EXAMPLES_QTHREADS)
find_package(QThreads)
if(NOT QTHREADS_FOUND)
if(NOT Qthreads_FOUND)
set(HPX_WITH_EXAMPLES_QTHREADS OFF)
endif()
endif()
Expand All @@ -1290,7 +1290,7 @@ hpx_option(
)
if(HPX_WITH_EXAMPLES_HDF5)
find_package(HDF5 COMPONENTS CXX)
if(NOT HDF5_FOUND)
if(NOT Hdf5_FOUND)
set(HPX_WITH_EXAMPLES_HDF5 OFF)
endif()
endif()
Expand All @@ -1305,7 +1305,7 @@ if(NOT "${HPX_PLATFORM_UC}" STREQUAL "BLUEGENEQ")
)
if(HPX_WITH_EXAMPLES_QT4)
find_package(Qt4)
if(NOT QT4_FOUND)
if(NOT Qt4_FOUND)
set(HPX_WITH_EXAMPLES_QT4 OFF)
endif()
endif()
Expand Down Expand Up @@ -2295,12 +2295,23 @@ add_subdirectory(components)
# ##############################################################################
# Tests
# ##############################################################################
find_package(PythonInterp)
if(POLICY CMP0148)
find_package(Python COMPONENTS Interpreter)
if(NOT Python_FOUND)
hpx_warn(
"A python interpreter could not be found. The test suite can not be run automatically."
)
endif()

if(NOT PYTHONINTERP_FOUND)
hpx_warn(
"A python interpreter could not be found. The test suite can not be run automatically."
)
else()
find_package(PythonInterp)
if(NOT PYTHONINTERP_FOUND)
hpx_warn(
"A python interpreter could not be found. The test suite can not be run automatically."
)
else()
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
endif()

if(HPX_WITH_TESTS)
Expand All @@ -2326,7 +2337,7 @@ if(HPX_WITH_TOOLS OR HPX_WITH_TESTS_BENCHMARKS)
endif()

# Configure hpxrun.py
if(PYTHONINTERP_FOUND)
if(PYTHONINTERP_FOUND OR Python_FOUND)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/hpxrun.py.in"
"${PROJECT_BINARY_DIR}/bin/hpxrun.py" @ONLY
Expand Down Expand Up @@ -2451,7 +2462,7 @@ endif()
# ##############################################################################
# installation instructions
# ##############################################################################
if(PYTHONINTERP_FOUND)
if(PYTHONINTERP_FOUND OR Python_FOUND)
install(
FILES "${PROJECT_BINARY_DIR}/bin/hpxrun.py"
DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand Down
53 changes: 31 additions & 22 deletions cmake/FindAmplifier.cmake
Original file line number Diff line number Diff line change
@@ -1,64 +1,73 @@
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2012 Hartmut Kaiser
# Copyright (c) 2012-2023 Hartmut Kaiser
#
# SPDX-License-Identifier: BSL-1.0
# 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)

if(NOT TARGET Amplifier::amplifier)
# compatibility with older CMake versions
if(AMPLIFIER_ROOT AND NOT Amplifier_ROOT)
set(Amplifier_ROOT
${AMPLIFIER_ROOT}
CACHE PATH "Amplifier base directory"
)
unset(AMPLIFIER_ROOT CACHE)
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(PC_AMPLIFIER QUIET amplifier)

find_path(
AMPLIFIER_INCLUDE_DIR ittnotify.h
HINTS ${AMPLIFIER_ROOT} ENV AMPLIFIER_ROOT ${PC_AMPLIFIER_INCLUDEDIR}
${PC_AMPLIFIER_INCLUDE_DIRS}
Amplifier_INCLUDE_DIR ittnotify.h
HINTS ${Amplifier_ROOT} ENV AMPLIFIER_ROOT ${PC_Amplifier_INCLUDEDIR}
${PC_Amplifier_INCLUDE_DIRS}
PATH_SUFFIXES include
)

find_library(
AMPLIFIER_LIBRARY
Amplifier_LIBRARY
NAMES ittnotify libittnotify
HINTS ${AMPLIFIER_ROOT} ENV AMPLIFIER_ROOT ${PC_AMPLIFIER_LIBDIR}
${PC_AMPLIFIER_LIBRARY_DIRS}
HINTS ${Amplifier_ROOT} ENV AMPLIFIER_ROOT ${PC_Amplifier_LIBDIR}
${PC_Amplifier_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)

# Set AMPLIFIER_ROOT in case the other hints are used
if(AMPLIFIER_ROOT)
# Set Amplifier_ROOT in case the other hints are used
if(Amplifier_ROOT)
# The call to file is for compatibility for windows paths
file(TO_CMAKE_PATH ${AMPLIFIER_ROOT} AMPLIFIER_ROOT)
file(TO_CMAKE_PATH ${Amplifier_ROOT} Amplifier_ROOT)
elseif("$ENV{AMPLIFIER_ROOT}")
file(TO_CMAKE_PATH $ENV{AMPLIFIER_ROOT} AMPLIFIER_ROOT)
file(TO_CMAKE_PATH $ENV{AMPLIFIER_ROOT} Amplifier_ROOT)
else()
file(TO_CMAKE_PATH "${AMPLIFIER_INCLUDE_DIR}" AMPLIFIER_INCLUDE_DIR)
string(REPLACE "/include" "" AMPLIFIER_ROOT "${AMPLIFIER_INCLUDE_DIR}")
file(TO_CMAKE_PATH "${Amplifier_INCLUDE_DIR}" Amplifier_INCLUDE_DIR)
string(REPLACE "/include" "" Amplifier_ROOT "${Amplifier_INCLUDE_DIR}")
endif()

set(AMPLIFIER_LIBRARIES ${AMPLIFIER_LIBRARY})
set(AMPLIFIER_INCLUDE_DIRS ${AMPLIFIER_INCLUDE_DIR})
set(Amplifier_LIBRARIES ${Amplifier_LIBRARY})
set(Amplifier_INCLUDE_DIRS ${Amplifier_INCLUDE_DIR})

find_package_handle_standard_args(
Amplifier DEFAULT_MSG AMPLIFIER_LIBRARY AMPLIFIER_INCLUDE_DIR
Amplifier DEFAULT_MSG Amplifier_LIBRARY Amplifier_INCLUDE_DIR
)

get_property(
_type
CACHE AMPLIFIER_ROOT
CACHE Amplifier_ROOT
PROPERTY TYPE
)
if(_type)
set_property(CACHE AMPLIFIER_ROOT PROPERTY ADVANCED 1)
set_property(CACHE Amplifier_ROOT PROPERTY ADVANCED 1)
if("x${_type}" STREQUAL "xUNINITIALIZED")
set_property(CACHE AMPLIFIER_ROOT PROPERTY TYPE PATH)
set_property(CACHE Amplifier_ROOT PROPERTY TYPE PATH)
endif()
endif()

mark_as_advanced(AMPLIFIER_ROOT AMPLIFIER_LIBRARY AMPLIFIER_INCLUDE_DIR)
mark_as_advanced(Amplifier_ROOT Amplifier_LIBRARY Amplifier_INCLUDE_DIR)

add_library(Amplifier::amplifier INTERFACE IMPORTED)
target_include_directories(
Amplifier::amplifier SYSTEM INTERFACE ${AMPLIFIER_INCLUDE_DIR}
Amplifier::amplifier SYSTEM INTERFACE ${Amplifier_INCLUDE_DIR}
)
target_link_libraries(Amplifier::amplifier INTERFACE ${AMPLIFIER_LIBRARIES})
target_link_libraries(Amplifier::amplifier INTERFACE ${Amplifier_LIBRARIES})
endif()
46 changes: 28 additions & 18 deletions cmake/FindAsio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,67 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

if(NOT TARGET Asio::asio)
# compatibility with older CMake versions
if(ASIO_ROOT AND NOT Asio_ROOT)
set(Asio_ROOT
${ASIO_ROOT}
CACHE PATH "Asio base directory"
)
unset(ASIO_ROOT CACHE)
endif()

find_path(
ASIO_INCLUDE_DIR asio.hpp
HINTS "${ASIO_ROOT}" ENV ASIO_ROOT "${HPX_ASIO_ROOT}"
Asio_INCLUDE_DIR asio.hpp
HINTS "${Asio_ROOT}" ENV ASIO_ROOT "${HPX_ASIO_ROOT}"
PATH_SUFFIXES include
)

if(NOT ASIO_INCLUDE_DIR)
if(NOT Asio_INCLUDE_DIR)
hpx_error(
"Could not find Asio. Set ASIO_ROOT as a CMake or environment variable to point to the Asio root install directory. Alternatively, set HPX_WITH_FETCH_ASIO=ON to fetch Asio using CMake's FetchContent (when using this option Asio will be installed together with HPX, be careful about conflicts with separately installed versions of Asio)."
"Could not find Asio. Set Asio_ROOT as a CMake or environment variable to point to the Asio root install directory. Alternatively, set HPX_WITH_FETCH_ASIO=ON to fetch Asio using CMake's FetchContent (when using this option Asio will be installed together with HPX, be careful about conflicts with separately installed versions of Asio)."
)
endif()

# Set ASIO_ROOT in case the other hints are used
if(ASIO_ROOT)
# Set Asio_ROOT in case the other hints are used
if(Asio_ROOT)
# The call to file is for compatibility with windows paths
file(TO_CMAKE_PATH ${ASIO_ROOT} ASIO_ROOT)
file(TO_CMAKE_PATH ${Asio_ROOT} Asio_ROOT)
elseif("$ENV{ASIO_ROOT}")
file(TO_CMAKE_PATH $ENV{ASIO_ROOT} ASIO_ROOT)
file(TO_CMAKE_PATH $ENV{ASIO_ROOT} Asio_ROOT)
else()
file(TO_CMAKE_PATH "${ASIO_INCLUDE_DIR}" ASIO_INCLUDE_DIR)
string(REPLACE "/include" "" ASIO_ROOT "${ASIO_INCLUDE_DIR}")
file(TO_CMAKE_PATH "${Asio_INCLUDE_DIR}" Asio_INCLUDE_DIR)
string(REPLACE "/include" "" Asio_ROOT "${Asio_INCLUDE_DIR}")
endif()

if(ASIO_INCLUDE_DIR AND EXISTS "${ASIO_INCLUDE_DIR}/asio/version.hpp")
if(Asio_INCLUDE_DIR AND EXISTS "${Asio_INCLUDE_DIR}/asio/version.hpp")
# Matches a line of the form:
#
# #define ASIO_VERSION XXYYZZ // XX.YY.ZZ
#
# with arbitrary whitespace between the tokens
file(
STRINGS "${ASIO_INCLUDE_DIR}/asio/version.hpp" ASIO_VERSION_DEFINE_LINE
STRINGS "${Asio_INCLUDE_DIR}/asio/version.hpp" Asio_VERSION_DEFINE_LINE
REGEX
"#define[ \t]+ASIO_VERSION[ \t]+[0-9]+[ \t]+//[ \t]+[0-9]+\.[0-9]+\.[0-9]+[ \t]*"
)
# Extracts the dotted version number after the comment as
# ASIO_VERSION_STRING
# Asio_VERSION_STRING
string(REGEX
REPLACE "#define ASIO_VERSION [0-9]+ // ([0-9]+\.[0-9]+\.[0-9]+)"
"\\1" ASIO_VERSION_STRING "${ASIO_VERSION_DEFINE_LINE}"
"\\1" Asio_VERSION_STRING "${Asio_VERSION_DEFINE_LINE}"
)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Asio
REQUIRED_VARS ASIO_INCLUDE_DIR
VERSION_VAR ASIO_VERSION_STRING
REQUIRED_VARS Asio_INCLUDE_DIR
VERSION_VAR Asio_VERSION_STRING
FOUND_VAR Asio_FOUND
)

add_library(Asio::asio INTERFACE IMPORTED)
target_include_directories(Asio::asio SYSTEM INTERFACE ${ASIO_INCLUDE_DIR})
target_include_directories(Asio::asio SYSTEM INTERFACE ${Asio_INCLUDE_DIR})

mark_as_advanced(ASIO_ROOT ASIO_INCLUDE_DIR ASIO_VERSION_STRING)
mark_as_advanced(Asio_ROOT Asio_INCLUDE_DIR Asio_VERSION_STRING)
endif()
17 changes: 13 additions & 4 deletions cmake/FindBreathe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
# 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)

# compatibility with older CMake versions
if(BREATHE_APIDOC_ROOT AND NOT Breathe_APIDOC_ROOT)
set(Breathe_APIDOC_ROOT
${BREATHE_APIDOC_ROOT}
CACHE PATH "Breathe base directory"
)
unset(BREATHE_ROOT CACHE)
endif()

find_program(
BREATHE_APIDOC_EXECUTABLE
Breathe_APIDOC_EXECUTABLE
NAMES breathe-apidoc
PATHS ${BREATHE_APIDOC_ROOT} ENV BREATHE_APIDOC_ROOT
PATHS ${Breathe_APIDOC_ROOT} ENV Breathe_APIDOC_ROOT
DOC "Path to breathe-apidoc executable"
)

if(BREATHE_APIDOC_EXECUTABLE)
if(Breathe_APIDOC_EXECUTABLE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Breathe DEFAULT_MESSAGE BREATHE_APIDOC_EXECUTABLE
Breathe DEFAULT_MESSAGE Breathe_APIDOC_EXECUTABLE
)
endif()
Loading

0 comments on commit 4db1508

Please sign in to comment.