-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
108 lines (94 loc) · 3.95 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
cmake_minimum_required(VERSION 3.7...3.21)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
project(
NVelox
VERSION 0.0
DESCRIPTION "Neovim library"
LANGUAGES C)
# Require out-of-source builds
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
message(
FATAL_ERROR
"You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles."
)
endif()
file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS src/nvelox/*.c)
file(GLOB_RECURSE HEADER_FILES CONFIGURE_DEPENDS include/nvelox/*.h)
add_library(nvelox SHARED ${SRC_FILES})
target_link_libraries(nvelox dl)
option(NVELOX_USE_BUNDLED "Use bundled dependencies" ON)
if(NVELOX_USE_BUNDLED)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/nvim-deps)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/nvelox-neovim)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env CLICOLOR_FORCE=1 ${CMAKE_COMMAND}
${CMAKE_CURRENT_SOURCE_DIR}/external/nvelox-neovim/third-party
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nvim-deps)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env CLICOLOR_FORCE=1 ${CMAKE_COMMAND} --build
${CMAKE_CURRENT_BINARY_DIR}/nvim-deps)
execute_process(
COMMAND
${CMAKE_COMMAND} -E env CLICOLOR_FORCE=1 ${CMAKE_COMMAND}
${CMAKE_CURRENT_SOURCE_DIR}/external/nvelox-neovim
-DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/nvim-deps/usr
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nvelox-neovim)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env CLICOLOR_FORCE=1 ${CMAKE_COMMAND} --build
${CMAKE_CURRENT_BINARY_DIR}/nvelox-neovim -t generated-sources)
else()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/nvelox-neovim)
execute_process(
COMMAND
${CMAKE_COMMAND} -E env CLICOLOR_FORCE=1 ${CMAKE_COMMAND}
${CMAKE_CURRENT_SOURCE_DIR}/external/nvelox-neovim
$ENV{NVELOX_NEOVIM_CMAKE_FLAGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nvelox-neovim)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env CLICOLOR_FORCE=1 ${CMAKE_COMMAND} --build
${CMAKE_CURRENT_BINARY_DIR}/nvelox-neovim -t generated-sources)
endif()
add_definitions(-DINCLUDE_GENERATED_DECLARATIONS)
set(NVELOX_NEOVIM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/nvelox-neovim)
set(NVELOX_NEOVIM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/nvelox-neovim)
target_include_directories(
nvelox
PUBLIC $<BUILD_INTERFACE:${NVELOX_NEOVIM_BINARY_DIR}/include>
$<BUILD_INTERFACE:${NVELOX_NEOVIM_BINARY_DIR}/cmake.config>
$<BUILD_INTERFACE:${NVELOX_NEOVIM_BINARY_DIR}/src/nvim/auto>
$<BUILD_INTERFACE:${NVELOX_NEOVIM_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/nvelox/nvim-include>
$<INSTALL_INTERFACE:include/nvelox/nvim-config>
$<INSTALL_INTERFACE:include/nvelox/nvim-auto>
$<INSTALL_INTERFACE:include/nvelox>)
include(GNUInstallDirs)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/nvelox/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nvelox)
install(
DIRECTORY ${NVELOX_NEOVIM_SOURCE_DIR}/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nvelox
FILES_MATCHING
PATTERN "*.h")
install(
DIRECTORY ${NVELOX_NEOVIM_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nvelox/nvim-include
FILES_MATCHING
PATTERN "*.h")
install(
DIRECTORY ${NVELOX_NEOVIM_BINARY_DIR}/cmake.config/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nvelox/nvim-config
FILES_MATCHING
PATTERN "*.h")
install(
DIRECTORY ${NVELOX_NEOVIM_BINARY_DIR}/src/nvim/auto/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nvelox/nvim-auto
FILES_MATCHING
PATTERN "*.h")
install(TARGETS nvelox EXPORT NVeloxConfig)
export(TARGETS nvelox FILE "${CMAKE_CURRENT_BINARY_DIR}/NVeloxConfig.cmake")
install(EXPORT NVeloxConfig
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/NVelox/cmake")