Cmake 创建一个子项目

step 1. 主文件夹

ADD_SUBDIRECTORY(LSVM)

step 2. 子文件夹

CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
PROJECT(LSVM)

FIND_PACKAGE(CUDA REQUIRED)

LIST(APPEND CUDA_NVCC_FLAGS “-arch=sm_30”)

IF(CMAKE_COMPILER_IS_GNUCC)
STRING(REGEX REPLACE “.*/” “” C C U D A H O S T C O M P I L E R ) I F ( {CUDA_HOST_COMPILER}) IF( CUDAHOSTCOMPILER)IF({C} STREQUAL “ccache”)
MESSAGE(WARNING “CUDA_HOST_COMPILER is set to: ${CUDA_HOST_COMPILER}, changing to /usr/bin/g++”)
SET(CUDA_HOST_COMPILER “/usr/bin/g++”)
ENDIF()
ENDIF()

ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)

SET(sources
dev_vars.h
csr.h
csr.cu
calc_x2.h
calc_x2.cu
check_cache.h
kernels_select_ws.h
kernels_klocal.h
kernels_smo.h
ohdSVM.cu
ohdSVM.h
debug.h
debug.cpp
cudaerror.h
cuda_utils.h
LSVM.cu
)

CUDA_ADD_LIBRARY(LSVM STATIC ${sources})
CUDA_ADD_CUBLAS_TO_TARGET(LSVM)
TARGET_LINK_LIBRARIES(LSVM ${CUDA_CUDA_LIBRARY})
SET_PROPERTY(TARGET LSVM PROPERTY CXX_STANDARD 11)

你可能感兴趣的:(Cmake,CUDA,C++,1024程序员节)