-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
130 lines (108 loc) · 4.06 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
cmake_minimum_required (VERSION 3.5)
project (plugins)
# FARSOURCE must not be defined via $HOME
set(FARSOURCE ${CMAKE_SOURCE_DIR}/../far2m)
set(LUA_SHARE ${FARSOURCE}/luafar/lua_share)
string(ASCII 27 Esc)
set(ColorNormal "${Esc}[m")
set(ColorRed "${Esc}[1;31m")
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_PREFIX "/usr/local")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(CMAKE_INSTALL_PREFIX "/usr/local")
else()
set(CMAKE_INSTALL_PREFIX "/usr")
endif()
endif()
if (NOT DEFINED P_HIGHLIGHT)
set(P_HIGHLIGHT "NO")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -Wno-unused-function -D_FILE_OFFSET_BITS=64") # -fsanitize=address
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99 -fPIC -Wno-unused-function -D_FILE_OFFSET_BITS=64") # -fsanitize=address
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2")
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
set(INSTALL_DIR ${CMAKE_BINARY_DIR}/install)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--gc-sections")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
endif()
endif()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)
if(CMAKE_VERSION VERSION_GREATER "3.3")
cmake_policy(SET CMP0063 NEW)
cmake_policy(SET CMP0057 NEW)
endif()
find_package(LibLua REQUIRED)
include_directories(${LIBLUA_INCLUDE_DIRS})
include_directories(${FARSOURCE}/WinPort)
add_executable (minilua ${FARSOURCE}/luafar/src/minilua.c)
target_link_libraries(minilua PRIVATE ${LIBLUA_LIBRARIES})
function(AddPlugin Name Active)
string(TOUPPER ${Name} Var)
if ((DEFINED ${Var} AND ${Var}) OR (NOT DEFINED ${Var} AND ${Active}))
message(STATUS "${Var} plugin enabled")
add_subdirectory (Plugins/${Name})
else()
if (${Active})
message(STATUS "${ColorRed}${Var} plugin disabled due to ${Var}=${${Var}}${ColorNormal}")
else()
message(STATUS "${ColorRed}${Var} plugin disabled, use -D${Var}=yes if you need it${ColorNormal}")
endif()
install(CODE "
execute_process(COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_INSTALL_PREFIX}/lib/far2m/Plugins/luafar/${Name}/plug/${Name}.far-plug-wide)
" COMPONENT system)
endif()
endfunction()
AddPlugin( filegen 0 )
AddPlugin( highlight 0 )
AddPlugin( lf4ed 1 )
AddPlugin( lfhistory 1 )
AddPlugin( lfsearch 1 )
AddPlugin( lftmp 1 )
AddPlugin( luapanel 1 )
AddPlugin( macro2lua 0 )
if (NOT DEFINED POLYGON OR POLYGON)
find_package(Sqlite3)
if (Sqlite3_FOUND)
AddPlugin(polygon 1)
else()
message(STATUS "${ColorRed}POLYGON plugin disabled due to not found sqlite3 package${ColorNormal}")
endif()
else()
AddPlugin(polygon 0)
endif()
if (SQLARC)
find_package(Sqlite3)
if (Sqlite3_FOUND)
AddPlugin(sqlarc 1)
else()
message(STATUS "${ColorRed}SQLARC plugin disabled due to not found sqlite3 package${ColorNormal}")
endif()
else()
AddPlugin(sqlarc 0)
endif()
install(DIRECTORY "${INSTALL_DIR}/" DESTINATION "lib/far2m/Plugins/luafar" USE_SOURCE_PERMISSIONS COMPONENT base FILES_MATCHING
PATTERN "*.far-plug-*"
PATTERN "highlight/plug/syntaxes" EXCLUDE
PATTERN "lf4ed/plug/scripts" EXCLUDE
PATTERN "lfsearch/plug/doc" EXCLUDE
PATTERN "lfsearch/plug/scripts" EXCLUDE
PATTERN "polygon/plug/modules" EXCLUDE
)
install(DIRECTORY "${INSTALL_DIR}/" DESTINATION "share/far2m/Plugins/luafar" USE_SOURCE_PERMISSIONS COMPONENT base FILES_MATCHING
PATTERN "*.far-plug-*" EXCLUDE
PATTERN "*"
)