-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
114 lines (98 loc) · 4.38 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Copyright (C) 2021-2023 b1f6c1c4
#
# This file is part of ajnin.
#
# ajnin is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3.
#
# ajnin is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with ajnin. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.16)
project(ajnin VERSION 0.6)
set(CMAKE_CXX_STANDARD 20)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
configure_file(include/config.h.in include/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include(CTest)
enable_testing()
add_subdirectory(tests)
include_directories(/usr/include/antlr4-runtime)
# set variable pointing to the antlr tool that supports C++
# this is not required if the jar file can be found under PATH environment
set(ANTLR_EXECUTABLE /usr/share/java/antlr-complete.jar CACHE STRING "Path of antlr-complete.jar")
# add macros to generate ANTLR Cpp code from grammar
find_package(ANTLR REQUIRED)
find_package(Boost 1.71.0 REQUIRED)
# Call macro to add lexer and grammar to your build dependencies.
antlr_target(TLexer TLexer.g4 LEXER
PACKAGE parsing)
antlr_target(TParser TParser.g4 PARSER
PACKAGE parsing
DEPENDS_ANTLR TLexer
COMPILE_FLAGS -lib ${ANTLR_TLexer_OUTPUT_DIR} -visitor)
# include generated files in project environment
include_directories(${ANTLR_TLexer_OUTPUT_DIR})
include_directories(${ANTLR_TParser_OUTPUT_DIR})
include_directories(${ANTLR_TVisitor_OUTPUT_DIR})
include_directories(include)
add_executable(ajnin main.cpp
manager/aux.cpp
manager/io.cpp
manager/non-build.cpp
manager/build.cpp
${ANTLR_TLexer_CXX_OUTPUTS}
${ANTLR_TParser_CXX_OUTPUTS})
target_link_libraries(ajnin antlr4-runtime)
target_link_libraries(ajnin boost_regex)
add_custom_target(link_target_an ALL COMMAND ${CMAKE_COMMAND} -E create_symlink ajnin an)
add_custom_target(link_target_sanity ALL COMMAND ${CMAKE_COMMAND} -E create_symlink ajnin sanity)
if(NOT EXISTS ${PANDOC_EXECUTABLE})
find_program(PANDOC_EXECUTABLE pandoc)
mark_as_advanced(PANDOC_EXECUTABLE)
if(NOT EXISTS ${PANDOC_EXECUTABLE})
message(FATAL_ERROR "Pandoc not found. Install Pandoc or set cache variable PANDOC_EXECUTABLE.")
endif()
endif()
add_custom_command(OUTPUT ajnin.1
COMMAND pandoc ARGS -s -t man -o ajnin.1 ${CMAKE_CURRENT_SOURCE_DIR}/man/ajnin.md
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/ajnin.md
COMMENT "Using pandoc to generate man page: ajnin.1")
add_custom_command(OUTPUT an.1
COMMAND pandoc ARGS -s -t man -o an.1 ${CMAKE_CURRENT_SOURCE_DIR}/man/an.md
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/an.md
COMMENT "Using pandoc to generate man page: an.1")
add_custom_command(OUTPUT sanity.1
COMMAND pandoc ARGS -s -t man -o sanity.1 ${CMAKE_CURRENT_SOURCE_DIR}/man/sanity.md
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/sanity.md
COMMENT "Using pandoc to generate man page: sanity.1")
add_custom_target(manual DEPENDS ajnin.1 an.1 sanity.1)
install(TARGETS ajnin DESTINATION bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/an DESTINATION bin/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sanity DESTINATION bin/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ajnin.1 DESTINATION share/man/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/an.1 DESTINATION share/man/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sanity.1 DESTINATION share/man/)
install(FILES indent/ajnin.vim DESTINATION share/vim/vimfiles/indent/)
install(FILES syntax/ajnin.vim DESTINATION share/vim/vimfiles/syntax/)
install(FILES LICENSE DESTINATION share/licenses/ajnin/)
if(DEFINED ENV{COVERALLS_REPO_TOKEN})
include(Coveralls)
target_compile_options(ajnin PRIVATE -fprofile-arcs -ftest-coverage)
target_link_libraries(ajnin gcov)
target_link_options(ajnin PRIVATE --coverage)
set(COVERAGE_SRCS
main.cpp
manager/aux.cpp
manager/build.cpp
manager/io.cpp
manager/non-build.cpp
include/filter.hpp
include/manager.hpp)
coveralls_setup("${COVERAGE_SRCS}" ON)
endif()