-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
94 lines (77 loc) · 2.46 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
82
83
84
85
86
87
88
89
90
91
92
93
#
# Copyright (c) 2016-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
cmake_minimum_required(VERSION 3.0.2)
project(fasttext)
# The version number.
set(fasttext_VERSION_MAJOR 0)
set(fasttext_VERSION_MINOR 1)
include_directories(fasttext)
# Set compiler flags and options.
if (MSVC)
# Display more warnings
set (CMAKE_CXX_FLAGS "-std=c++11 /W3")
else ()
set (CMAKE_CXX_FLAGS " -pthread -std=c++11 -funroll-loops -O3 -march=native")
endif ()
set(HEADER_FILES
src/args.h
src/autotune.h
src/densematrix.h
src/dictionary.h
src/fasttext.h
src/loss.h
src/matrix.h
src/meter.h
src/model.h
src/productquantizer.h
src/quantmatrix.h
src/real.h
src/strutils.h
src/utils.h
src/vector.h)
set(SOURCE_FILES
src/args.cc
src/autotune.cc
src/densematrix.cc
src/dictionary.cc
src/fasttext.cc
src/loss.cc
src/main.cc
src/matrix.cc
src/meter.cc
src/model.cc
src/productquantizer.cc
src/quantmatrix.cc
src/strutils.cc
src/utils.cc
src/vector.cc)
if (NOT MSVC)
include(GNUInstallDirs)
configure_file("fasttext.pc.in" "fasttext.pc" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/fasttext.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
add_library(fasttext-shared SHARED ${SOURCE_FILES} ${HEADER_FILES})
add_library(fasttext-static STATIC ${SOURCE_FILES} ${HEADER_FILES})
add_library(fasttext-static_pic STATIC ${SOURCE_FILES} ${HEADER_FILES})
set_target_properties(fasttext-shared PROPERTIES OUTPUT_NAME fasttext
SOVERSION "${fasttext_VERSION_MAJOR}")
set_target_properties(fasttext-static PROPERTIES OUTPUT_NAME fasttext)
set_target_properties(fasttext-static_pic PROPERTIES OUTPUT_NAME fasttext_pic POSITION_INDEPENDENT_CODE True)
add_executable(fasttext-bin src/main.cc)
if (MSVC)
SET(CMAKE_EXE_LINKER_FLAGS "-pthread")
target_link_libraries(fasttext-bin fasttext-static)
else()
target_link_libraries(fasttext-bin pthread fasttext-static)
endif()
set_target_properties(fasttext-bin PROPERTIES PUBLIC_HEADER "${HEADER_FILES}" OUTPUT_NAME fasttext)
install (TARGETS fasttext-shared LIBRARY DESTINATION lib)
install (TARGETS fasttext-static ARCHIVE DESTINATION lib)
install (TARGETS fasttext-static_pic ARCHIVE DESTINATION lib)
install (TARGETS fasttext-bin RUNTIME DESTINATION bin PUBLIC_HEADER DESTINATION include/fasttext)
add_subdirectory(tests)