Я экспериментирую в Windows 10 с командами CMake FetchContent.
Я пытаюсь протестировать библиотеку TBB из этого репозитория: https://github.com/uxlfoundation/oneTBB.
Это прекрасно создает библиотеку, когда я создаю исполняемый файл, но она просто не может найти DLL во время выполнения (я знаю, что в Windows DLL должна находиться в той же папке, что и исполняемый файл). но это не требовалось для другой библиотеки, которую я пробовал с FetchContent — SDL3). Разве FetchContent не должен предоставлять доступ ко всему, от заголовков до библиотеки DLL, во время выполнения? Чего мне не хватает при использовании этой команды?
Спасибо за любую информацию.
cmake_minimum_required(VERSION 3.31)
project(tbb LANGUAGES CXX)
# Generate a JSON file that contains all the compile commands for all object
# files (not the linking commands)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Fancy way to set the standard, link against this 'library' to inherit its
# compile features
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(project_options INTERFACE)
target_compile_features(project_options INTERFACE cxx_std_23)
# Get non-local dependencies
if(true)
include(FetchContent)
# Declare oneTBB (open-source) dependency
FetchContent_Declare(
oneTBB
GIT_REPOSITORY https://github.com/uxlfoundation/oneTBB.git
GIT_TAG master
GIT_SHALLOW ON
)
# Specify configuration
set(TBB_TEST OFF)
set(TBB_INSTALL OFF)
# Acquire the dependencies
FetchContent_MakeAvailable(oneTBB)
endif()
set(EXECUTABLE_NAME test_basics)
add_executable(${EXECUTABLE_NAME} "main.cpp")
target_link_libraries(${EXECUTABLE_NAME} PRIVATE project_options TBB::tbb)
Это файл main.cpp:
#include
#include
auto main() -> int
{
using namespace oneapi;
std::println("oneTBB basics test");
const auto accumulate = [](tbb::blocked_range const& r, int init) -> int
{
for (int v = r.begin(); v != r.end(); v++)
{
init += v;
}
return init;
};
const auto reduce = [](int lhs, int rhs) -> int { return lhs + rhs; };
auto sum{tbb::parallel_reduce(tbb::blocked_range(1, 101), 0, accumulate, reduce)};
std::println("Sum: {}", sum);
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... ion-does-n