forked from aardappel/treesheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
137 lines (120 loc) · 4.77 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Sample build with makefile generator
#
# cd <into-treesheets-source>
# cmake . -B _build -DCMAKE_BUILD_TYPE=Release \
# -DCMAKE_INSTALL_PREFIX=installed \
# -DCMAKE_PROGRAM_PATH=<path-to-wx-config> # not always needed
# cmake --build _build --target install
#
# Sample build with IDE generator, like Xcode
#
# cd <into-treesheets-source>
# cmake -B _build -GXcode \
# -DCMAKE_PROGRAM_PATH=<path-to-wx-config> # not always needed
# cmake --build _build --config Release --target install
#
# Run program:
#
# ./i/treesheets
#
# Should work on Windows, too. About helping FindwxWidgets to find wxWidgets
# consult: https://cmake.org/cmake/help/latest/module/FindwxWidgets.html
cmake_minimum_required(VERSION 3.5)
project(treesheets)
if(NOT APPLE AND NOT WIN32)
set(TREESHEETS_RELOCATABLE_INSTALLATION OFF CACHE BOOL "Install data relative to the treesheets binary, instead of respecting the Filesystem Hierarchy Standard")
include(GNUInstallDirs)
endif()
# set(CMAKE_CXX_STANDARD 17) # this doesn't work correctly on all CMake versions :(
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
find_package(wxWidgets REQUIRED aui adv core xml net)
include(${wxWidgets_USE_FILE})
file(
GLOB lobster_sources
lobster/external/flatbuffers/src/*.cpp
lobster/src/builtins.cpp
lobster/src/compiler.cpp
lobster/src/disasm.cpp
lobster/src/file.cpp
lobster/src/lobsterreader.cpp
lobster/src/platform.cpp
lobster/src/vm.cpp
lobster/src/vmdata.cpp
lobster/src/vmlog.cpp
lobster/src/tocpp.cpp
lobster/src/tccbind.cpp
lobster/external/libtcc/libtcc.c
)
add_library(lobster STATIC ${lobster_sources})
target_include_directories(lobster PUBLIC lobster/include lobster/src lobster/external/libtcc)
add_library(lobster-impl STATIC src/lobster_impl.cpp)
target_link_libraries(lobster-impl PRIVATE lobster)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
OPTION(WITH_CLANG_TIDY "Run clang-tidy linter" OFF)
if (WITH_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=cppcoreguidelines-*,clang-analyzer-*,readability-*,performance-*,portability-*,concurrency-*,modernize-*)
endif()
add_executable(
treesheets
src/main.cpp
)
target_link_libraries(
treesheets
PRIVATE
${wxWidgets_LIBRARIES}
lobster-impl
)
if(NOT APPLE AND NOT WIN32 AND NOT TREESHEETS_RELOCATABLE_INSTALLATION)
set(TREESHEETS_BINDIR ${CMAKE_INSTALL_BINDIR})
set(TREESHEETS_DOCDIR ${CMAKE_INSTALL_DOCDIR})
set(TREESHEETS_FULL_DOCDIR ${CMAKE_INSTALL_FULL_DOCDIR})
set(TREESHEETS_PKGDATADIR ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME})
set(TREESHEETS_FULL_PKGDATADIR ${CMAKE_INSTALL_FULL_DATADIR}/${CMAKE_PROJECT_NAME})
# Apple and Windows always look to relative paths for locales.
target_compile_definitions(treesheets PRIVATE "LOCALEDIR=L\"${CMAKE_INSTALL_FULL_LOCALEDIR}\"")
target_compile_definitions(treesheets PRIVATE "TREESHEETS_DOCDIR=\"${TREESHEETS_FULL_DOCDIR}\"")
target_compile_definitions(treesheets PRIVATE "TREESHEETS_DATADIR=\"${TREESHEETS_FULL_PKGDATADIR}\"")
else()
set(TREESHEETS_BINDIR ${CMAKE_INSTALL_PREFIX})
set(TREESHEETS_DOCDIR ${CMAKE_INSTALL_PREFIX})
set(TREESHEETS_PKGDATADIR ${CMAKE_INSTALL_PREFIX})
endif()
install(TARGETS treesheets DESTINATION ${TREESHEETS_BINDIR})
install(DIRECTORY TS/docs DESTINATION ${TREESHEETS_DOCDIR})
install(FILES TS/readme.html DESTINATION ${TREESHEETS_DOCDIR})
install(DIRECTORY TS/examples DESTINATION ${TREESHEETS_DOCDIR})
install(DIRECTORY TS/images DESTINATION ${TREESHEETS_PKGDATADIR})
install(DIRECTORY TS/scripts DESTINATION ${TREESHEETS_PKGDATADIR})
# Install translations to correct platform-specific path.
# See: https://docs.wxwidgets.org/trunk/overview_i18n.html#overview_i18n_mofiles
file(
GLOB locales
LIST_DIRECTORIES true
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/TS/translations
TS/translations/*/ts.mo
)
list(
TRANSFORM locales
REPLACE "/ts\\.mo$" ""
)
if(APPLE OR WIN32 OR TREESHEETS_RELOCATABLE_INSTALLATION)
foreach(locale ${locales})
install(
FILES "TS/translations/${locale}/ts.mo"
DESTINATION "${CMAKE_INSTALL_PREFIX}/translations/${locale}"
)
endforeach()
else()
# Falling back to GNU scheme
foreach(locale ${locales})
install(
FILES "TS/translations/${locale}/ts.mo"
DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${locale}/LC_MESSAGES"
)
endforeach()
endif()
if(NOT APPLE AND NOT WIN32)
install(FILES TS/images/treesheets.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
install(FILES TS/treesheets.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(FILES TS/treesheets.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages)
endif()