-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
147 lines (119 loc) · 5.33 KB
/
CMakeLists.txt
File metadata and controls
147 lines (119 loc) · 5.33 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#[[The MIT License (MIT)
Copyright (c) 2023 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.]]
cmake_minimum_required(VERSION 3.8)
find_program(MSBUILD_EXECUTABLE NAMES MSBuild.exe)
if(MSBUILD_EXECUTABLE)
message(STATUS "MSBuild found at ${MSBUILD_EXECUTABLE}")
else()
message(FATAL_ERROR "MSBuild not found. Please ensure it is installed and on the PATH.")
endif()
# LANGUAGE SERVER BUILD =========================================
project(ispc_languageserver)
set(SOLUTION_FILE "${CMAKE_SOURCE_DIR}/server/ispc_languageserver.sln")
set(MSBUILD_RESTORE_COMMAND "${MSBUILD_EXECUTABLE}" "${SOLUTION_FILE}" "/t:Restore" "/p:Platform=Any CPU")
execute_process(
COMMAND ${MSBUILD_RESTORE_COMMAND}
RESULT_VARIABLE MSBUILD_RESTORE_RESULT
OUTPUT_VARIABLE MSBUILD_RESTORE_OUTPUT
)
if(MSBUILD_RESTORE_RESULT EQUAL 0)
message(STATUS "MSBuild NuGet package restore succeeded:\n${MSBUILD_RESTORE_OUTPUT}")
else()
message(FATAL_ERROR "MSBuild NuGet package restore failed:\n${MSBUILD_RESTORE_OUTPUT}")
endif()
set(MSBUILD_COMMAND "${MSBUILD_EXECUTABLE}" "${SOLUTION_FILE}" "/p:Configuration=Release" "/p:Platform=Any CPU")
execute_process(
COMMAND ${MSBUILD_COMMAND}
RESULT_VARIABLE MSBUILD_RESULT
OUTPUT_VARIABLE MSBUILD_OUTPUT
)
if(MSBUILD_RESULT EQUAL 0)
message(STATUS "MSBuild build succeeded:\n${MSBUILD_OUTPUT}")
else()
message(FATAL_ERROR "MSBuild build failed:\n${MSBUILD_OUTPUT}")
endif()
# TREE-SITTER INIT AND BUILD =========================================
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/tree-sitter/.git")
message(STATUS "Initializing tree-sitter submodule")
execute_process(COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
execute_process(COMMAND git submodule update --remote --merge
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tree-sitter/.git)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
execute_process(
COMMAND make
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tree-sitter
RESULT_VARIABLE make_result
OUTPUT_VARIABLE make_output
)
if(NOT make_result EQUAL 0)
message(FATAL_ERROR "Make failed: ${make_output}")
endif()
else()
configure_file(
${CMAKE_SOURCE_DIR}/tree-sitter-CMakeLists.txt
${CMAKE_SOURCE_DIR}/tree-sitter/CMakeLists.txt
COPYONLY
)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/tree-sitter/build)
execute_process(
COMMAND ${CMAKE_COMMAND} -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -S ${CMAKE_SOURCE_DIR}/tree-sitter -B ${CMAKE_SOURCE_DIR}/tree-sitter/build
)
set(SOLUTION_FILE "${CMAKE_SOURCE_DIR}/tree-sitter/build/tree-sitter.sln")
set(MSBUILD_COMMAND "${MSBUILD_EXECUTABLE}" "${SOLUTION_FILE}" "/p:Configuration=Release")
execute_process(
COMMAND ${MSBUILD_COMMAND}
RESULT_VARIABLE MSBUILD_RESULT
OUTPUT_VARIABLE MSBUILD_OUTPUT
)
if(MSBUILD_RESULT EQUAL 0)
message(STATUS "MSBuild build succeeded:\n${MSBUILD_OUTPUT}")
else()
message(FATAL_ERROR "MSBuild build failed:\n${MSBUILD_OUTPUT}")
endif()
endif()
# ispc.tree-sitter GRAMMAR BUILD =========================================
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
execute_process(
COMMAND make
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/ispc.tree-sitter
RESULT_VARIABLE make_result
OUTPUT_VARIABLE make_output
)
if(NOT make_result EQUAL 0)
message(FATAL_ERROR "Make failed: ${make_output}")
endif()
else()
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/ispc.tree-sitter/build)
execute_process(
COMMAND ${CMAKE_COMMAND} -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -S ${CMAKE_SOURCE_DIR}/ispc.tree-sitter -B ${CMAKE_SOURCE_DIR}/ispc.tree-sitter/build
)
set(SOLUTION_FILE "${CMAKE_SOURCE_DIR}/ispc.tree-sitter/build/ispc.tree-sitter.sln")
set(MSBUILD_COMMAND "${MSBUILD_EXECUTABLE}" "${SOLUTION_FILE}" "/p:Configuration=Release")
execute_process(
COMMAND ${MSBUILD_COMMAND}
RESULT_VARIABLE MSBUILD_RESULT
OUTPUT_VARIABLE MSBUILD_OUTPUT
)
if(MSBUILD_RESULT EQUAL 0)
message(STATUS "MSBuild build succeeded:\n${MSBUILD_OUTPUT}")
else()
message(FATAL_ERROR "MSBuild build failed:\n${MSBUILD_OUTPUT}")
endif()
endif()