forked from ArthurSonzogni/Diagon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (107 loc) · 4.49 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
115
116
117
118
cmake_minimum_required (VERSION 3.11)
project(Diagon)
# ┌─────────────────────────────────────────────────┐
# │ Print Information about the compilation system │
# └─────────────────────────────────────────────────┘
if(CMAKE_CXX_COMPILER MATCHES "/em\\+\\+(-[a-zA-Z0-9.])?$")
set(Web true)
else()
set(Web false)
endif()
message("┌── Diagon configuration ───────────────────────")
message("│ - Build type : " ${CMAKE_BUILD_TYPE})
message("│ - C compiler: ${CMAKE_C_COMPILER}")
message("│ - C++ compiler: ${CMAKE_CXX_COMPILER}")
message("│ - System: " ${CMAKE_SYSTEM_NAME} )
message("│ - Use Web : " ${Web})
message("└────────────────────────────────────────────────")
# ┌─────────────────────────────────────────────────┐
# │ ANTLR │
# └─────────────────────────────────────────────────┘
execute_process(
COMMAND bash download_and_patch.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools/antlr
)
SET(WITH_LIBCXX OFF CACHE BOOL "")
add_subdirectory(${CMAKE_SOURCE_DIR}/tools/antlr/antlr4/runtime/Cpp/ EXCLUDE_FROM_ALL)
include_directories(${CMAKE_SOURCE_DIR}/tools/antlr/antlr4/runtime/Cpp/runtime/src)
# Function
# ANTLR(<file.g4>)
#
# Description:
# Take an ANTLR file and produce a CMake rule to generate the corresponding
# C++ files.
#
# Notes:
# The ANTLR file path must be relative to ${CMAKE_CURRENT_SOURCE_DIR}
#
# Example:
# ANTLR(Grammar.g4)
function(ANTLR source)
get_filename_component(source_filename ${CMAKE_CURRENT_SOURCE_DIR}/${source} NAME_WE)
get_filename_component(source_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/${source} DIRECTORY)
get_filename_component(source_gen_dir ${CMAKE_CURRENT_BINARY_DIR}/${source} DIRECTORY)
add_custom_command(
OUTPUT
${source_gen_dir}/${source_filename}Lexer.cpp
${source_gen_dir}/${source_filename}Parser.cpp
${source_gen_dir}/${source_filename}Lexer.h
${source_gen_dir}/${source_filename}Parser.h
COMMAND
java
ARGS
-jar ${CMAKE_SOURCE_DIR}/tools/antlr/antlr.jar
-Dlanguage=Cpp
-no-listener
-no-visitor
-o ${source_gen_dir}
${source_src_dir}/${source_filename}.g4
MAIN_DEPENDENCY
${source_src_dir}/${source_filename}.g4
)
endfunction()
function(target_set_common target)
set_property(TARGET ${target} PROPERTY CXX_STANDARD 17)
if (Web)
# Nothing
elseif (MSVC)
target_compile_options(${target} PRIVATE "/wd4244")
target_compile_options(${target} PRIVATE "/wd4267")
target_compile_options(${target} PRIVATE "/wd4996")
target_compile_options(${target} PRIVATE "/wd4305")
else()
target_compile_options(${target} PRIVATE "-Wall")
#target_compile_options(${target} PRIVATE "-Werror")
target_compile_options(${target} PRIVATE "-Wno-sign-compare")
target_compile_options(${target} PRIVATE "-Wno-attributes")
endif()
endfunction()
#-------------------------------------------------------------------------------
add_subdirectory(src)
#-------------------------------------------------------------------------------
execute_process(
COMMAND
git rev-list --count HEAD
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE
git_version
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "diagon")
set(CPACK_PACKAGE_VENDOR "Arthur Sonzogni")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Arthur Sonzogni")
set(CPACK_PACKAGE_VERSION_MAJOR ${git_version})
set(CPACK_PACKAGE_VERSION_MINOR "")
set(CPACK_PACKAGE_VERSION_PATCH "")
set(CPACK_DEBIAN_PACKAGE_VERSION ${git_version})
set(CPACK_PACKAGE_HOMEPAGE_URL "https://arthursonzogni.com/Diagon/")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "
Generate beautiful ASCII art diagrams.
Diagon is a collection of interactive generators. Math formulas, sequences diagrams, graph,
border, ... This is written in C++, available online with WebAssembly.
")
set(CPACK_DEBIAN_PACKAGE_DEPENDS " ")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://arthursonzogni.com/Diagon/")
include(CPack)