Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
3282 lines (3167 loc) · 148 KB
/
Copy pathCMakeLists.txt
File metadata and controls
3282 lines (3167 loc) · 148 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 3.16)
project(Notepatra VERSION 0.1.130 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) # compile .qrc in target SOURCES (icons/vega/diagram render layer)
option(BUILD_TESTING "Build Notepatra regression tests" OFF)
option(BUILD_LEXER_TEST "Backward-compatible alias for BUILD_TESTING" OFF)
# v0.1.64 — Lite mode by default. The bare binary stays ~9 MB and the
# Vega-Lite renderer shows a "Charts Pack required" prompt with manual-
# install docs (auto-installer ships v0.1.65). Pass
# -DNOTEPATRA_WITH_WEBENGINE=ON at configure time for a "full" build that
# bundles QtWebEngine and renders charts inline.
#
# This mirrors DuckDB's extension philosophy: tiny core, optional heavy
# bits installed on demand. Keeps download / launch / disk footprint
# small for users who don't need charts.
option(NOTEPATRA_WITH_WEBENGINE "Bundle QtWebEngine for inline Vega-Lite chart rendering (full-mode build)" OFF)
# v0.1.107 — Full-flavor umbrella. Turns on the heavy opt-in features:
# WebEngine (inline Vega-Lite charts, WHERE the Qt module is available) and
# the DuckDB engine. The default (Lite) build has neither. On macOS, Homebrew
# qt@5 no longer ships QtWebEngine, so a Full macOS build gets DuckDB only and
# the WebEngine probe below downgrades to a stub — that is expected and fine.
option(NOTEPATRA_FULL "Full flavor: WebEngine charts (where available) + DuckDB engine" OFF)
if(NOTEPATRA_FULL)
set(NOTEPATRA_WITH_WEBENGINE ON)
endif()
# v0.1.72 — Cloud-free build variant. When ON, the binary physically
# refuses to talk to any non-private network destination (i.e. anything
# that's not localhost / 127.x / [::1] / 10.x / 172.16-31.x / 192.168.x /
# *.local / *.lan / unix sockets). The cloud-URL paste UI is also
# stripped so the user can't even type api.openai.com — there's no path
# from the binary to a public LLM endpoint.
#
# Shipped as the `notepatra-local-ai` .deb for regulated industries,
# air-gapped fleets, data-sovereignty compliance. Ollama / llama.cpp /
# LM Studio / Jan / self-hosted Ollama on the LAN all continue to work.
option(NOTEPATRA_NO_CLOUD "Build cloud-free variant — block all non-private LLM endpoints" OFF)
if(NOTEPATRA_NO_CLOUD)
add_compile_definitions(NOTEPATRA_NO_CLOUD=1)
message(STATUS "Building cloud-free variant: public LLM endpoints will be refused at runtime")
endif()
if(BUILD_TESTING OR BUILD_LEXER_TEST)
enable_testing()
set(NOTEPATRA_BUILD_TESTS ON)
else()
set(NOTEPATRA_BUILD_TESTS OFF)
endif()
# Use the dynamic CRT (/MD) on Windows MSVC, matching Qt5 from install-qt-action.
# Mixing /MT (static CRT) with /MD-built Qt produces CRT-heap mismatches that
# crash at runtime — see https://doc.qt.io/qt-5/windows-deployment.html.
# vcruntime140.dll / msvcp140.dll are preinstalled on Windows Server 2022
# runners and on every Windows install with the VC++ Redistributable
# (which most Windows machines already have).
if(WIN32 AND POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
# v0.1.56: Force MSVC to interpret string literals as UTF-8.
# Without this, MSVC reads non-ASCII bytes (e.g. the 🔒 emoji at U+1F512) as
# the system code page (Windows-1252 on en-US), so QStringLiteral("🔒 Share")
# becomes mojibake at compile time. Affects every emoji / accented / non-Latin
# character in the codebase. The `/utf-8` flag sets both -execution-charset
# and -source-charset to UTF-8 — the canonical fix.
if(MSVC)
add_compile_options(/utf-8)
# v0.1.113: VS2026 (MSVC toolset 14.5x / _MSC_VER >= 1950) removed
# stdext::make_checked_array_iterator, which Qt 5.15.2's qlist.h still calls
# via QT_MAKE_CHECKED_ARRAY_ITERATOR — so every QList-instantiating TU fails
# to compile (C2653 / C3861). GitHub's hosted Windows images all rolled to
# VS2026 with no VS2022 left, so it can't be fixed at the runner level.
# Force-include a one-line shim before every TU's Qt headers. The shim is a
# no-op (#if-guarded out) on every other toolchain. See src/msvc_stdext_shim.h.
add_compile_options(/FI${CMAKE_CURRENT_SOURCE_DIR}/src/msvc_stdext_shim.h)
endif()
# ── Platform detection ──
if(WIN32)
set(PLATFORM_NAME "windows")
set(EXE_NAME "notepatra")
elseif(APPLE)
set(PLATFORM_NAME "macos")
set(EXE_NAME "Notepatra")
else()
set(PLATFORM_NAME "linux")
set(EXE_NAME "notepatra")
endif()
message(STATUS "Building for platform: ${PLATFORM_NAME}")
# ── Qt5 ──
# v0.1.43: Sql + Charts added for Data Analyst mode.
# - Sql: SQLite driver ships with Qt by default; PostgreSQL/MySQL/SQL Server
# require separate Qt SQL plugin packages users install themselves
# (libqt5sql5-psql, libqt5sql5-mysql, libqt5sql5-odbc on Debian/Ubuntu;
# `brew install qt@5` ships them all on macOS).
# - Charts: rendered inline in the AI chat transcript when the model emits
# a ```chart fenced spec.
find_package(Qt5 REQUIRED COMPONENTS Widgets PrintSupport Network Concurrent Sql Charts Test)
# v0.1.70 — Qt5Svg is OPTIONAL: probe quietly, link if available. Without
# the dev package, QImageReader still decodes SVG via the runtime plugin
# (libqt5svg5) that ships with most distros. If neither is present the
# icons render as broken-image placeholders — acceptable degradation.
find_package(Qt5 QUIET COMPONENTS Svg)
# v0.1.63 — optional QtWebEngine for Vega-Lite chart rendering. On distros
# that don't ship libqt5webengine5 (e.g. minimal CI containers), the option
# can be flipped off and VegaChartRenderer compiles a QLabel stub instead.
# We probe via find_package(... QUIET) so a missing component downgrades
# NOTEPATRA_WITH_WEBENGINE to OFF with a warning rather than failing the
# configure outright.
if(NOTEPATRA_WITH_WEBENGINE)
find_package(Qt5 QUIET COMPONENTS WebEngineWidgets WebChannel)
if(Qt5WebEngineWidgets_FOUND AND Qt5WebChannel_FOUND)
message(STATUS "Vega-Lite renderer + Noter bridge: Qt5WebEngineWidgets ${Qt5WebEngineWidgets_VERSION} + Qt5WebChannel ${Qt5WebChannel_VERSION}")
else()
message(WARNING
"Qt5WebEngineWidgets / Qt5WebChannel not found — Vega-Lite + Noter "
"rich-editor will compile a stub. Install libqt5webengine5-dev + "
"libqt5webchannel5-dev (Debian/Ubuntu), qt5-webengine + qt5-webchannel "
"(Arch), qt@5 includes both on macOS. To silence this warning "
"configure with -DNOTEPATRA_WITH_WEBENGINE=OFF.")
set(NOTEPATRA_WITH_WEBENGINE OFF)
endif()
endif()
# ── QScintilla ──
# Platform-specific search for QScintilla headers and library.
# On CI, these are typically passed via -DQSCINTILLA_INCLUDE=... -DQSCINTILLA_LIB=...
if(WIN32)
find_path(QSCINTILLA_INCLUDE Qsci/qsciscintilla.h
PATH_SUFFIXES Qsci)
find_library(QSCINTILLA_LIB qscintilla2_qt5)
elseif(APPLE)
# When QScintilla is built from source with Qt5's qmake, it installs into
# the Qt5 prefix (e.g. /usr/local/opt/qt@5 or /opt/homebrew/opt/qt@5).
# Also check Homebrew's own qscintilla2 prefix and common locations.
find_path(QSCINTILLA_INCLUDE Qsci/qsciscintilla.h
PATHS /usr/local/include /opt/homebrew/include
/usr/local/opt/qscintilla2/include /opt/homebrew/opt/qscintilla2/include
/usr/local/opt/qt@5/include /opt/homebrew/opt/qt@5/include
PATH_SUFFIXES "" Qsci qt5/Qsci
NO_DEFAULT_PATH)
if(NOT QSCINTILLA_INCLUDE)
find_path(QSCINTILLA_INCLUDE Qsci/qsciscintilla.h)
endif()
find_library(QSCINTILLA_LIB qscintilla2_qt5
PATHS /usr/local/lib /opt/homebrew/lib
/usr/local/opt/qscintilla2/lib /opt/homebrew/opt/qscintilla2/lib
/usr/local/opt/qt@5/lib /opt/homebrew/opt/qt@5/lib
NO_DEFAULT_PATH)
if(NOT QSCINTILLA_LIB)
find_library(QSCINTILLA_LIB qscintilla2_qt5)
endif()
else()
set(QSCINTILLA_INCLUDE_HINTS
/usr/include
/usr/include/qt5
/usr/lib/qt5/include
)
if(CMAKE_LIBRARY_ARCHITECTURE)
list(APPEND QSCINTILLA_INCLUDE_HINTS
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/qt5
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/include
)
endif()
find_path(QSCINTILLA_INCLUDE Qsci/qsciscintilla.h
PATHS ${QSCINTILLA_INCLUDE_HINTS}
PATH_SUFFIXES "" Qsci qt5/Qsci)
if(NOT QSCINTILLA_INCLUDE)
find_path(QSCINTILLA_INCLUDE Qsci/qsciscintilla.h)
endif()
find_library(QSCINTILLA_LIB qscintilla2_qt5)
endif()
# Validate that QScintilla was found
if(NOT QSCINTILLA_LIB)
message(FATAL_ERROR "QScintilla library (qscintilla2_qt5) not found. "
"Set -DQSCINTILLA_LIB=/path/to/libqscintilla2_qt5.dylib")
endif()
if(NOT QSCINTILLA_INCLUDE)
message(FATAL_ERROR "QScintilla headers not found. "
"Set -DQSCINTILLA_INCLUDE=/path/to/include (containing Qsci/ directory)")
endif()
message(STATUS "QScintilla lib: ${QSCINTILLA_LIB}")
message(STATUS "QScintilla include: ${QSCINTILLA_INCLUDE}")
# ── Rust core library ──
set(RUST_CORE_DIR ${CMAKE_SOURCE_DIR}/rust-core)
if(WIN32)
set(RUST_LIB ${RUST_CORE_DIR}/target/release/notepad_core.lib)
else()
set(RUST_LIB ${RUST_CORE_DIR}/target/release/libnotepad_core.a)
endif()
# Build Rust library as a custom command.
# Use BYPRODUCTS (not OUTPUT) so multi-config generators (Visual Studio) handle
# the externally-produced .lib correctly at link time.
add_custom_target(rust_core
COMMAND cargo build --release
BYPRODUCTS ${RUST_LIB}
WORKING_DIRECTORY ${RUST_CORE_DIR}
COMMENT "Building Rust core library..."
)
# ── Sources ──
# Auto-discover every src/*.cpp file. CONFIGURE_DEPENDS makes CMake re-run
# whenever a new .cpp lands in src/, so adding a feature just means dropping
# the file in — no manual SOURCES edit required. Eliminates the "I added a
# new src file but forgot to register it" class of release-day failure.
file(GLOB SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/src/*.cpp")
# v0.1.63 — pull in subsystem .cpp files (e.g. src/charts/*.cpp for the
# Vega-Lite renderer). Kept as a separate glob so reviewers see the
# subdirectory structure at a glance.
file(GLOB CHART_SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/src/charts/*.cpp")
list(APPEND SOURCES ${CHART_SOURCES})
# .npd diagram subsystem. npd_parser.cpp is pure C++ (Qt Core only);
# diagram_render.cpp + diagram_view.cpp render natively with QPainter (no
# WebEngine) so the diagram works in BOTH flavors on every platform.
file(GLOB DIAGRAM_SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/src/diagram/*.cpp")
list(APPEND SOURCES ${DIAGRAM_SOURCES})
# v0.1.70 — bundle 14 monochrome SVG icons used by AIPanel welcome cards,
# attachment chips, lock toggles, etc. Replaces the previous emoji glyphs
# (🤖 🌿 🔌 🖼 …) which rendered as tofu on Linux systems without color-
# emoji fonts. Qt's QImageReader (via Qt5::Svg) decodes the icons; HTML
# <img src=':/icons/foo.svg' width='14' height='14'> embeds them inline
# in QLabel rich text.
list(APPEND SOURCES resources/icons.qrc)
set(HEADERS
src/mainwindow.h
src/editor.h
src/lexerutils.h
src/lexer_go.h
src/lexer_kotlin.h
src/lexer_powershell.h
src/lexer_rust.h
src/lexer_swift.h
src/lexer_typescript.h
src/lexer_plaintext.h
src/lexer_csv.h
src/npp_palette.h
src/tabmanager.h
src/statusbar.h
src/findreplace.h
src/fileexplorer.h
src/functionlist.h
src/preferences.h
src/rustbridge.h
src/compare.h
src/plugin.h
src/terminal.h
src/markdownpreview.h
src/hexeditor.h
src/gitgutter.h
src/ollama.h
src/aipanel.h
src/inlineedit.h
src/inlineedit_diff.h
src/dbconnections.h
src/csvanalyst.h
src/chartrender.h
src/restclient.h
src/gitpanel.h
src/sqlfmtpanel.h
src/fmtpanel.h
src/searchresults.h
src/welcome.h
src/projectsearch.h
src/updater.h
src/fonts.h
src/ollamastatus.h
src/themes.h
src/config.h
# v0.2 Coding-mode revamp (Slice B+C)
src/diff_view.h
src/edit_plan.h
# v0.1.62 — per-hunk staging
src/git_hunk_apply.h
src/gutter_hunk_popup.h
# v0.1.63 — Vega-Lite chart renderer (Data Analyst slice).
src/charts/vega_chart_renderer.h
# .npd diagram view host (Q_OBJECT — native QPainter renderer, both flavors).
src/diagram/diagram_view.h
# v0.1.64 — Lite-mode plugin discovery.
src/plugin_loader.h
)
# ── Platform-specific resources ──
if(WIN32)
# Windows: embed the icon AND the version resource via a GENERATED .rc.
#
# The .rc used to be a static file with FILEVERSION hardcoded to 0,1,0,0,
# so every Windows build reported 0.1.0 to winget / SCCM / Intune and to
# File Properties > Details, regardless of the real version. Generating it
# from project(Notepatra VERSION ...) makes that impossible to drift: there
# is exactly one place the version is written.
if(EXISTS "${CMAKE_SOURCE_DIR}/resources/notepatra.rc.in")
# VERSIONINFO needs a 4-part comma form (a,b,c,d); PROJECT_VERSION is
# 3-part dotted, so pad the build field with 0.
set(NOTEPATRA_RC_VERSION_COMMA
"${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0")
set(NOTEPATRA_RC_VERSION_DOT
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.0")
# The generated .rc lives in the build tree, where a bare
# "notepatra.ico" would not resolve — point at the source copy. RC
# wants forward or escaped slashes, so hand it a forward-slash path.
set(NOTEPATRA_ICON_PATH "${CMAKE_SOURCE_DIR}/resources/notepatra.ico")
configure_file(
"${CMAKE_SOURCE_DIR}/resources/notepatra.rc.in"
"${CMAKE_BINARY_DIR}/notepatra.rc"
@ONLY)
list(APPEND SOURCES "${CMAKE_BINARY_DIR}/notepatra.rc")
endif()
endif()
# ── Executable ──
if(APPLE)
# macOS: build as an app bundle.
#
# We use a hand-written Info.plist template at resources/Info.plist.in
# rather than letting CMake auto-generate a minimal one, because Tahoe
# (macOS 26) silently refuses to launch ad-hoc-signed apps that lack
# LSMinimumSystemVersion, NSPrincipalClass, NSHighResolutionCapable,
# file-type declarations, and arch priority. CMake's default template
# doesn't include those keys.
add_executable(${EXE_NAME} MACOSX_BUNDLE ${SOURCES} ${HEADERS})
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "Notepatra"
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.notepatra.editor"
MACOSX_BUNDLE_INFO_STRING "Notepatra ${PROJECT_VERSION} — Native code editor"
MACOSX_BUNDLE_COPYRIGHT "© Prateek Singh. GPL-3.0 licensed."
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/resources/Info.plist.in"
)
# Embed icon if present
if(EXISTS "${CMAKE_SOURCE_DIR}/resources/notepatra.icns")
set_source_files_properties(resources/notepatra.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
target_sources(${EXE_NAME} PRIVATE resources/notepatra.icns)
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE_ICON_FILE "notepatra.icns")
endif()
# Ship entitlements inside the bundle so install.sh can re-sign
# the user's local copy without needing network access to fetch
# them. macOS codesign reads this during the hardened-runtime
# re-sign step in install.sh.
if(EXISTS "${CMAKE_SOURCE_DIR}/resources/entitlements.plist")
set_source_files_properties(resources/entitlements.plist PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
target_sources(${EXE_NAME} PRIVATE resources/entitlements.plist)
endif()
elseif(WIN32)
# Windows: WIN32 flag suppresses console window
add_executable(${EXE_NAME} WIN32 ${SOURCES} ${HEADERS})
else()
# Linux: plain executable
add_executable(${EXE_NAME} ${SOURCES} ${HEADERS})
endif()
add_dependencies(${EXE_NAME} rust_core)
# Inject the version from `project(Notepatra VERSION X.Y.Z)` so main.cpp's
# --version, --help, and app.setApplicationVersion() always match the build.
# Single source of truth: CMakeLists.txt → NOTEPATRA_VERSION compile define.
target_compile_definitions(${EXE_NAME} PRIVATE
NOTEPATRA_VERSION="${PROJECT_VERSION}"
)
target_include_directories(${EXE_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/rust-core/include
${QSCINTILLA_INCLUDE}
)
# ── Linking ──
target_link_libraries(${EXE_NAME} PRIVATE
Qt5::Widgets
Qt5::PrintSupport
Qt5::Network
Qt5::Concurrent
Qt5::Sql
Qt5::Charts
${QSCINTILLA_LIB}
${RUST_LIB}
)
if(Qt5Svg_FOUND)
target_link_libraries(${EXE_NAME} PRIVATE Qt5::Svg)
# Enables DiagramView's SVG + HTML export (QSvgGenerator). PNG/PDF always work.
target_compile_definitions(${EXE_NAME} PRIVATE NOTEPATRA_WITH_SVG)
endif()
# v0.1.63 — link WebEngineWidgets when the renderer is enabled. The
# stub path (NOTEPATRA_WITH_WEBENGINE=OFF) doesn't include any
# WebEngine header, so the link skip is required as well as the
# compile define (see src/charts/vega_chart_renderer.cpp), so the stub
# build neither links nor includes any WebEngine header.
target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/charts ${CMAKE_SOURCE_DIR}/src/diagram)
if(NOTEPATRA_WITH_WEBENGINE)
target_compile_definitions(${EXE_NAME} PRIVATE NOTEPATRA_WITH_WEBENGINE=1)
target_link_libraries(${EXE_NAME} PRIVATE Qt5::WebEngineWidgets Qt5::WebChannel)
# v0.1.90 — offline vega-embed bundle. ~828 KB of JS shipped as a
# Qt resource so charts render without JSDelivr in the loop (works
# air-gapped + survives CDN outages). Full flavor only — the lite
# build doesn't include the WebEngine renderer at all.
if(EXISTS "${CMAKE_SOURCE_DIR}/resources/vega.qrc")
target_sources(${EXE_NAME} PRIVATE resources/vega.qrc)
endif()
# v0.1.103 — the diagram render layer (dagre/render.js/diagram.html qrc) is
# GONE: DiagramView now paints natively with QPainter (DiagramRender), so no
# WebEngine + no qrc:///diagram/. resources/diagram/* is retained in-tree for
# reference but no longer compiled into any binary.
# v0.1.95 — Noter WebChannel JS resource removed alongside the
# WebEngine path (notes_bridge / notes_editor) when the feature was
# rewritten to use a vanilla QTextEdit. Leaving the EXISTS guard
# here as historical breadcrumb in case a future WebEngine path comes back.
endif()
if(WIN32)
# CRITICAL: QScintilla on Windows is built as a DLL by default. Its headers
# export symbols via __declspec(dllexport)/dllimport guarded by QSCINTILLA_DLL.
# Consumers MUST define QSCINTILLA_DLL so the headers emit dllimport on
# their declarations — otherwise the linker looks for QsciScintilla::staticMetaObject
# in our own .obj files (where it isn't) instead of the import library.
target_compile_definitions(${EXE_NAME} PRIVATE QSCINTILLA_DLL)
# Rust staticlib needs these system libs on MSVC. Rust normally emits link
# directives for them but being explicit avoids surprises across toolchains.
target_link_libraries(${EXE_NAME} PRIVATE
ws2_32 userenv bcrypt ntdll
advapi32 ole32 shell32 dbghelp
kernel32 user32 gdi32 winspool comdlg32
)
elseif(APPLE)
target_link_libraries(${EXE_NAME} PRIVATE pthread dl m
"-framework Security" "-framework CoreFoundation")
else()
# libxcb is a transitive Qt5 GUI dep on Linux X11. We use it directly
# in main.cpp (startup-notify completion) and mainwindow.cpp
# (_NET_ACTIVE_WINDOW with source=2 to bypass Cinnamon/Muffin's
# focus-stealing prevention on IPC file-open), so link explicitly.
target_link_libraries(${EXE_NAME} PRIVATE pthread dl m xcb)
endif()
# ── DuckDB (optional, vendored) ──
# v0.1.55 — DuckDB is the universal-reader engine for the Data Analyst
# mode: CSV / Parquet / JSON / S3 / SQLite federation, all behind one SQL
# dialect. We detect a vendored copy at vendor/duckdb/ first; if missing,
# fall back to a system-installed libduckdb; if neither exists, build
# without DuckDB and the connection panel hides the DuckDB option.
#
# Vendored layout (after `cd vendor/duckdb && unzip libduckdb-*.zip`):
# vendor/duckdb/duckdb.h
# vendor/duckdb/libduckdb.so (Linux x64)
# vendor/duckdb/libduckdb.dylib (macOS arm64/x64)
# vendor/duckdb/duckdb.dll, duckdb.lib (Windows x64)
#
# Runtime: an RPATH of $ORIGIN tells the loader to look for
# libduckdb.so next to the notepatra binary so we can ship them together.
# DuckDB is FULL-ONLY. libduckdb is ~57 MB, so the default Lite binary must
# never link it (hard rule: the bare binary stays small). It is enabled in the
# Full flavor — via the Full umbrella (NOTEPATRA_FULL, used where WebEngine is
# unavailable, e.g. macOS where Homebrew qt@5 dropped WebEngine) OR alongside
# WebEngine on Linux/Windows. Lite (neither) forces it OFF even if a caller
# passes -DNOTEPATRA_USE_DUCKDB=ON. The Data Analyst works on CSV + in-memory
# SQLite without DuckDB; with DuckDB it gains in-process Parquet/JSON/S3/SQLite.
if(NOTEPATRA_FULL OR NOTEPATRA_WITH_WEBENGINE)
set(NOTEPATRA_USE_DUCKDB ON)
else()
if(NOTEPATRA_USE_DUCKDB)
message(WARNING "NOTEPATRA_USE_DUCKDB ignored: DuckDB is Full-only. Build the "
"Full flavor (-DNOTEPATRA_FULL=ON). Forcing OFF for the Lite binary.")
endif()
set(NOTEPATRA_USE_DUCKDB OFF)
endif()
if(NOTEPATRA_USE_DUCKDB)
set(_DUCKDB_VENDOR_DIR "${CMAKE_SOURCE_DIR}/vendor/duckdb")
find_path(DUCKDB_INCLUDE_DIR
NAMES duckdb.h
HINTS "${_DUCKDB_VENDOR_DIR}"
PATHS /usr/include /usr/local/include /opt/homebrew/include
)
if(WIN32)
set(_DUCKDB_LIB_NAMES duckdb)
elseif(APPLE)
set(_DUCKDB_LIB_NAMES duckdb libduckdb)
else()
set(_DUCKDB_LIB_NAMES duckdb libduckdb)
endif()
find_library(DUCKDB_LIBRARY
NAMES ${_DUCKDB_LIB_NAMES}
HINTS "${_DUCKDB_VENDOR_DIR}"
PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu
/opt/homebrew/lib /opt/local/lib
)
if(DUCKDB_INCLUDE_DIR AND DUCKDB_LIBRARY)
message(STATUS "DuckDB: found at ${DUCKDB_LIBRARY}")
target_compile_definitions(${EXE_NAME} PRIVATE NOTEPATRA_HAVE_DUCKDB=1)
target_include_directories(${EXE_NAME} PRIVATE ${DUCKDB_INCLUDE_DIR})
target_link_libraries(${EXE_NAME} PRIVATE ${DUCKDB_LIBRARY})
# Tell the runtime loader to look next to the binary first.
# NOTE: CI ships build-full/notepatra directly (no `make install`), so
# the BUILD rpath — not just INSTALL_RPATH — must carry $ORIGIN /
# @executable_path, else the shipped binary can't find libduckdb sitting
# next to it (the bare build-tree rpath was the absolute vendor path +
# an empty/cwd entry, which only resolved when cwd == the binary dir).
# The vendor dir is kept as a second entry for local dev where the lib
# lives under vendor/duckdb/.
if(UNIX AND NOT APPLE)
set_target_properties(${EXE_NAME} PROPERTIES
INSTALL_RPATH "$ORIGIN"
BUILD_RPATH "$ORIGIN;${_DUCKDB_VENDOR_DIR}"
)
elseif(APPLE)
set_target_properties(${EXE_NAME} PROPERTIES
INSTALL_RPATH "@executable_path"
BUILD_RPATH "@executable_path;${_DUCKDB_VENDOR_DIR}"
)
endif()
else()
message(STATUS "DuckDB: not found — Data-mode DuckDB connection types will be disabled at runtime")
endif()
endif()
# ── Regression tests (opt in via -DBUILD_TESTING=ON) ──
# BUILD_LEXER_TEST remains as a compatibility alias for old scripts/docs.
#
# Each call to notepatra_add_qt_test() also appends the target name to the
# global property `notepatra_test_targets`. After all tests are registered
# below, we expose them as a single `notepatra_all_tests` meta-target so
# CI's `cmake --build . --target notepatra_all_tests` builds every test
# without having to manually keep build.yml in sync with new test_*.cpp
# files. v0.1.57 hit a CI regression because test_edit_plan.cpp existed
# in CMake but wasn't in build.yml's --target list — this prevents that
# class of failure forever.
function(notepatra_add_qt_test target_name)
add_test(
NAME ${target_name}
COMMAND ${CMAKE_COMMAND} -E env QT_QPA_PLATFORM=offscreen $<TARGET_FILE:${target_name}>
)
set_property(GLOBAL APPEND PROPERTY notepatra_test_targets ${target_name})
endfunction()
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_terminal_ansi.cpp")
add_executable(test_terminal_ansi test_terminal_ansi.cpp)
target_link_libraries(test_terminal_ansi PRIVATE Qt5::Core)
notepatra_add_qt_test(test_terminal_ansi)
set_tests_properties(test_terminal_ansi PROPERTIES LABELS "smoke;terminal;v0125")
message(STATUS "Regression test enabled — target: test_terminal_ansi")
endif()
# ── Non-printing character display (Notepad++ "Show Symbol" parity) ─────────
# Links only editor_symbols.cpp, not the app: the assertions measure real
# laid-out pixel widths in a live QsciScintilla, and pulling in the Rust core
# would make a fast, purely-visual test slow for no benefit.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_editor_symbols.cpp")
add_executable(test_editor_symbols
test_editor_symbols.cpp
${CMAKE_SOURCE_DIR}/src/editor_symbols.cpp)
target_include_directories(test_editor_symbols PRIVATE
${CMAKE_SOURCE_DIR}/src ${QSCINTILLA_INCLUDE})
target_link_libraries(test_editor_symbols PRIVATE
Qt5::Widgets Qt5::Test ${QSCINTILLA_LIB})
if(WIN32)
target_compile_definitions(test_editor_symbols PRIVATE QSCINTILLA_DLL)
endif()
notepatra_add_qt_test(test_editor_symbols)
set_tests_properties(test_editor_symbols PROPERTIES
LABELS "regression;editor;symbols;v01124")
message(STATUS "Regression test enabled — target: test_editor_symbols")
endif()
# ── Indent guides keep the theme's colours (reserved STYLE_INDENTGUIDE) ─────
# Links the REAL Editor: the claim under test is that Editor::applyTheme
# reaches a reserved Scintilla style, and a test against a free helper would
# pass even if the theme path never called it. The source list is Editor's
# link closure only — no MainWindow, no AI/DB/chart stack.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_indent_guide_theme.cpp")
add_executable(test_indent_guide_theme
test_indent_guide_theme.cpp
${CMAKE_SOURCE_DIR}/src/editor.cpp
${CMAKE_SOURCE_DIR}/src/editor_symbols.cpp
${CMAKE_SOURCE_DIR}/src/npp_palette.cpp
${CMAKE_SOURCE_DIR}/src/lexerutils.cpp
${CMAKE_SOURCE_DIR}/src/lexer_csv.cpp
${CMAKE_SOURCE_DIR}/src/lexer_extras.cpp
${CMAKE_SOURCE_DIR}/src/lexer_go.cpp
${CMAKE_SOURCE_DIR}/src/lexer_kotlin.cpp
${CMAKE_SOURCE_DIR}/src/lexer_plaintext.cpp
${CMAKE_SOURCE_DIR}/src/lexer_powershell.cpp
${CMAKE_SOURCE_DIR}/src/lexer_rust.cpp
${CMAKE_SOURCE_DIR}/src/lexer_swift.cpp
${CMAKE_SOURCE_DIR}/src/lexer_typescript.cpp
${CMAKE_SOURCE_DIR}/src/rustbridge.cpp
${CMAKE_SOURCE_DIR}/src/gitgutter.cpp
${CMAKE_SOURCE_DIR}/src/git_hunk_apply.cpp
${CMAKE_SOURCE_DIR}/src/path_denylist.cpp
${CMAKE_SOURCE_DIR}/src/gutter_hunk_popup.cpp
${CMAKE_SOURCE_DIR}/src/diff_view.cpp)
add_dependencies(test_indent_guide_theme rust_core)
target_include_directories(test_indent_guide_theme PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/rust-core/include
${QSCINTILLA_INCLUDE})
target_link_libraries(test_indent_guide_theme PRIVATE
Qt5::Widgets Qt5::Test ${QSCINTILLA_LIB} ${RUST_LIB})
if(WIN32)
target_compile_definitions(test_indent_guide_theme PRIVATE QSCINTILLA_DLL)
target_link_libraries(test_indent_guide_theme PRIVATE
ws2_32 userenv bcrypt ntdll advapi32)
elseif(APPLE)
target_link_libraries(test_indent_guide_theme PRIVATE pthread dl m
"-framework Security" "-framework CoreFoundation")
else()
target_link_libraries(test_indent_guide_theme PRIVATE pthread dl m)
endif()
notepatra_add_qt_test(test_indent_guide_theme)
set_tests_properties(test_indent_guide_theme PROPERTIES
LABELS "regression;editor;theme;indentguide")
message(STATUS "Regression test enabled — target: test_indent_guide_theme")
endif()
# ── Read-only SQL classifier gate (query_sql / csv_query security contract) ──
# Links the REAL DbConnections::classifySql / isReadOnlyQuery / isMutation from
# dbconnections.cpp (Qt-Core string logic; NOTEPATRA_HAVE_DUCKDB stays off for
# this target so the classifier is exercised in isolation, no DuckDB link).
# Qt5::Gui/Widgets/Sql are pulled in because dbconnections.cpp's TU also holds
# the connection-manager dialog + QSqlDatabase code. Offscreen-safe: pure
# string logic, never constructs a widget or modal.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_db_readonly_gate.cpp")
add_executable(test_db_readonly_gate
test_db_readonly_gate.cpp
src/dbconnections.cpp
)
target_include_directories(test_db_readonly_gate PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_db_readonly_gate PRIVATE
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Sql)
notepatra_add_qt_test(test_db_readonly_gate)
set_tests_properties(test_db_readonly_gate PROPERTIES
LABELS "unit;ai;db;security" TIMEOUT 120)
message(STATUS "Regression test enabled — target: test_db_readonly_gate")
endif()
# ── .npd diagram parser (diagram subsystem; pure C++, no WebEngine) ──
# The parser is the source-of-truth engine the diagram canvas projects from,
# so it's covered here independently of the native QPainter renderer.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_npd_parser.cpp")
add_executable(test_npd_parser test_npd_parser.cpp src/diagram/npd_parser.cpp)
target_include_directories(test_npd_parser PRIVATE
${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/diagram)
target_link_libraries(test_npd_parser PRIVATE Qt5::Core)
notepatra_add_qt_test(test_npd_parser)
set_tests_properties(test_npd_parser PROPERTIES LABELS "unit;diagram")
message(STATUS "Regression test enabled — target: test_npd_parser")
endif()
# ── Mermaid → .npd importer test (pure; round-trips through Npd::parse) ──
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_mermaid_import.cpp")
add_executable(test_mermaid_import test_mermaid_import.cpp
src/diagram/mermaid_import.cpp src/diagram/npd_parser.cpp)
target_include_directories(test_mermaid_import PRIVATE
${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/diagram)
target_link_libraries(test_mermaid_import PRIVATE Qt5::Core)
notepatra_add_qt_test(test_mermaid_import)
set_tests_properties(test_mermaid_import PROPERTIES LABELS "unit;diagram")
endif()
# v0.1.78 — wire rust-core's cargo unit tests into ctest so the encoding /
# binary-detection regression tests run as part of release-check.sh.
# Includes the file_io UTF-16/32 BOM coverage added to fix the "UTF-16 LE
# .sql files flagged as binary" bug. cargo test in release mode mirrors what
# the production build links against, so we don't get a debug/release skew.
if(NOTEPATRA_BUILD_TESTS)
add_test(NAME rust_core_tests
COMMAND cargo test --release
WORKING_DIRECTORY ${RUST_CORE_DIR})
set_tests_properties(rust_core_tests PROPERTIES LABELS "unit;rust;encoding;v0178")
message(STATUS "Regression test enabled — rust-core cargo test")
endif()
# ── Save As filter contract test (v0.1.87 follow-up) ──
# Asserts the user-visible end-to-end contract — picking Python in the Save As
# dropdown auto-suffixes the saved file with .py — through the same helpers
# the dialog uses. Pure-functional, no Qt event loop.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_save_as_filters.cpp")
add_executable(test_save_as_filters
test_save_as_filters.cpp
src/lexerutils.cpp
src/lexer_go.cpp
src/lexer_kotlin.cpp
src/lexer_powershell.cpp
src/lexer_rust.cpp
src/lexer_swift.cpp
src/lexer_typescript.cpp
src/lexer_extras.cpp
src/lexer_plaintext.cpp
src/lexer_csv.cpp
)
target_include_directories(test_save_as_filters PRIVATE
${CMAKE_SOURCE_DIR}/src
${QSCINTILLA_INCLUDE}
)
target_link_libraries(test_save_as_filters PRIVATE
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport ${QSCINTILLA_LIB}
)
if(WIN32)
target_compile_definitions(test_save_as_filters PRIVATE QSCINTILLA_DLL)
endif()
notepatra_add_qt_test(test_save_as_filters)
set_tests_properties(test_save_as_filters PROPERTIES LABELS "smoke;saveas")
message(STATUS "Regression test enabled — target: test_save_as_filters")
endif()
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_last_dir.cpp")
add_executable(test_last_dir test_last_dir.cpp)
target_include_directories(test_last_dir PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_last_dir PRIVATE Qt5::Core)
notepatra_add_qt_test(test_last_dir)
set_tests_properties(test_last_dir PROPERTIES LABELS "unit;saveas;lastdir")
message(STATUS "Regression test enabled — target: test_last_dir")
endif()
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_lexers_v0125.cpp")
add_executable(test_lexers_v0125
test_lexers_v0125.cpp
src/lexerutils.cpp
src/lexer_go.cpp
src/lexer_kotlin.cpp
src/lexer_powershell.cpp
src/lexer_rust.cpp
src/lexer_swift.cpp
src/lexer_typescript.cpp
src/lexer_extras.cpp
src/lexer_plaintext.cpp
src/lexer_csv.cpp
)
target_include_directories(test_lexers_v0125 PRIVATE
${CMAKE_SOURCE_DIR}/src
${QSCINTILLA_INCLUDE}
)
target_link_libraries(test_lexers_v0125 PRIVATE
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport ${QSCINTILLA_LIB}
)
if(WIN32)
target_compile_definitions(test_lexers_v0125 PRIVATE QSCINTILLA_DLL)
endif()
notepatra_add_qt_test(test_lexers_v0125)
set_tests_properties(test_lexers_v0125 PROPERTIES LABELS "smoke;lexer;v0125")
message(STATUS "Regression test enabled — target: test_lexers_v0125")
endif()
# ── v0.1.58 release validation: lexer smoke test ──
# Builds tests/comprehensive/lexer_smoke.cpp which constructs a real
# QsciScintilla widget per language, attaches the lexer returned by
# Notepatra's createLexerForLanguage(), feeds it a keyword-rich snippet,
# and verifies Scintilla reports >=2 distinct styles AND some non-zero
# styled bytes — i.e. the lexer actually classified keywords as keywords.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/tests/comprehensive/lexer_smoke.cpp")
add_executable(test_lexer_smoke
tests/comprehensive/lexer_smoke.cpp
src/lexerutils.cpp
src/lexer_go.cpp
src/lexer_kotlin.cpp
src/lexer_powershell.cpp
src/lexer_rust.cpp
src/lexer_swift.cpp
src/lexer_typescript.cpp
src/lexer_extras.cpp
src/lexer_plaintext.cpp
src/lexer_csv.cpp
)
target_include_directories(test_lexer_smoke PRIVATE
${CMAKE_SOURCE_DIR}/src
${QSCINTILLA_INCLUDE}
)
target_link_libraries(test_lexer_smoke PRIVATE
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport ${QSCINTILLA_LIB}
)
if(WIN32)
target_compile_definitions(test_lexer_smoke PRIVATE QSCINTILLA_DLL)
endif()
notepatra_add_qt_test(test_lexer_smoke)
set_tests_properties(test_lexer_smoke PROPERTIES LABELS "smoke;lexer;v0158")
message(STATUS "Regression test enabled — target: test_lexer_smoke")
endif()
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_lexers.cpp")
add_executable(test_lexers test_lexers.cpp)
target_include_directories(test_lexers PRIVATE
${CMAKE_SOURCE_DIR}/src
${QSCINTILLA_INCLUDE}
)
target_link_libraries(test_lexers PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::PrintSupport
${QSCINTILLA_LIB}
)
if(WIN32)
target_compile_definitions(test_lexers PRIVATE QSCINTILLA_DLL)
endif()
notepatra_add_qt_test(test_lexers)
set_tests_properties(test_lexers PROPERTIES LABELS "smoke;lexer")
message(STATUS "Regression test enabled — target: test_lexers")
endif()
# ── Noter — HTML storage layer test (27 cases) ──
# Validates atomic write, backup ring, XSS sanitizer, lock file,
# filename safety, validate-before-write, and the 12 reliability
# defenses documented in design/notes-ux/index.html SURFACE 13.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_storage.cpp")
add_executable(test_notes_storage
test_notes_storage.cpp
src/notes_storage.cpp
src/notes_template.cpp
)
target_include_directories(test_notes_storage PRIVATE
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(test_notes_storage PRIVATE Qt5::Core Qt5::Network Qt5::Test)
add_test(NAME test_notes_storage COMMAND $<TARGET_FILE:test_notes_storage>)
set_tests_properties(test_notes_storage PROPERTIES LABELS "unit;noter;storage")
message(STATUS "Regression test enabled — target: test_notes_storage")
endif()
# ── Noter — SQLite todos + reminder engine test (172 cases) ──
# Validates schema migration, HTML action-block reindex round-trip,
# due-group classification across time boundaries, snooze + reminder
# state transitions, quick-todo creation, and the app-lifetime reminder
# service (persisted last-tick meta + unbounded catch-up digest).
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_todos.cpp")
add_executable(test_notes_todos
test_notes_todos.cpp
src/notes_todos.cpp
src/notes_reminder.cpp
)
target_include_directories(test_notes_todos PRIVATE
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(test_notes_todos PRIVATE Qt5::Core Qt5::Sql Qt5::Test)
add_test(NAME test_notes_todos COMMAND $<TARGET_FILE:test_notes_todos>)
set_tests_properties(test_notes_todos PROPERTIES LABELS "unit;noter;todos")
message(STATUS "Regression test enabled — target: test_notes_todos")
endif()
# ── Noter — sweep prompt builder + parser test (36 cases) ──
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_sweep_prompt.cpp")
add_executable(test_notes_sweep_prompt
test_notes_sweep_prompt.cpp
src/notes_sweep_prompt.cpp
)
target_include_directories(test_notes_sweep_prompt PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_notes_sweep_prompt PRIVATE Qt5::Core Qt5::Test)
add_test(NAME test_notes_sweep_prompt COMMAND $<TARGET_FILE:test_notes_sweep_prompt>)
set_tests_properties(test_notes_sweep_prompt PROPERTIES LABELS "unit;noter;sweep")
endif()
# ── Noter — AI-Extract marked-region apply layer (v0.1.112) ──
# Headless (QGuiApplication — QTextDocument needs QtGui, not Widgets).
# Links the REAL storage sanitizer so the apply→toHtml→sanitizeBody→
# setHtml→findExtractRegion round trip is exercised end-to-end: that
# round trip is the strongest regression guard on the invisible anchor
# markers the replace-in-place re-run behavior depends on.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_extract_apply.cpp")
add_executable(test_notes_extract_apply
test_notes_extract_apply.cpp
src/notes_extract_apply.cpp
src/notes_sweep_prompt.cpp
src/notes_storage.cpp
src/notes_template.cpp
)
target_include_directories(test_notes_extract_apply PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_notes_extract_apply PRIVATE
Qt5::Core Qt5::Gui Qt5::Network Qt5::Test)
add_test(NAME test_notes_extract_apply COMMAND $<TARGET_FILE:test_notes_extract_apply>)
set_tests_properties(test_notes_extract_apply PROPERTIES
LABELS "unit;noter;extract"
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
message(STATUS "Regression test enabled — target: test_notes_extract_apply")
endif()
# ── Noter — slide-over panels test (18 cases) ──
# v0.1.112 — also hosts the Extract reliability-layer widget tests, which
# drive the REAL NotesPanel (busy-state machine + pre-flight probe), so it
# links the same source set as test_notes_panel_widget.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_panels.cpp")
add_executable(test_notes_panels
test_notes_panels.cpp
src/notes.cpp
src/notes_storage.cpp
src/notes_template.cpp
src/notes_todos.cpp
src/notes_reminder.cpp
src/notes_popout.cpp
src/notes_sweep_dialog.cpp
src/notes_sweep_prompt.cpp
src/notes_extract_apply.cpp
src/notes_export.cpp
src/ollama.cpp
src/ai_interaction_log.cpp
src/credscrub.cpp
)
target_include_directories(test_notes_panels PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_notes_panels PRIVATE
Qt5::Core Qt5::Widgets Qt5::Sql Qt5::Network Qt5::Test
Qt5::PrintSupport)
add_test(NAME test_notes_panels COMMAND $<TARGET_FILE:test_notes_panels>)
set_tests_properties(test_notes_panels PROPERTIES LABELS "unit;noter;panels")
endif()
# ── Noter — NotesPanel widget integration test (v0.1.95) ──
# Heavy linkage: exercises the actual two-pane widget end-to-end via QTest
# keystrokes. Drives newMeetingNote / openNoteFile / markdown shortcuts /
# F4 toggle / Enter-on-checkbox behaviors that the unit tests can't reach.
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_panel_widget.cpp")
add_executable(test_notes_panel_widget
test_notes_panel_widget.cpp
src/notes.cpp
src/notes_storage.cpp
src/notes_template.cpp
src/notes_todos.cpp
src/notes_reminder.cpp
src/notes_popout.cpp
src/notes_sweep_dialog.cpp
src/notes_sweep_prompt.cpp
src/notes_extract_apply.cpp
src/notes_export.cpp
src/ollama.cpp
src/ai_interaction_log.cpp
src/credscrub.cpp
)
target_include_directories(test_notes_panel_widget PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_notes_panel_widget PRIVATE
Qt5::Core Qt5::Widgets Qt5::Sql Qt5::Network Qt5::Test
Qt5::PrintSupport)
add_test(NAME test_notes_panel_widget COMMAND $<TARGET_FILE:test_notes_panel_widget>)
set_tests_properties(test_notes_panel_widget PROPERTIES
LABELS "integration;noter;widget"
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
message(STATUS "Regression test enabled — target: test_notes_panel_widget")
endif()
# ── Noter — render-dump harness (writes PNGs for visual inspection) ──
if(NOTEPATRA_BUILD_TESTS AND EXISTS "${CMAKE_SOURCE_DIR}/test_noter_render.cpp")
add_executable(test_noter_render
test_noter_render.cpp
src/notes.cpp
src/notes_storage.cpp
src/notes_template.cpp
src/notes_todos.cpp
src/notes_reminder.cpp
src/notes_popout.cpp
src/notes_sweep_dialog.cpp
src/notes_sweep_prompt.cpp
src/notes_extract_apply.cpp
src/notes_export.cpp
src/ollama.cpp
src/ai_interaction_log.cpp
src/credscrub.cpp
)
target_include_directories(test_noter_render PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_noter_render PRIVATE
Qt5::Core Qt5::Widgets Qt5::Sql Qt5::Network Qt5::Test
Qt5::PrintSupport)
# Originally a manual visual-dump tool; registered as a ctest since the
# M6 discoverability gate (every Noter QShortcut must be documented in
# the Help guide) made it pass/fail. PNG dumps still land in /tmp.
add_test(NAME test_noter_render COMMAND $<TARGET_FILE:test_noter_render>)
set_tests_properties(test_noter_render PROPERTIES
LABELS "integration;noter;render"
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
endif()
# ── Noter — PDF + Markdown export test (25 cases, Full edition only) ──
if(NOTEPATRA_BUILD_TESTS AND NOTEPATRA_WITH_WEBENGINE
AND EXISTS "${CMAKE_SOURCE_DIR}/test_notes_export.cpp")
add_executable(test_notes_export
test_notes_export.cpp
src/notes_export.cpp
)
target_include_directories(test_notes_export PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(test_notes_export PRIVATE
Qt5::Core Qt5::Widgets Qt5::WebEngineWidgets Qt5::Test)
target_compile_definitions(test_notes_export PRIVATE NOTEPATRA_WITH_WEBENGINE=1)
add_test(NAME test_notes_export COMMAND $<TARGET_FILE:test_notes_export>)
set_tests_properties(test_notes_export PROPERTIES LABELS "unit;noter;export")
endif()