forked from baidu/lac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
81 lines (69 loc) · 3.23 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
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 3.0)
project(lac CXX C)
message(STATUS "CXX compiler: ${CMAKE_CXX_COMPILER}, version: "
"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "C compiler: ${CMAKE_C_COMPILER}, version: "
"${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "A gcc compiler with a version >= 4.8.2 is needed.")
endif()
else()
message(FATAL_ERROR "A gcc compiler is needed.")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-O4 -g -pipe -W -Wall -Wno-unused-parameter -fPIC -fpermissive -std=gnu++11")
if (IS_ABSOLUTE ${PADDLE_ROOT})
set(PADDLE_ABS_PATH ${PADDLE_ROOT})
else ()
get_filename_component(PADDLE_ABS_PATH ${CMAKE_BINARY_DIR}/${PADDLE_ROOT} ABSOLUTE)
endif ()
if (EXISTS ${PADDLE_ABS_PATH})
message(STATUS "\$PADDLE_ROOT is set to '${PADDLE_ABS_PATH}'")
include_directories(${PADDLE_ABS_PATH})
include_directories(${PADDLE_ABS_PATH}/third_party/install/gflags/include)
include_directories(${PADDLE_ABS_PATH}/third_party/boost)
include_directories(${PADDLE_ABS_PATH}/third_party/install/glog/include)
include_directories(${PADDLE_ABS_PATH}/third_party/install/protobuf/include)
include_directories(${PADDLE_ABS_PATH}/third_party/eigen3)
else ()
message(FATAL_ERROR "'${PADDLE_ABS_PATH}' does not exist.\nPlease set -DPADDLE_ROOT=/path/to/your/fluid_inference_lib/")
endif ()
set (fluid_lib_path ${PADDLE_ABS_PATH}/paddle/fluid/inference)
if (EXISTS ${fluid_lib_path})
link_directories(${PADDLE_ABS_PATH}/paddle/fluid/inference)
link_libraries(paddle_fluid)
else ()
message(FATAL_ERROR "Fluid inference lib not found.\nPlease set -DPADDLE_ROOT=/path/to/your/fluid_inference_lib")
endif ()
# add mkldnn library if it exitsts
set (mkldnn_lib_path ${PADDLE_ABS_PATH}/third_party/install/mkldnn/lib)
if (EXISTS ${mkldnn_lib_path})
message(STATUS "MKLDNN lib found.")
link_directories(${PADDLE_ABS_PATH}/third_party/install/mkldnn/lib)
link_libraries(mkldnn)
else ()
message(STATUS "MKLDNN lib not found.")
endif()
# add mklml library if it exitsts
set (mklml_inc_path ${PADDLE_ABS_PATH}/third_party/install/mklml/include)
set (mklml_lib_path ${PADDLE_ABS_PATH}/third_party/install/mklml/lib)
if (EXISTS ${mklml_inc_path} AND EXISTS ${mklml_lib_path})
message(STATUS "MKLML lib found.")
include_directories(${PADDLE_ABS_PATH}/third_party/install/mklml/include)
link_directories(${PADDLE_ABS_PATH}/third_party/install/mklml/lib)
link_libraries(mklml_intel iomp5)
else ()
message(STATUS "MKLML lib not found.")
endif()
link_libraries(rt dl pthread)
include_directories(include)
aux_source_directory(src SOURCE)
add_library(lac ${SOURCE} include/ilac.h)
add_executable(lac_demo test/src/lac_demo.cpp)
set_target_properties(lac_demo PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
target_link_libraries(lac_demo lac)
install(TARGETS lac DESTINATION ${PROJECT_SOURCE_DIR}/output/lib)
install(TARGETS lac_demo DESTINATION ${PROJECT_SOURCE_DIR}/output/demo)
install(FILES ${PROJECT_SOURCE_DIR}/include/ilac.h
DESTINATION ${PROJECT_SOURCE_DIR}/output/include)