vcpkg/ports/tree-sitter/CMakeLists.txt
kylo252 00413b7537
[tree-sitter] add new port (#26058)
* [tree-sitter] add new port

* ci: test support for uwp

* fixup: address review comments

* chore: update git-version

* fixup: skip removing non-existent binaries

* refactor: patch the upstream pkgconfig instead

* fixup: remove unnecessary vcpkg-cmake-wrapper

this is only used for overriding CMake's builtins

* Bump cmake_minimum_required

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>

* Fix version database

Co-authored-by: Billy O'Neal <bion@microsoft.com>
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
2022-08-05 23:46:37 -07:00

52 lines
1.5 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(
tree-sitter
LANGUAGES C
VERSION 0.26.0
)
set(TS_SOVERSION_MAJOR 0)
set(TS_SOVERSION_MINOR 0)
file(GLOB TS_SRC_FILES "${PROJECT_SOURCE_DIR}/src/*.c")
list(REMOVE_ITEM TS_SRC_FILES "${PROJECT_SOURCE_DIR}/src/lib.c") # skip amalgamation
include(GNUInstallDirs)
add_library(tree-sitter ${TS_SRC_FILES})
target_include_directories(
tree-sitter
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(
tree-sitter
PROPERTIES C_STANDARD 99
C_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
SOVERSION ${TS_SOVERSION_MAJOR}.${TS_SOVERSION_MINOR})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tree-sitter.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter.pc" @ONLY)
install(
TARGETS tree-sitter
EXPORT unofficial-tree-sitter-config
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(FILES "${PROJECT_SOURCE_DIR}/include/tree_sitter/api.h"
"${PROJECT_SOURCE_DIR}/include/tree_sitter/parser.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
install(
EXPORT unofficial-tree-sitter-config
NAMESPACE unofficial::tree-sitter::
DESTINATION share/unofficial-tree-sitter)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")