CMakeLists.txt 1.13 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 11)

project(alexnet LANGUAGES CXX)

#set cmake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# add dependencies
find_package(Armadillo REQUIRED)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Armadillo_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Armadillo_LIBRARIES})
13
14
15
find_package(Caffe2 REQUIRED)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Caffe2_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Caffe2_LIBRARIES})
16
17

# additional commands
18
set(LIBS ${LIBS} -lprotobuf -lglog -lgflags)
19
20
21
22
23
24
25
26
27
find_package(CUDA)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})
set(LIBS ${LIBS} ${CUDA_LIBRARIES} ${CUDA_curand_LIBRARY})

if(CUDA_FOUND)
  set(LIBS ${LIBS} caffe2 caffe2_gpu)
else()
  set(LIBS ${LIBS} caffe2)
endif()
28
29
30
31

# create static library
include_directories(${INCLUDE_DIRS})
add_library(alexnet alexnet.h)
32
target_include_directories(alexnet PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${INCLUDE_DIRS})
33
34
35
36
37
38
39
target_link_libraries(alexnet PUBLIC ${LIBS})
set_target_properties(alexnet PROPERTIES LINKER_LANGUAGE CXX)

# export cmake project
export(TARGETS alexnet FILE alexnet.cmake)

# additional commands end