Skip to content

Commit

Permalink
link against hpx_core
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorostsa committed Feb 15, 2024
1 parent 1798cbc commit f34103e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 43 deletions.
37 changes: 25 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2020 Mikael Simberg
# Copyright (c) 2007-2024 Hartmut Kaiser
# Copyright (c) 2011-2014 Thomas Heller
# Copyright (c) 2024 Isidoros Tsaousis-Seiras
# Copyright (c) 2007-2008 Chirag Dekate
# Copyright (c) 2011 Bryce Lelbach
# Copyright (c) 2011 Vinay C Amatya
Expand Down Expand Up @@ -589,25 +590,37 @@ hpx_option(
ADVANCED
)

# if STDEXEC_ROOT was provided, HPX_WITH_STDEXEC is set to ON
if(STDEXEC_ROOT OR HPX_WITH_FETCH_STDEXEC)
if(Stdexec_ROOT OR HPX_WITH_FETCH_STDEXEC)
# explicitly enable HPX_WITH_STDEXEC
set(HPX_WITH_STDEXEC ON)

hpx_add_config_define(HPX_HAVE_STDEXEC)
# prefer Stdexec_ROOT over HPX_WITH_FETCH_STDEXEC by default
if(Stdexec_ROOT AND HPX_WITH_FETCH_STDEXEC)
set(HPX_WITH_FETCH_STDEXEC OFF)
hpx_warn(
"Both Stdexec_ROOT and HPX_WITH_FETCH_STDEXEC are provided. HPX_WITH_FETCH_STDEXEC is set to OFF."
)
endif()
elseif(HPX_WITH_STDEXEC)
hpx_error(
"HPX_WITH_STDEXEC is set to ON, but STDEXEC_ROOT is not provided. Please provide STDEXEC_ROOT or set HPX_WITH_FETCH_STDEXEC to ON."
"HPX_WITH_STDEXEC is set to ON, but Stdexec_ROOT is not provided and HPX_WITH_FETCH_STDEXEC is not enabled. Please provide Stdexec_ROOT or set HPX_WITH_FETCH_STDEXEC to ON."
)
endif()

if(HPX_WITH_STDEXEC)
# need cxx20 and over
if(HPX_WITH_CXX_STANDARD LESS 20)
hpx_error(
"HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher."
)
endif()
hpx_info("STDEXEC is enabled.")
# STDEXEC requires C++20
if(HPX_WITH_STDEXEC AND HPX_WITH_CXX_STANDARD LESS 20)
hpx_error(
"HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher."
)
endif()

if(HPX_WITH_FETCH_STDEXEC)
hpx_option(
HPX_WITH_STDEXEC_TAG
STRING "STDEXEC repository tag or branch"
"main"
CATEGORY "Executor"
)
endif()

# ##############################################################################
Expand Down
8 changes: 5 additions & 3 deletions cmake/FindStdexec.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) 2024 Isidoros Tsaousis-Seiras
#
# 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 STDEXEC::stdexec)
if (STDEXEC_ROOT AND NOT Stdexec_ROOT)
Expand Down Expand Up @@ -29,8 +34,5 @@ if(NOT TARGET STDEXEC::stdexec)
add_library(STDEXEC::stdexec INTERFACE IMPORTED)
target_include_directories(STDEXEC::stdexec SYSTEM INTERFACE ${Stdexec_INCLUDE_DIR})




mark_as_advanced(Stdexec_INCLUDE_DIR Stdexec_ROOT)
endif()
59 changes: 31 additions & 28 deletions cmake/HPX_SetupStdexec.cmake
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
if(STDEXEC_ROOT AND NOT Stdexec_ROOT)
set(Stdexec_ROOT
${STDEXEC_ROOT}
CACHE PATH "STDEXEC base directory"
)
unset(STDEXEC_ROOT CACHE)
endif()
# Copyright (c) 2024 Isidoros Tsaousis-Seiras
#
# 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(HPX_WITH_FETCH_STDEXEC AND NOT Stdexec_ROOT)
hpx_info(
"HPX_WITH_FETCH_STDEXEC=${HPX_WITH_FETCH_STDEXEC}, Stdexec will be fetched using CMake's FetchContent."
)
if(UNIX)
include(FetchContent)
FetchContent_Declare(
Stdexec
GIT_REPOSITORY https://github.com/NVIDIA/stdexec.git
GIT_TAG main
if(HPX_WITH_STDEXEC AND NOT TARGET STDEXEC::stdexec)
hpx_add_config_define(HPX_HAVE_STDEXEC)

if(HPX_WITH_FETCH_STDEXEC)
hpx_info(
"HPX_WITH_FETCH_STDEXEC=${HPX_WITH_FETCH_STDEXEC}, Stdexec will be fetched using CMake's FetchContent."
)
FetchContent_MakeAvailable(Stdexec)
endif()
if(UNIX)
include(FetchContent)
message("FETCHING STDEXEC")
FetchContent_Declare(
Stdexec
GIT_REPOSITORY https://github.com/NVIDIA/stdexec.git
GIT_TAG ${HPX_WITH_STDEXEC_TAG}
)
FetchContent_MakeAvailable(Stdexec)
endif()

add_library(STDEXEC::stdexec INTERFACE IMPORTED)
target_include_directories(STDEXEC::stdexec INTERFACE ${stdexec_SOURCE_DIR}/include)
target_link_libraries(STDEXEC::stdexec INTERFACE ${Stdexec_LIBRARY})
elseif(HPX_WITH_STDEXEC)
find_package(Stdexec REQUIRED)
# add_library(STDEXEC::stdexec INTERFACE IMPORTED)
# target_include_directories(STDEXEC::stdexec INTERFACE ${stdexec_SOURCE_DIR})
# target_link_libraries(STDEXEC::stdexec INTERFACE ${Stdexec_LIBRARY})
else()
find_package(Stdexec REQUIRED)

if(NOT Stdexec_FOUND)
hpx_error(
"Stdexec could not be found, please specify Stdexec_ROOT to point to the correct location"
)
if(NOT Stdexec_FOUND)
hpx_error(
"Stdexec could not be found, please specify Stdexec_ROOT to point to the correct location"
)
endif()
endif()
endif()
9 changes: 9 additions & 0 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ if(TARGET APEX::apex)
target_link_libraries(hpx_full INTERFACE APEX::apex)
endif()

# Do I need this here?
# if(TARGET STDEXEC::stdexec)
# target_link_libraries(hpx_full INTERFACE STDEXEC::stdexec)
# endif()

if(TARGET Gperftools::gperftools)
target_link_libraries(hpx_full PRIVATE Gperftools::gperftools)
endif()
Expand Down Expand Up @@ -376,6 +381,10 @@ if(HPX_WITH_ITTNOTIFY)
target_link_libraries(hpx_core PUBLIC Amplifier::amplifier)
endif()

if(TARGET STDEXEC::stdexec)
target_link_libraries(hpx_core INTERFACE STDEXEC::stdexec)
endif()

if(HPX_WITH_PARCELPORT_GASNET AND GASNET_LIBRARY_DIRS)
target_link_directories(hpx_core PUBLIC ${GASNET_LIBRARY_DIRS})
endif()
Expand Down

0 comments on commit f34103e

Please sign in to comment.