neovim/cmake.deps/cmake/LibtermkeyCMakeLists.txt
2023-11-20 15:21:55 +01:00

38 lines
1.3 KiB
CMake

cmake_minimum_required(VERSION 3.10)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(libtermkey C)
add_compile_options(-w)
if(EXISTS ${PROJECT_SOURCE_DIR}/termkey.h.in)
file(STRINGS Makefile TERMKEY_VERSION_MAJOR REGEX "VERSION_MAJOR")
string(REGEX MATCH "[0-9]+" TERMKEY_VERSION_MAJOR ${TERMKEY_VERSION_MAJOR})
file(STRINGS Makefile TERMKEY_VERSION_MINOR REGEX "VERSION_MINOR")
string(REGEX MATCH "[0-9]+" TERMKEY_VERSION_MINOR ${TERMKEY_VERSION_MINOR})
file(READ termkey.h.in TERMKEY_TEXT)
string(REPLACE "@@VERSION_MAJOR@@" "${TERMKEY_VERSION_MAJOR}" TERMKEY_TEXT "${TERMKEY_TEXT}")
string(REPLACE "@@VERSION_MINOR@@" "${TERMKEY_VERSION_MINOR}" TERMKEY_TEXT "${TERMKEY_TEXT}")
file(WRITE termkey.h "${TERMKEY_TEXT}")
endif()
add_library(termkey termkey.c driver-csi.c driver-ti.c)
target_compile_definitions(termkey PRIVATE HAVE_UNIBILIUM)
target_include_directories(termkey PRIVATE SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
set_target_properties(termkey PROPERTIES
PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/termkey.h)
target_link_libraries(termkey PRIVATE ${UNIBILIUM_LIBRARIES})
include(GNUInstallDirs)
install(TARGETS termkey
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# vim: set ft=cmake: