diff --git a/CMakeLists.txt b/CMakeLists.txt index ca0587e79..e934bedcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,23 @@ set(stdexec_export_targets) # Define the main library add_library(stdexec INTERFACE) +file(GLOB_RECURSE exec_headers CONFIGURE_DEPENDS include/exec/*.hpp) +file(GLOB_RECURSE stdexec_headers CONFIGURE_DEPENDS include/stdexec/*.hpp) +target_sources(stdexec +PUBLIC + FILE_SET headers + TYPE HEADERS + BASE_DIRS include + FILES + ${exec_headers} + ${stdexec_headers} + # stdexec_version_config.hpp is generated by rapids' script + FILE_SET version_config + TYPE HEADERS + BASE_DIRS ${CMAKE_BINARY_DIR}/include + FILES + ${CMAKE_BINARY_DIR}/include/stdexec_version_config.hpp +) list(APPEND stdexec_export_targets stdexec) # Set library version @@ -160,10 +177,6 @@ set_target_properties(stdexec PROPERTIES # Declare the public include directories include(GNUInstallDirs) -target_include_directories(stdexec INTERFACE - $ - $ - ) target_link_libraries(stdexec INTERFACE Threads::Threads) @@ -269,9 +282,15 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") endif() if(STDEXEC_ENABLE_CUDA) - - file(GLOB_RECURSE nvexec_sources include/nvexec/*.cuh) - add_library(nvexec INTERFACE ${nvexec_sources}) + file(GLOB_RECURSE nvexec_headers CONFIGURE_DEPENDS include/nvexec/*.cuh) + add_library(nvexec INTERFACE) + target_sources(nvexec + PUBLIC + FILE_SET headers + TYPE HEADERS + BASE_DIRS include + FILES ${nvexec_headers} + ) list(APPEND stdexec_export_targets nvexec) add_library(STDEXEC::nvexec ALIAS nvexec) @@ -283,6 +302,10 @@ if(STDEXEC_ENABLE_CUDA) target_link_options(nvexec INTERFACE $<$,$>:-stdpar -gpu=cc${CMAKE_CUDA_ARCHITECTURES}>) + install(TARGETS nvexec + EXPORT stdexec-exports + FILE_SET headers) + if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")) include(rapids-cuda) # Needs to run before `enable_language(CUDA)` @@ -330,16 +353,29 @@ if (STDEXEC_ENABLE_TBB) INSTALL_EXPORT_SET stdexec-exports ) - file(GLOB_RECURSE tbbpool_sources include/execpools/tbb/*.hpp) - add_library(tbbpool INTERFACE ${tbbpool_sources}) + # CONFIGURE_DEPENDS ensures that CMake reconfigures when a relevant hpp file is + # added or removed. + file(GLOB_RECURSE tbbpool_headers CONFIGURE_DEPENDS include/execpools/tbb/*.hpp) + add_library(tbbpool INTERFACE) list(APPEND stdexec_export_targets tbbpool) add_library(STDEXEC::tbbpool ALIAS tbbpool) + target_sources(tbbpool + PUBLIC + FILE_SET headers + TYPE HEADERS + BASE_DIRS include + FILES ${tbbpool_headers} + ) target_link_libraries(tbbpool INTERFACE STDEXEC::stdexec TBB::tbb ) + + install(TARGETS tbbpool + EXPORT stdexec-exports + FILE_SET headers) endif() option(STDEXEC_ENABLE_TASKFLOW "Enable TaskFlow targets" OFF) @@ -435,10 +471,6 @@ endif() set(SYSTEM_CONTEXT_SOURCES src/system_context/system_context.cpp) add_library(system_context STATIC ${SYSTEM_CONTEXT_SOURCES}) -target_include_directories(system_context PRIVATE - $ - $ - ) target_compile_features(system_context PUBLIC cxx_std_20) set_target_properties(system_context PROPERTIES CXX_STANDARD 20 @@ -448,7 +480,7 @@ target_compile_options(system_context PUBLIC $<$:/Zc:__cplusplus /Zc:preprocessor> ) add_library(STDEXEC::system_context ALIAS system_context) - +target_link_libraries(system_context PUBLIC stdexec) if(CMAKE_CROSSCOMPILING) @@ -499,16 +531,9 @@ endif() include(CPack) install(TARGETS stdexec system_context - DESTINATION ${CMAKE_INSTALL_LIBDIR} - EXPORT stdexec-exports) - -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/include/stdexec_version_config.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + EXPORT stdexec-exports + FILE_SET headers + FILE_SET version_config) ############################################################################## # Install exports ------------------------------------------------------------