5.5.4 : Le fichier CMakeLists.txt
Écrire le fichier CMakeLists.txt est assez simple :
On définit notre projet :
1 2 |
project(TestNvcppLib) cmake_minimum_required(VERSION 3.0) |
On ajoute quelques flags de compilation (le fameux -stdpar, une option d'optimisation basique, les warnings et l'activation de C++17) :
1 |
set(CMAKE_CXX_FLAGS "-stdpar=gpu -O1 -Wall -std=c++17") |
On créé notre bibliothèque :
1 |
add_library(test_hadamard_nvcpp_lib SHARED hadamard_product.cpp) |
On créé notre exécutable :
1 |
add_executable(test_hadamard_nvcpp main.cpp)
|
On lie notre exécutable à notre bibliothèque :
1 |
target_link_libraries(test_hadamard_nvcpp test_hadamard_nvcpp_lib)
|
Le fichier CMakeLists.txt complet :
1 2 3 4 5 6 |
project(TestNvcppLib) cmake_minimum_required(VERSION 3.0) set(CMAKE_CXX_FLAGS "-stdpar=gpu -O1 -Wall -std=c++17") add_library(test_hadamard_nvcpp_lib SHARED hadamard_product.cpp) add_executable(test_hadamard_nvcpp main.cpp) target_link_libraries(test_hadamard_nvcpp test_hadamard_nvcpp_lib) |
Le fichier CMakeLists.txt est disponible ici.