6.1.2 : Le CMakeLists.txt

On commence par définir notre project comme d'habitude
1
2
project(SimpleDotProduct)
cmake_minimum_required(VERSION 3.0)


Le compilateur va appeler TBB (Threading Bounding Block, la bibliohtèque de parallélisation d'Intel) pour gérer les exécutions std::execution::par_unseq et std::execution::par . Si vous l'oubliez, vous aurez une erreur de linkage :
1
find_package(TBB COMPONENTS tbb REQUIRED)


On ajoute quelques flags de compilation en activant bien C++20 :
1
set(CMAKE_CXX_FLAGS "-O2 -Wall -std=c++20")


On créé notre exécutable :
1
add_executable(simple_dot_product_random main.cpp)


On n'oublie pas d'utiliser TBB au linkage :
1
target_link_libraries(simple_dot_product_random TBB::tbb)


Le CMakeLists.txt complet :

1
2
3
4
5
6
7
8
9
10
project(SimpleDotProduct)
cmake_minimum_required(VERSION 3.0)

find_package(TBB COMPONENTS tbb REQUIRED)

set(CMAKE_CXX_FLAGS "-O2 -Wall -std=c++20")

add_executable(simple_dot_product_random main.cpp)

target_link_libraries(simple_dot_product_random TBB::tbb)


Le fichier CMakeLists.txt est disponible ici.