Skip to content

Commit 5aa0669

Browse files
Fix CMake configuration for CONTOUR_FRONTEND_GUI=OFF to still build contour binary, but without GUI.
Signed-off-by: Christian Parpart <[email protected]>
1 parent 9f3ec54 commit 5aa0669

File tree

6 files changed

+44
-17
lines changed

6 files changed

+44
-17
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ add_subdirectory(vtparser)
1111
add_subdirectory(vtbackend)
1212
add_subdirectory(vtrasterizer)
1313

14-
if(CONTOUR_FRONTEND_GUI)
15-
add_subdirectory(contour)
16-
endif()
14+
add_subdirectory(contour)

src/contour/CMakeLists.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ message(STATUS "Qt components: ${QT_COMPONENTS}")
2424

2525
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} REQUIRED)
2626

27-
add_subdirectory(display)
27+
if(CONTOUR_FRONTEND_GUI)
28+
add_subdirectory(display)
29+
endif()
2830

2931
if(APPLE)
3032
#set(CMAKE_INSTALL_RPATH "@executable_path")
@@ -35,29 +37,32 @@ if(APPLE)
3537
find_package(Qt6 COMPONENTS Core Quick REQUIRED)
3638
endif()
3739

40+
set(_header_files
41+
Actions.h
42+
CaptureScreen.h
43+
Config.h
44+
ContourApp.h
45+
)
3846
set(_source_files
39-
CaptureScreen.cpp CaptureScreen.h
47+
Actions.cpp
48+
CaptureScreen.cpp
49+
Config.cpp
50+
ContourApp.cpp
4051
main.cpp
4152
)
4253

4354
if(CONTOUR_FRONTEND_GUI)
4455
list(APPEND _header_files
45-
Actions.h
4656
Audio.h
4757
BlurBehind.h
48-
Config.h
49-
ContourApp.h
5058
ContourGuiApp.h
5159
TerminalSession.h
5260
TerminalSessionManager.h
5361
helper.h
5462
)
5563
list(APPEND _source_files
56-
Actions.cpp
5764
Audio.cpp
5865
BlurBehind.cpp
59-
Config.cpp
60-
ContourApp.cpp
6166
ContourGuiApp.cpp
6267
TerminalSession.cpp
6368
TerminalSessionManager.cpp
@@ -167,10 +172,9 @@ endif()
167172

168173
target_link_libraries(contour
169174
PRIVATE
170-
ContourTerminalDisplay
171175
crispy::core
172176
vtbackend
173-
vtrasterizer
177+
Qt6::Core
174178
${YAML_CPP_LIBRARIES}
175179
)
176180

@@ -181,7 +185,8 @@ if(CONTOUR_FRONTEND_GUI)
181185
endif()
182186
target_link_libraries(contour
183187
PRIVATE
184-
Qt6::Core
188+
vtrasterizer
189+
ContourTerminalDisplay
185190
Qt6::Core5Compat
186191
Qt6::Multimedia
187192
Qt6::Network

src/contour/Config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,13 @@ void YAMLConfigReader::load(Config& c)
361361
loadFromEntry("mouse_block_selection_modifier", c.mouseBlockSelectionModifiers);
362362
loadFromEntry("profiles", c.profiles, c.defaultProfileName.value());
363363
loadFromEntry("git_drawings", c.gitDrawings);
364+
#if defined(CONTOUR_FRONTEND_GUI)
364365
vtrasterizer::BoxDrawingRenderer::setGitDrawingsStyle(c.gitDrawings.value());
365366
loadFromEntry("box_arc_style", c.boxArcStyle);
366367
vtrasterizer::BoxDrawingRenderer::setArcStyle(c.boxArcStyle.value());
367368
loadFromEntry("braile_style", c.braileStyle);
368369
vtrasterizer::BoxDrawingRenderer::setBraileStyle(c.braileStyle.value());
370+
#endif
369371

370372
// loadFromEntry("color_schemes", c.colorschemes); // NB: This is always loaded lazily
371373
loadFromEntry("input_mapping", c.inputMappings);

src/contour/Config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
#include <contour/Actions.h>
55
#include <contour/ConfigDocumentation.h>
6-
#include <contour/display/ShaderConfig.h>
6+
7+
#if defined(CONTOUR_FRONTEND_GUI)
8+
#include <contour/display/ShaderConfig.h>
9+
#endif
710

811
#include <vtbackend/Color.h>
912
#include <vtbackend/ColorPalette.h>

src/contour/display/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@ endif()
3030

3131
target_include_directories(ContourTerminalDisplay PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../..")
3232
target_link_libraries(ContourTerminalDisplay vtrasterizer)
33-
target_link_libraries(ContourTerminalDisplay Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::Multimedia Qt6::Quick Qt6::QuickControls2)
33+
target_link_libraries(ContourTerminalDisplay
34+
Qt6::Core
35+
Qt6::Gui
36+
Qt6::Multimedia
37+
Qt6::OpenGL
38+
Qt6::Quick
39+
Qt6::QuickControls2
40+
)
3441
set_target_properties(ContourTerminalDisplay PROPERTIES AUTOMOC ON)

src/contour/main.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
#include <contour/ContourGuiApp.h>
2+
3+
#if defined(CONTOUR_FRONTEND_GUI)
4+
#include <contour/ContourGuiApp.h>
5+
#else
6+
#include <contour/ContourApp.h>
7+
#endif
8+
9+
#include <QtCore/QByteArray>
10+
#include <QtCore/QString>
11+
12+
#if __has_include(<QtCore/QtLogging>)
13+
#include <QtCore/QtLogging>
14+
#endif
315

416
#if defined(_WIN32)
517
#include <cstdio>

0 commit comments

Comments
 (0)