-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
82 lines (66 loc) · 3.42 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
81
# CMakeList.txt: 顶层 CMake 项目文件,在此处执行全局配置
# 并包含子项目。
#
cmake_minimum_required (VERSION 3.8)
include_directories(/home/wz/boost_1_68_0)
project ("StanceDetector")
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
function(find_mkl)
set(MKL_ARCH intel64)
set(MKL_ROOT /opt/intel/mkl)
find_path(MKL_INCLUDE_DIR mkl.h
PATHS ${MKL_ROOT} ${MKL_ROOT}/include)
find_library(MKL_CORE_LIB NAMES mkl_intel_lp64 mkl_sequential mkl_core
PATHS ${MKL_ROOT} ${MKL_ROOT}/lib/${MKL_ARCH}
DOC "MKL core library path")
find_library(MKL_COMPILER_LIB NAMES iomp5 libiomp5md
PATHS ${MKL_ROOT} ${MKL_ROOT}/../compiler/lib/${MKL_ARCH} #Windows
${MKL_ROOT}/../compilers_and_libraries/linux/lib/${MKL_ARCH}_lin #Linux
DOC "MKL compiler lib (for threaded MKL)")
if(MKL_INCLUDE_DIR AND MKL_CORE_LIB AND MKL_COMPILER_LIB)
get_filename_component(MKL_CORE_LIB_DIR ${MKL_CORE_LIB} DIRECTORY)
get_filename_component(MKL_COMPILER_LIB_DIR ${MKL_COMPILER_LIB} DIRECTORY)
get_filename_component(MKL_COMPILER_LIB_FILE ${MKL_COMPILER_LIB} NAME)
message(STATUS "Found MKL\n * include: ${MKL_INCLUDE_DIR},\n * core library dir: ${MKL_CORE_LIB_DIR},\n * compiler library: ${MKL_COMPILER_LIB}")
# Due to a conflict with /MT and /MD, MSVC needs mkl_intel_lp64 linked last, or we can change individual
# projects to use /MT (mkl_intel_lp64 linked with /MT, default MSVC projects use /MD), or we can instead
# link to the DLL versions. For now I'm opting for this solution which seems to work with projects still
# at their default /MD. Linux build requires the mkl_intel_lp64 to be linked first. So...:
if(MSVC)
set(LIBS ${LIBS} mkl_sequential mkl_core mkl_intel_lp64 ${MKL_COMPILER_LIB_FILE} PARENT_SCOPE)
else()
set(LIBS ${LIBS} mkl_intel_lp64 mkl_sequential mkl_core ${MKL_COMPILER_LIB_FILE} PARENT_SCOPE)
endif()
include_directories(${MKL_INCLUDE_DIR})
link_directories(${MKL_CORE_LIB_DIR} ${MKL_COMPILER_LIB_DIR})
set(MKL_LINK_DIRS ${MKL_CORE_LIB_DIR} ${MKL_COMPILER_LIB_DIR} PARENT_SCOPE) # Keeping this for python build
else()
message(FATAL_ERROR "Failed to find MKL in path: ${MKL_ROOT} (Did you set MKL_ROOT properly?)")
endif()
endfunction()
######## Cross-compiler, cross-platform options
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_FAST_MATH")
if (MKL OR MKL_ROOT)
find_mkl() # sets include/lib directories and sets ${LIBS} needed for linking
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_USE_MKL_ALL")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -w -msse3 -funroll-loops -std=c++11 -O0 -pg" )
else()
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -funroll-loops -w -std=c++11 -Ofast -march=native" )
endif()
#add_definitions( -DUSE_FLOAT )
# 包含子项目。
include_directories(3rd/eigen)
include_directories(3rd/jsoncpp)
include_directories(3rd/n3ldg/include 3rd/cxxopts/include)
include_directories(3rd/inih)
include_directories(3rd/tinyutf8)
include_directories(3rd/jsoncpp)
include_directories(StanceDetector)
AUX_SOURCE_DIRECTORY(3rd/jsoncpp SRCS)
AUX_SOURCE_DIRECTORY(StanceDetector SRCS)
#add_executable (StanceDetector "StanceDetector.cpp" "StanceDetector.h")
add_executable (StanceDetector ${SRCS})
target_link_libraries(StanceDetector ${LIBS})
include_directories(StanceDetector/model)