Skip to content
Merged
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
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ if(IPC_TOOLKIT_TOPLEVEL_PROJECT)
endif()
endif()

if(IPC_TOOLKIT_TOPLEVEL_PROJECT)
option(IPC_TOOLKIT_BUILD_TESTS "Build unit-tests" ON)
option(IPC_TOOLKIT_BUILD_PYTHON "Build Python bindings" OFF)
else()
# If this is not the top-level project, we don't want to build tests or Python
# bindings. This is useful for projects that use IPC Toolkit as a submodule.
set(IPC_TOOLKIT_BUILD_TESTS OFF CACHE BOOL "Build unit-tests" FORCE)
set(IPC_TOOLKIT_BUILD_PYTHON OFF CACHE BOOL "Build Python bindings" FORCE)
endif()
# If this is not the top-level project, we don't build tests or Python bindings
# by default. This is useful for projects that use IPC Toolkit as a submodule.
option(IPC_TOOLKIT_BUILD_TESTS "Build unit-tests" ${IPC_TOOLKIT_TOPLEVEL_PROJECT})
option(IPC_TOOLKIT_BUILD_PYTHON "Build Python bindings" OFF)

option(IPC_TOOLKIT_WITH_CUDA "Enable CUDA CCD" OFF)
option(IPC_TOOLKIT_WITH_SIMD "Enable SIMD" ON)
Expand Down Expand Up @@ -138,7 +133,17 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Verify Options
################################################################################

# CUDA support
# Check for CUDA support
if (IPC_TOOLKIT_WITH_CUDA)
include(CheckLanguage)
check_language(CUDA)
if (NOT CMAKE_CUDA_COMPILER)
message(WARNING "CUDA support requested but no CUDA compiler found. Continuing without CUDA.")
set(IPC_TOOLKIT_WITH_CUDA OFF)
endif()
endif()

# Enable CUDA support if requested
if(IPC_TOOLKIT_WITH_CUDA)
# If CMAKE_CUDA_ARCHITECTURES was not specified, set it to native.
if(DEFINED CMAKE_CUDA_ARCHITECTURES)
Expand Down Expand Up @@ -172,7 +177,10 @@ if(IPC_TOOLKIT_WITH_SIMD)
message(STATUS "SIMD support found: ${SIMD_CXX_FLAGS}")
else()
message(WARNING "SIMD support requested but not found. Continuing without SIMD.")
set(IPC_TOOLKIT_WITH_SIMD OFF CACHE BOOL "Enable SIMD" FORCE)
# We shadow the cache entry with a normal variable instead of forcing the
# cache off. Forcing would overwrite the user's request, and the option
# would stay OFF in this build directory even after SIMD becomes available.
set(IPC_TOOLKIT_WITH_SIMD OFF)
endif()
endif()

Expand Down
35 changes: 5 additions & 30 deletions cmake/recipes/onetbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,18 @@ option(TBB_PREFER_STATIC "Use the static version of TBB for the alias target" ON
unset(TBB_DIR CACHE)

function(onetbb_import_target)
macro(push_variable var value)
if(DEFINED CACHE{${var}})
set(ONETBB_OLD_${var}_VALUE "${${var}}")
set(ONETBB_OLD_${var}_TYPE CACHE_TYPE)
elseif(DEFINED ${var})
set(ONETBB_OLD_${var}_VALUE "${${var}}")
set(ONETBB_OLD_${var}_TYPE NORMAL_TYPE)
else()
set(ONETBB_OLD_${var}_TYPE NONE_TYPE)
endif()
set(${var} "${value}" CACHE PATH "" FORCE)
endmacro()

macro(pop_variable var)
if(ONETBB_OLD_${var}_TYPE STREQUAL CACHE_TYPE)
set(${var} "${ONETBB_OLD_${var}_VALUE}" CACHE PATH "" FORCE)
elseif(ONETBB_OLD_${var}_TYPE STREQUAL NORMAL_TYPE)
unset(${var} CACHE)
set(${var} "${ONETBB_OLD_${var}_VALUE}")
elseif(ONETBB_OLD_${var}_TYPE STREQUAL NONE_TYPE)
unset(${var} CACHE)
else()
message(FATAL_ERROR "Trying to pop a variable that has not been pushed: ${var}")
endif()
endmacro()

# We set BUILD_SHARED_LIBS as a normal variable. oneTBB's subdirectory
# inherits it, and it disappears when this function returns, so the caller's
# value is restored for free.
if(TBB_PREFER_STATIC)
push_variable(BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS OFF)
else()
push_variable(BUILD_SHARED_LIBS ON)
set(BUILD_SHARED_LIBS ON)
endif()

set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME tbb)
include(CPM)
CPMAddPackage("gh:uxlfoundation/oneTBB@2022.3.0")

pop_variable(BUILD_SHARED_LIBS)
endfunction()

onetbb_import_target()
Expand Down
Loading