Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support and documentation for CMake build system #51

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.22)
project(
readtags
VERSION 0.3.0
DESCRIPTION "a library for looking up tag entries in tag files"
HOMEPAGE_URL "https://github.com/universal-ctags/libreadtags"
LANGUAGES C
)

set(CMAKE_C_STANDARD 99)

option(LIBREADTAGS_BUILD_SHARED "Build shared/static library" OFF)

set(API_VERSION 1)
set(BUILD_VERSION 1.1.2)

if (LIBREADTAGS_BUILD_SHARED)
message(STATUS "Building shared library")
add_library(${PROJECT_NAME} SHARED readtags.c)
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${BUILD_VERSION}
SOVERSION ${API_VERSION}
PUBLIC_HEADER readtags.h
)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
else ()
message(STATUS "Building static library")
add_library(${PROJECT_NAME} STATIC readtags.c)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
endif ()

add_library(universal-ctags::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# libreadtags

libreadtags is a library for reading tags files generated by ctags.
libreadtags assumes the tags file format explained in [tags(5)](https://docs.ctags.io/en/latest/man/tags.5.html)
of Universal-ctags.
Expand All @@ -10,3 +12,41 @@ NEWS.md describes note worty changes.
If you are looking for command line interface for tags files,
you will like [readtags command](https://docs.ctags.io/en/latest/man/readtags.1.html)
shipped as part of Universal-ctags. It uses libreadtags extensively.

## CMake Usage

### Build as a standalone project

#### Configure and build only

```shell
mkdir build
cmake -DCMAKE_BUILD_TYPE=Release -DLIBREADTAGS_BUILD_SHARED=ON -S . -B build
cmake --build build --target readtags
```

#### Configure and install

This will install the library and headers to `/usr/local`.

```shell
mkdir build
cmake -DCMAKE_BUILD_TYPE=Release -DLIBREADTAGS_BUILD_SHARED=ON -S . -B build
sudo cmake --build build --target install
```

### Integrate into other CMake projects

```cmake
include(FetchContent)

FetchContent_Declare(
readtags
GIT_REPOSITORY https://github.com/universal-ctags/libreadtags.git
GIT_TAG master
)

FetchContent_MakeAvailable(readtags)

target_link_libraries(your_target PRIVATE universal-ctags::readtags)
```