forked from pjreddie/darknet
-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
69 lines (59 loc) · 2.69 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 2.8)
project(darknet)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMake")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/pyDarknet)
## Compiler settings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--export-dynamic -Wall -Wno-sign-compare -fPIC")
#thread
FIND_PACKAGE(Threads)
list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
# CUDA
FIND_PACKAGE(CUDA)
if (CUDA_FOUND)
message(STATUS "CUDA Version: " ${CUDA_VERSION_STRINGS})
message(STATUS "CUDA Libararies: " ${CUDA_LIBRARIES})
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
list(APPEND LIBRARIES ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY} ${CUDA_cusparse_LIBRARY})
list(APPEND CUDA_NVCC_FLAGS "-std=c++11;-O2;-Xcompiler \"-fPIC\" ")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_20,code=compute_20 ")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_30,code=compute_30 ")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_35,code=compute_35 ")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_50,code=compute_50 ")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_52,code=compute_52 ")
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
add_definitions(-DGPU)
cuda_include_directories(src)
else()
list(APPEND LIBRARIES "m")
endif()
#BOOST
FIND_PACKAGE(Boost REQUIRED python)
FIND_PACKAGE(PythonLibs REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
include_directories(SYSTEM ${PYTHON_INCLUDE_DIR})
include_directories(SYSTEM ${OpenCV_INCLUDE_DIR})
include_directories(src)
set(SRC_DIR src)
FILE(GLOB SRC_FILES ${SRC_DIR}/*.c)
FILE(GLOB CU_SRC_FILES ${SRC_DIR}/*.cu)
LIST(REMOVE_ITEM SRC_FILES "${PROJECT_SOURCE_DIR}/src/server.c")
LIST(REMOVE_ITEM SRC_FILES "${PROJECT_SOURCE_DIR}/src/old.c")
LIST(REMOVE_ITEM SRC_FILES "${PROJECT_SOURCE_DIR}/src/cpu_gemm.c")
#LIST(REMOVE_ITEM SRC_FILES "${PROJECT_SOURCE_DIR}/src/darknet.c")
if (CUDA_FOUND)
message(STATUS "CUDA FOUND")
cuda_add_library(dnl SHARED ${SRC_FILES} ${CU_SRC_FILES})
target_link_libraries(dnl ${LIBRARIES} ${OpenCV_LIBS})
cuda_add_executable(darknet ${SRC_DIR}/darknet.c)
target_link_libraries(darknet ${LIBRARIES} ${OpenCV_LIBS} dnl)
cuda_add_library(pydarknet SHARED ${SRC_DIR}/pydarknet.cpp)
target_link_libraries(pydarknet dnl ${LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${OpenCV_LIBS} )
else ()
add_library(dnl SHARED ${SRC_FILES} ${CU_SRC_FILES})
target_link_libraries(dnl ${LIBRARIES})
add_executable(darknet ${SRC_DIR}/darknet.c)
target_link_libraries(darknet ${LIBRARIES} dnl)
add_library(pydarknet SHARED ${SRC_DIR}/pydarknet.cpp)
target_link_libraries(pydarknet ${LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} dnl)
endif()