Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
35 changes: 22 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,22 @@ if (STDEXEC_ENABLE_NUMA)
target_compile_definitions(stdexec INTERFACE STDEXEC_ENABLE_NUMA)
endif()

set(SYSTEM_CONTEXT_SOURCES src/system_context/system_context.cpp)
add_library(system_context ${SYSTEM_CONTEXT_SOURCES})
target_compile_features(system_context PUBLIC cxx_std_20)
set_target_properties(system_context PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_compile_options(system_context PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Zc:__cplusplus /Zc:preprocessor /Zc:externConstexpr>
)
add_library(STDEXEC::system_context ALIAS system_context)
target_link_libraries(system_context PUBLIC stdexec)
option(STDEXEC_BUILD_SYSTEM_CONTEXT "Build the system_context compiled library" OFF)

if(STDEXEC_BUILD_SYSTEM_CONTEXT)
set(SYSTEM_CONTEXT_SOURCES src/system_context/system_context.cpp)
add_library(system_context ${SYSTEM_CONTEXT_SOURCES})
target_compile_features(system_context PUBLIC cxx_std_20)
set_target_properties(system_context PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_compile_options(system_context PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Zc:__cplusplus /Zc:preprocessor /Zc:externConstexpr>
)
add_library(STDEXEC::system_context ALIAS system_context)
target_link_libraries(system_context PUBLIC stdexec)
endif()


option(STDEXEC_ENABLE_IO_URING "Enable the use of the io_uring scheduler on Linux" OFF)
Expand Down Expand Up @@ -495,7 +499,12 @@ endif()

include(CPack)

install(TARGETS stdexec system_context
set(stdexec_install_targets stdexec)
if(STDEXEC_BUILD_SYSTEM_CONTEXT)
list(APPEND stdexec_install_targets system_context)
endif()

install(TARGETS ${stdexec_install_targets}
EXPORT stdexec-exports
FILE_SET headers
FILE_SET version_config)
Expand Down
25 changes: 22 additions & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class StdexecPackage(ConanFile):
license = "Apache 2.0"

settings = "os", "arch", "compiler", "build_type"
options = {
"system_context": [True, False],
}
default_options = {
"system_context": False,
}
exports_sources = (
"include/*",
"src/*",
Expand All @@ -24,6 +30,12 @@ class StdexecPackage(ConanFile):
)
generators = "CMakeToolchain"

def configure(self):
if self.options.system_context:
self.package_type = "static-library"
else:
self.package_type = "header-library"

def validate(self):
check_min_cppstd(self, "20")

Expand All @@ -37,18 +49,21 @@ def layout(self):

def build(self):
tests = "OFF" if self.conf.get("tools.build:skip_test", default=False) else "ON"
system_context = "ON" if self.options.system_context else "OFF"

cmake = CMake(self)
cmake.configure(variables={
"STDEXEC_BUILD_TESTS": tests,
"STDEXEC_BUILD_EXAMPLES": tests,
"STDEXEC_BUILD_SYSTEM_CONTEXT": system_context,
})
cmake.build()
cmake.test()

def package_id(self):
# Clear settings because this package is header-only.
self.info.clear()
if not self.info.options.system_context:
# Clear settings because this package is header-only.
self.info.clear()

def package(self):
cmake = CMake(self)
Expand All @@ -58,4 +73,8 @@ def package_info(self):
self.cpp_info.set_property("cmake_file_name", "P2300")
self.cpp_info.set_property("cmake_target_name", "P2300::P2300")
self.cpp_info.set_property("cmake_target_aliases", ["STDEXEC::stdexec"])
self.cpp_info.libs = ["system_context"]
if self.options.system_context:
self.cpp_info.components["system_context"].libs = ["system_context"]
self.cpp_info.components["system_context"].set_property(
"cmake_target_name", "STDEXEC::system_context"
)
26 changes: 14 additions & 12 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,19 @@ target_link_libraries(test.stdexec
PRIVATE
common_test_settings)

add_executable(test.system_context_replaceability
test_main.cpp
stdexec/schedulers/test_system_context_replaceability.cpp)
target_link_libraries(test.system_context_replaceability
PUBLIC
STDEXEC::stdexec
STDEXEC::system_context
stdexec_executable_flags
Catch2::Catch2
PRIVATE
common_test_settings)
if(STDEXEC_BUILD_SYSTEM_CONTEXT)
add_executable(test.system_context_replaceability
test_main.cpp
stdexec/schedulers/test_system_context_replaceability.cpp)
target_link_libraries(test.system_context_replaceability
PUBLIC
STDEXEC::stdexec
STDEXEC::system_context
stdexec_executable_flags
Catch2::Catch2
PRIVATE
common_test_settings)
endif()

add_executable(test.scratch test_main.cpp test_scratch.cpp)
target_link_libraries(test.scratch
Expand All @@ -129,7 +131,7 @@ include(${icm_SOURCE_DIR}/icm_build_failure_testing.cmake)

catch_discover_tests(test.stdexec)
catch_discover_tests(test.scratch)
if(NOT STDEXEC_ENABLE_CUDA)
if(STDEXEC_BUILD_SYSTEM_CONTEXT AND NOT STDEXEC_ENABLE_CUDA)
catch_discover_tests(test.system_context_replaceability)
endif()

Expand Down
5 changes: 4 additions & 1 deletion test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ enable_testing()
find_package(P2300 REQUIRED)

add_executable(test_stdexec test.cpp)
target_link_libraries(test_stdexec STDEXEC::stdexec)
target_link_libraries(test_stdexec STDEXEC::stdexec $<TARGET_NAME_IF_EXISTS:STDEXEC::system_context>)
if(TARGET STDEXEC::system_context)
target_compile_definitions(test_stdexec PRIVATE STDEXEC_TEST_SYSTEM_CONTEXT)
endif()
add_test(test_stdexec test_stdexec)
9 changes: 9 additions & 0 deletions test_package/test.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#ifdef STDEXEC_TEST_SYSTEM_CONTEXT
#include <exec/system_context.hpp>
#else
#include <exec/static_thread_pool.hpp>
#endif
#include <stdexec/execution.hpp>

#include <cstdlib>

int main()
{
#ifdef STDEXEC_TEST_SYSTEM_CONTEXT
auto x = stdexec::starts_on(exec::get_parallel_scheduler(), stdexec::just(42));
#else
exec::static_thread_pool pool{1};
auto x = stdexec::starts_on(pool.get_scheduler(), stdexec::just(42));
#endif
auto [a] = stdexec::sync_wait(std::move(x)).value();
return a == 42 ? EXIT_SUCCESS : EXIT_FAILURE;
}