-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
92 lines (81 loc) · 2.33 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
# Copyright 2021 Davidson Francis <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5.2)
set(CMAKE_C_STANDARD 99)
project(ag C)
include(GNUInstallDirs)
# General
add_compile_options(-Wall -Wextra)
include_directories(${CMAKE_SOURCE_DIR})
add_definitions(-D_GNU_SOURCE)
# Files
set(AG_SRC
ag_src/decompress.c
ag_src/ignore.c
ag_src/lang.c
ag_src/log.c
ag_src/main.c
ag_src/options.c
ag_src/print.c
ag_src/print_w32.c
ag_src/scandir.c
ag_src/search.c
ag_src/util.c
ag_src/zfile.c
)
set(LIBAG_DOC
doc/man3/ag_finish.3
doc/man3/ag_free_all_results.3
doc/man3/ag_free_result.3
doc/man3/ag_get_stats.3
doc/man3/ag_init.3
doc/man3/ag_init_config.3
doc/man3/ag_search.3
doc/man3/ag_search_ts.3
doc/man3/ag_set_config.3
doc/man3/ag_start_workers.3
doc/man3/ag_stop_workers.3
)
# libag objects
add_library(libag_objects OBJECT ${AG_SRC} libag.c)
set_target_properties(libag_objects PROPERTIES
PUBLIC_HEADER libag.h
POSITION_INDEPENDENT_CODE 1
)
target_include_directories(libag_objects PRIVATE ag_src/)
# libag
add_library(ag SHARED $<TARGET_OBJECTS:libag_objects>)
target_link_libraries(ag pcre lzma z pthread)
# pkg-config
configure_file(doc/libag.pc.in libag.pc @ONLY)
# Install libag
install(TARGETS ag
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Install manpages
install(FILES doc/man1/ag.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${LIBAG_DOC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
# Install pkgconfig
install(FILES ${CMAKE_BINARY_DIR}/libag.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
# Examples
add_executable(simple
examples/simple.c)
target_link_libraries(simple ag)
add_executable(init_config
examples/init_config.c)
target_link_libraries(init_config ag)
## Bindings
# Python
add_subdirectory(bindings)