This commit is contained in:
Adam Kosiorek 2014-07-24 13:58:37 +02:00 коммит произвёл Jeff Donahue
Родитель 75e3f56b98
Коммит edc493a3e4
2 изменённых файлов: 33 добавлений и 24 удалений

Просмотреть файл

@ -32,6 +32,11 @@ set(CMAKE_CXX_COMPILER_FLAGS ${CMAKE_CXX_COMPILER_FLAGS} -Wall)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )#-O3)
# Global Definitions
if(CPU_ONLY)
add_definitions(-DCPU_ONLY)
endif()
# Include Directories
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include)
include_directories(${${PROJECT_NAME}_INCLUDE_DIRS})
@ -41,8 +46,10 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeScripts)
# CUDA is required globally
find_package(CUDA 5.5 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
if(NOT CPU_ONLY)
find_package(CUDA 5.5 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
endif()
### Subdirectories ##########################################################################

Просмотреть файл

@ -7,14 +7,6 @@ find_package(Threads REQUIRED)
find_package(Glog REQUIRED)
include_directories(${GLOG_INCLUDE_DIRS})
# CUDA
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_30,code=sm_30
-gencode arch=compute_35,code=sm_35
)
# BLAS
if(BLAS STREQUAL "atlas")
@ -68,34 +60,44 @@ link_directories( ${Boost_LIBRARY_DIRS} )
add_subdirectory(proto)
# Recursively find source files
# cuda sources
file(GLOB_RECURSE CU_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
# test sources
## test sources
file(GLOB_RECURSE TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_*.cpp)
# all cpp sources
## all cpp sources
file(GLOB_RECURSE CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
# remove test sources from cpp sources
## remove test sources from cpp sources
list(REMOVE_ITEM CPP_SOURCES ${TEST_SOURCES})
add_library(caffe ${CPP_SOURCES})
cuda_add_library(caffe_cu ${CU_SOURCES})
# both depend on proto
add_dependencies(caffe proto)
add_dependencies(caffe_cu proto)
target_link_libraries(caffe caffe_cu proto
# CUDA
if(NOT CPU_ONLY)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_30,code=sm_30
-gencode arch=compute_35,code=sm_35
)
# cuda sources
file(GLOB_RECURSE CU_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
cuda_add_library(caffe_cu ${CU_SOURCES})
add_dependencies(caffe_cu proto)
target_link_libraries(caffe caffe_cu
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
)
endif()
target_link_libraries(caffe proto
${GLOG_LIBRARIES}
${HDF5_LIBRARIES}
${OpenCV_LIBS}
${LEVELDB_LIBS}
${LMDB_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${LMDB_LIBRARIES}
${BLAS_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)