forked from rohit-px2/nvui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
162 lines (161 loc) · 4.34 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
cmake_minimum_required(VERSION 3.19)
#if(DEFINED ENV{QT_DIR})
#message("Qt Dir is Set")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_DIR}")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_DIR}/Qt5Core")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_DIR}/Qt5Widgets")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_DIR}/Qt5Gui")
#else()
#message("Could not find QT_DIR")
#endif()
#if (DEFINED ENV{QT_SVGDIR})
#message("Qt SVG Dir is set")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_SVGDIR}")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_SVGDIR}/Qt5Svg")
#list(APPEND CMAKE_PREFIX_PATH "$ENV{QT_SVGDIR}/Qt5Gui")
#endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_CPPCHECK "cppcheck")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
project(nvui)
if(MSVC)
add_compile_options(/W4)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wextra -pedantic)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(msgpack CONFIG REQUIRED)
find_package(Catch2 CONFIG REQUIRED)
find_package(Qt5Core CONFIG REQUIRED)
find_package(Qt5Gui CONFIG REQUIRED)
find_package(Qt5Widgets CONFIG REQUIRED)
find_package(Qt5Svg CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(GLOB SOURCES
src/msgpack_overrides.hpp
src/editor.hpp
src/editor.cpp
src/titlebar.hpp
src/titlebar.cpp
src/utils.cpp
src/nvim.hpp
src/nvim.cpp
src/hlstate.hpp
src/hlstate.cpp
src/window.hpp
src/window.cpp
src/cursor.hpp
src/cursor.cpp
src/popupmenu.hpp
src/popupmenu.cpp
src/cmdline.hpp
src/cmdline.cpp
src/font.hpp
src/grid.cpp
src/grid.hpp
src/decide_renderer.hpp
)
if (WIN32)
message("Windows detected.")
file(GLOB WINONLYSOURCES
src/wineditor.hpp
src/wineditor.cpp
src/platform/windows/*.cpp
src/platform/windows/*.hpp
)
list(APPEND SOURCES ${WINONLYSOURCES})
endif()
find_package(Boost COMPONENTS filesystem thread REQUIRED)
list(APPEND SOURCES "src/main.cpp")
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Release")
add_executable(nvui WIN32 "assets/icons/desktop/neovim_icon.rc" ${SOURCES})
else()
add_executable(nvui ${SOURCES})
endif()
target_link_libraries(nvui PRIVATE msgpackc msgpackc-cxx)
target_link_libraries(nvui PRIVATE Qt::Core Qt::Gui Qt::Widgets Qt::Svg)
target_link_libraries(nvui PRIVATE fmt::fmt-header-only)
target_include_directories(nvui PRIVATE
"${PROJECT_SOURCE_DIR}/src"
)
if(WIN32)
target_link_libraries(nvui PUBLIC
d2d1.lib
d3d11.lib
dwrite.lib
)
endif()
if (Boost_FOUND)
target_include_directories(nvui PRIVATE ${Boost_INCLUDE_DIR})
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE
${Boost_LIBRARIES}
)
include(CheckIPOSupported)
check_ipo_supported(RESULT LTOAvailable)
if(LTOAvailable)
set_property(TARGET nvui PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
file(GLOB TEST_SOURCES
src/msgpack_overrides.hpp
src/editor.hpp
src/editor.cpp
src/titlebar.hpp
src/titlebar.cpp
src/utils.hpp
src/nvim.hpp
src/nvim.cpp
src/window.hpp
src/window.cpp
src/hlstate.hpp
src/hlstate.cpp
src/cursor.hpp
src/cursor.cpp
test/*.cpp
src/popupmenu.hpp
src/popupmenu.cpp
src/cmdline.hpp
src/cmdline.cpp
src/font.hpp
src/grid.cpp
src/grid.hpp
src/decide_renderer.hpp
)
if (WIN32)
file(GLOB WINONLYTESTSOURCES
src/wineditor.hpp
src/wineditor.cpp
src/platform/windows/*.cpp
src/platform/windows/*.hpp
)
list(APPEND TEST_SOURCES ${WINONLYTESTSOURCES})
endif()
add_executable(nvui_test "test/test_main.cpp" ${TEST_SOURCES})
target_link_libraries(nvui_test PRIVATE msgpackc msgpackc-cxx)
target_link_libraries(nvui_test PRIVATE Catch2::Catch2)
target_link_libraries(nvui_test PRIVATE Qt::Core Qt::Gui Qt::Widgets Qt::Svg)
target_link_libraries(nvui_test PRIVATE fmt::fmt-header-only)
target_include_directories(nvui_test PRIVATE
"${PROJECT_SOURCE_DIR}/test"
"${PROJECT_SOURCE_DIR}/src"
)
if (BOOST_FOUND)
target_include_directories(nvui_test PRIVATE ${Boost_INCLUDE_DIR})
endif()
target_link_libraries(nvui_test PRIVATE
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_LIBRARIES}
)
include(CTest)
include(Catch)
catch_discover_tests(nvui_test)