文章目录
1 工程CMakeLists.txt 2 vscode配置launch.json,settings.json,tasks.json文件
1 工程CMakeLists.txt
cmake_minimum_required ( VERSION 3.8 ) # 根据你的CMake版本调整
# 设置项目名称
project ( ez_compower_upward VERSION 0.1 LANGUAGES CXX CUDA)
find_package ( CUDA REQUIRED)
# 查找并链接需要的库,例如对于标准库之外的依赖
find_package ( Threads REQUIRED) # 例如,如果需要链接线程库
# 设置C++ 标准,这里使用C++ 14
set ( CMAKE_CXX_STANDARD 14 )
set ( CMAKE_CXX_STANDARD_REQUIRED True)
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" )
include_directories ( ${ CMAKE_SOURCE_DIR} / config)
include_directories ( ${ CMAKE_SOURCE_DIR} / interfaces)
include_directories ( ${ CMAKE_SOURCE_DIR} / algorithm/ point_process/ include)
include_directories ( ${ CMAKE_SOURCE_DIR} / algorithm/ pixel_process/ include)
include_directories ( / usr/ local/ cuda/ include)
# include _directories ( ${ CMAKE_SOURCE_DIR} / interfaces/ pixel_process/ include)
# 指定项目源文件
set ( SOURCE_FILES
main. cpp
#${ CMAKE_SOURCE_DIR} / algorithm/ point_process/ src/ point_read. cpp
. . .
${ CMAKE_SOURCE_DIR} / algorithm/ pixel_process/ src/ pixel_algo. cu
)
message ( STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}" )
foreach ( file ${ SOURCE_FILES} )
message ( STATUS "SOURCE_FILE: ${file}" )
endforeach ( )
# 添加可执行文件目标
CUDA_ADD_EXECUTABLE ( ez_compower_app
${ SOURCE_FILES}
)
target_include_directories ( ez_compower_app PRIVATE / usr/ local/ cuda/ include)
# 如果你的项目需要链接其他库,可以在这里添加,例如
target_link_libraries ( ez_compower_app pthread pcap ${ CUDA_LIBRARIES} ) # 对应于Linux下的线程库
# 或者针对特定库的链接命令,比如
# target _link_libraries ( ez_compower_upward SomeThirdPartyLib)
# 可选:设置编译选项,比如警告等级
if ( ${ CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -g" )
endif ( )
# 如果你的项目包含测试,可以使用CTest
enable_testing ( )
# 添加测试用例的示例
# add _test ( NAME MyTest COMMAND MyTest)
# include ( CTest)
2 vscode配置launch.json,settings.json,tasks.json文件
{
"version" : "0.2.0" ,
"configurations" : [
{
"name" : "(gdb) CUDA Debug" ,
"type" : "cppdbg" ,
"request" : "launch" ,
"program" : "${workspaceFolder}/build/ez_compower_app" ,
"args" : [ ] ,
"stopAtEntry" : false,
"cwd" : "${workspaceFolder}" ,
"environment" : [ ] ,
"externalConsole" : false,
"MIMode" : "gdb" ,
"setupCommands" : [
{
"description" : "Enable pretty-printing for gdb" ,
"text" : "-enable-pretty-printing" ,
"ignoreFailures" : true
}
] ,
"preLaunchTask" : "build" ,
"miDebuggerPath" : "/usr/bin/gdb" ,
"internalConsoleOptions" : "neverOpen"
}
]
}
{
"version" : "2.0.0" ,
"tasks" : [
{
"label" : "build" ,
"type" : "shell" ,
"command" : "make" ,
"args" : [ ] ,
"options" : {
"cwd" : "${workspaceFolder}/build"
} ,
"group" : {
"kind" : "build" ,
"isDefault" : true
} ,
"presentation" : {
"echo" : true,
"reveal" : "always" ,
"focus" : false,
"panel" : "shared" ,
"showReuseMessage" : true,
"clear" : false
} ,
"problemMatcher" : [ ]
}
]
}
{
"files.associations" : {
"cctype" : "cpp" ,
"clocale" : "cpp" ,
"cmath" : "cpp" ,
"csignal" : "cpp" ,
"cstdarg" : "cpp" ,
"cstddef" : "cpp" ,
"cstdio" : "cpp" ,
"cstdlib" : "cpp" ,
"cstring" : "cpp" ,
"ctime" : "cpp" ,
"cwchar" : "cpp" ,
"cwctype" : "cpp" ,
"array" : "cpp" ,
"atomic" : "cpp" ,
"strstream" : "cpp" ,
"*.tcc" : "cpp" ,
"bitset" : "cpp" ,
"chrono" : "cpp" ,
"complex" : "cpp" ,
"cstdint" : "cpp" ,
"deque" : "cpp" ,
"list" : "cpp" ,
"unordered_map" : "cpp" ,
"vector" : "cpp" ,
"exception" : "cpp" ,
"algorithm" : "cpp" ,
"functional" : "cpp" ,
"ratio" : "cpp" ,
"system_error" : "cpp" ,
"tuple" : "cpp" ,
"type_traits" : "cpp" ,
"fstream" : "cpp" ,
"initializer_list" : "cpp" ,
"iomanip" : "cpp" ,
"iosfwd" : "cpp" ,
"iostream" : "cpp" ,
"istream" : "cpp" ,
"limits" : "cpp" ,
"memory" : "cpp" ,
"mutex" : "cpp" ,
"new" : "cpp" ,
"ostream" : "cpp" ,
"numeric" : "cpp" ,
"sstream" : "cpp" ,
"stdexcept" : "cpp" ,
"streambuf" : "cpp" ,
"thread" : "cpp" ,
"cfenv" : "cpp" ,
"cinttypes" : "cpp" ,
"utility" : "cpp" ,
"typeindex" : "cpp" ,
"typeinfo" : "cpp" ,
"valarray" : "cpp" ,
"*.ipp" : "cpp" ,
"string" : "cpp" ,
"bit" : "cpp" ,
"codecvt" : "cpp" ,
"condition_variable" : "cpp" ,
"map" : "cpp" ,
"iterator" : "cpp" ,
"memory_resource" : "cpp" ,
"optional" : "cpp" ,
"random" : "cpp" ,
"string_view" : "cpp" ,
"__nullptr" : "cpp"
}
}