-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
1290 lines (1151 loc) · 46.5 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
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
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# Copyright (c) 2006-2011 Peter Kümmel, <[email protected]>
# Copyright (c) 2008-2020 Kornel Benko, <[email protected]>
cmake_minimum_required(VERSION 3.1.0)
set(LYX_PROJECT LyX)
# Instruct cmake to not use gnu extensions,
# this prevents the mix of '-std=c++*' and '-std=gnu++*' flags
set(CMAKE_CXX_EXTENSIONS OFF)
enable_testing()
get_filename_component(lyx_dir_readme ${CMAKE_SOURCE_DIR}/README REALPATH) # Resolve symlinks
get_filename_component(TOP_SRC_DIR ${lyx_dir_readme} PATH)
message(STATUS "TOP_SRC_DIR = ${TOP_SRC_DIR}")
set(LYX_CMAKE_DIR "development/cmake")
set(TOP_CMAKE_PATH "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}")
set(TOP_MODULE_PATH "${TOP_CMAKE_PATH}/modules")
set(TOP_SCRIPT_PATH "${TOP_CMAKE_PATH}/scripts")
set(CMAKE_MODULE_PATH "${TOP_MODULE_PATH}")
set(CMAKE_PROJECT_NAME ${LYX_PROJECT})
message(STATUS)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "Building in-source")
set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}/build")
else()
message(STATUS "Building out-of-source")
set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}")
endif()
# This directory should be used if some test uses lyx-executable
set(LYX_TESTS_USERDIR "${TOP_BINARY_DIR}/Testing/.lyx")
file(MAKE_DIRECTORY "${LYX_TESTS_USERDIR}")
if(COMMAND cmake_policy)
# Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION
cmake_policy(SET CMP0006 NEW)
if(POLICY CMP0043)
# COMPILE_DEFINITIONS are not used yet. Enable new behavior.
cmake_policy(SET CMP0043 NEW)
endif()
cmake_policy(SET CMP0020 NEW)
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
endif()
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Supress regeneration
set(CMAKE_SUPPRESS_REGENERATION FALSE)
if(LYX_XMINGW)
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLNAME ${LYX_XMINGW})
set(TOOLCHAIN "${TOOLNAME}-")
set(CMAKE_C_COMPILER "${TOOLCHAIN}gcc" CACHE PATH "Mingw C compiler" FORCE)
set(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++" CACHE PATH "Mingw C++ compiler" FORCE)
set(CMAKE_RC_COMPILER "${TOOLCHAIN}windres" CACHE PATH "Mingw rc compiler" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
if(NOT help AND NOT HELP)
# 'project' triggers the searching for a compiler
project(${LYX_PROJECT})
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
message(STATUS "Gnu CXX compiler version = ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "is too old, should be >= 4.9")
message(FATAL_ERROR "Exiting")
endif()
endif()
endif()
if(UNIX)
set(ARCH_TRIPLET )
FIND_PROGRAM(DPKG_ARCHITECTURE_EXECUTABLE dpkg-architecture)
if(DPKG_ARCHITECTURE_EXECUTABLE)
EXECUTE_PROCESS(COMMAND ${DPKG_ARCHITECTURE_EXECUTABLE} -qDEB_HOST_MULTIARCH
OUTPUT_VARIABLE ARCH_TRIPLET
ERROR_VARIABLE ERROR_ARCH_TRIPLET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
if(ARCH_TRIPLET)
set(SYSTEM_LIB_DIRS /usr/lib /usr/lib/${ARCH_TRIPLET} /usr/local/lib)
else()
set(SYSTEM_LIB_DIRS /usr/lib /usr/local/lib)
endif()
include(LyXMacros)
include(LyXDestinations)
# Value of USE_POSIX_PACKAGING is needed in determineversionandbuildtype()
if(WIN32)
set(CMAKE_PREFIX_PATH Specify-path-to-Qt CACHE PATH "Used Qt version")
if(MSVC)
set(LYX_3RDPARTY_BUILD ON CACHE BOOL "Build 3rdparty libraries" FORCE)
endif()
set(USE_WINDOWS_PACKAGING ON)
elseif(APPLE)
set(USE_MACOSX_PACKAGING ON)
else()
set(USE_POSIX_PACKAGING ON)
endif()
determineversionandbuildtype("${TOP_SRC_DIR}/configure.ac" _package_list _version_list _envlist LYX_DATE LYX_BUILD_TYPE)
list(GET _package_list 0 PACKAGE_BASE)
list(GET _package_list 1 PACKAGE_VERSION)
list(GET _package_list 2 PACKAGE_BUGREPORT)
list(GET _envlist 0 LYX_DIR_VER)
list(GET _envlist 1 LYX_USERDIR_VER)
list(GET _version_list 0 LYX_VERSION)
list(GET _version_list 1 LYX_MAJOR_VERSION)
list(GET _version_list 2 LYX_MINOR_VERSION)
list(GET _version_list 3 LYX_RELEASE_LEVEL)
list(GET _version_list 4 LYX_RELEASE_PATCH)
# Usage LYX_OPTION
# 1. parameter: option name without prefix 'LYX_'
# 2. parameter: description
# 3. parameter: default value, ON or OFF
# 4. parameter: system on which option is used: ALL, GCC, MSVC, ...
# Usage LYX_COMBO
# 1. parameter: name without prefix 'LYX_'
# 2. parameter: description
# 3. parameter: default value
# 4-n parameter: possible other string values
LYX_OPTION_INIT()
LYX_COMBO(ENABLE_BUILD_TYPE "Allows to tweak the compiled code" AUTO release prerelease development gprof)
if(LYX_ENABLE_BUILD_TYPE MATCHES "AUTO")
message(STATUS "Selecting build type defaults from configure.ac")
else()
set(LYX_BUILD_TYPE "${LYX_ENABLE_BUILD_TYPE}")
message(STATUS "Selecting build type defaults from LYX_ENABLE_BUILD_TYPE")
endif()
# Select some defaults depending on LYX_BUILD_TYPE
# they can always be overwritten by the respective command line settings
# These settings are only effective on fresh(==empty) CMakeCache.txt
if(LYX_BUILD_TYPE STREQUAL "development")
set(DefaultLyxDebug ON)
set(DefaultLyxRelease OFF)
set(DefaultLyxStdlibDebug ON)
set(DefaultLyxEnableAssertions ON)
set(DefaultLyxProfile OFF)
set(DefaultExternalLibs OFF)
elseif(LYX_BUILD_TYPE STREQUAL "prerelease")
set(DefaultLyxDebug OFF)
set(DefaultLyxRelease OFF)
set(DefaultLyxStdlibDebug OFF)
set(DefaultLyxEnableAssertions OFF)
set(DefaultLyxProfile OFF)
set(DefaultExternalLibs ON)
elseif(LYX_BUILD_TYPE STREQUAL "release")
set(DefaultLyxDebug OFF)
set(DefaultLyxRelease ON)
set(DefaultLyxStdlibDebug OFF)
set(DefaultLyxEnableAssertions OFF)
set(DefaultLyxProfile OFF)
set(DefaultExternalLibs ON)
elseif(LYX_BUILD_TYPE STREQUAL "gprof")
set(DefaultLyxDebug ON)
set(DefaultLyxRelease OFF)
set(DefaultLyxStdlibDebug OFF)
set(DefaultLyxEnableAssertions OFF)
set(DefaultLyxProfile ON)
set(DefaultExternalLibs OFF)
else()
message(FATAL_ERROR "Invalid build type (${LYX_BUILD_TYPE}) encountered")
endif()
# Options for all compilers/systems
LYX_OPTION(CPACK "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL)
LYX_OPTION(LOCALVERSIONING "Add version info to created package name (only used if LYX_CPACK option set)" OFF ALL)
LYX_OPTION(INSTALL "Build install projects/rules (implies a bunch of other options)" OFF ALL)
LYX_OPTION(NLS "Enable Native Language Support (NLS)" ON ALL)
LYX_OPTION(REQUIRE_SPELLCHECK "Abort if no spellchecker available" OFF ALL)
LYX_OPTION(ASPELL "Require aspell" OFF ALL)
LYX_OPTION(ENCHANT "Require Enchant" OFF ALL)
LYX_OPTION(HUNSPELL "Require Hunspell" OFF ALL)
LYX_OPTION(RELEASE "Build release version, build debug when disabled" ${DefaultLyxRelease} ALL)
LYX_OPTION(DEBUG "Enforce debug build" ${DefaultLyxDebug} ALL)
LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL)
LYX_OPTION(ENABLE_ASSERTIONS "Run sanity checks in the program" ${DefaultLyxEnableAssertions} ALL)
LYX_OPTION(PACKAGE_SUFFIX "Use version suffix for packaging" ON ALL)
LYX_STRING(SUFFIX_VALUE "Use this string as suffix" "")
LYX_OPTION(PCH "Use precompiled headers" OFF ALL)
LYX_OPTION(MERGE_FILES "Merge source files into one compilation unit" OFF ALL)
LYX_OPTION(MERGE_REBUILD "Rebuild generated files from merged files build" OFF ALL)
LYX_OPTION(QUIET "Don't generate verbose makefiles" OFF ALL)
LYX_OPTION(INSTALL_PREFIX "Install path for LyX" OFF ALL)
LYX_OPTION(BUNDLE "Build bundle (experimental) " OFF ALL)
LYX_OPTION(ENABLE_URLTESTS "Enable for URL tests" OFF ALL)
LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL)
LYX_OPTION(ENABLE_KEYTESTS "Enable for keytests" OFF ALL)
if (NOT CMAKE_VERSION VERSION_LESS "3.17")
LYX_OPTION(ENABLE_VALGRIND_TESTS "Enable for tests involving valgrind" OFF ALL)
else()
if (LYX_ENABLE_VALGRIND_TESTS)
unset(LYX_ENABLE_VALGRIND_TESTS CACHE)
endif()
endif()
LYX_COMBO(DEBUG_SANITIZE "Use sanitize check" NONE ADDRESS UNSPECIFIED)
#LYX_COMBO(USE_FILEDIALOG "Use native or QT file dialog" QT NATIVE)
LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT5 QT6)
LYX_COMBO(USE_IPO "Interprocedural optimization" OFF AUTO ON)
#LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL)
LYX_OPTION(DISABLE_CALLSTACK_PRINTING "do not print a callstack when crashing" OFF ALL)
LYX_OPTION(EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ${DefaultExternalLibs} ALL)
LYX_OPTION(EXTERNAL_DTL "OFF := Build 3rdparty commands dt2dv and dv2dt" ${DefaultExternalLibs} ALL)
LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ${DefaultExternalLibs} ALL)
LYX_OPTION(EXTERNAL_HUNSPELL "OFF := Build 3rdparty lib hunspelllib" ${DefaultExternalLibs} ALL)
LYX_COMBO(EXTERNAL_MYTHES "OFF := Build 3rdparty lib mytheslib" AUTO OFF ON)
# GCC specific
LYX_OPTION(PROFILE "Build with options for gprof" ${DefaultLyxProfile} GCC)
LYX_OPTION(EXTERNAL_BOOST "Use external boost" ${DefaultExternalLibs} GCC)
LYX_OPTION(PROGRAM_SUFFIX "Append version suffix to binaries" ON GCC)
LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC)
LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC)
LYX_OPTION(DEBUG_GLIBC_ASSERTIONS "Enable stdlib-assertions debug mode" OFF GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" ${DefaultLyxStdlibDebug} GCC)
# MSVC specific
LYX_OPTION(CONSOLE "Show console on Windows" ON MSVC)
LYX_OPTION(VLD "Use VLD with MSVC" OFF MSVC)
LYX_OPTION(WALL "Enable all warnings" OFF MSVC)
LYX_OPTION(DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC)
# APPLE specific
LYX_OPTION(DMG "Build as Mac bundle, needed for .dmg (experimental) " OFF MAC)
LYX_OPTION(COCOA "Use Cocoa on Mac" OFF MAC)
# On Windows, download the dependencies if need be.
if(LYX_DEPENDENCIES_DOWNLOAD)
message(STATUS)
# Do not check for bitness against CMAKE_SIZEOF_VOID_P, as it relates to the bitness of the CMake executable,
# not that of the compiler.
if(MSVC_VERSION GREATER_EQUAL 1920 AND "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" MATCHES "x64")
set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2019-deps-64)
set(deps_files lyx-windows-deps-msvc2019_64.zip)
set(deps_server http://ftp.lyx.org/pub/lyx/devel/win_deps)
set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/lyx-windows-deps-msvc2019-64)
elseif(MSVC_VERSION GREATER_EQUAL 1920)
set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2019-deps)
set(deps_files lyx-windows-deps-msvc2019_32.zip)
set(deps_server http://ftp.lyx.org/pub/lyx/devel/win_deps)
set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/lyx-windows-deps-msvc2019)
elseif(MSVC_VERSION GREATER_EQUAL 1900 AND NOT "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" MATCHES "x64")
set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2015-deps)
set(deps_files lyx-windows-deps-msvc2015.zip)
set(deps_server http://ftp.lyx.org/pub/lyx/devel/win_deps)
set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/lyx-windows-deps-msvc2015)
else()
message(FATAL_ERROR "error: no dependency package known for the selected MSVC version.")
endif()
message(STATUS "Using downloaded dependencies in ${LYX_DEPENDENCIES_DIR}")
foreach(it ${deps_files})
set(already_downloaded already_downloaded-NOTFOUND CACHE PATH "downloaded" FORCE)
find_file(already_downloaded ${it} "${LYX_DEPENDENCIES_DIR}/download")
if(NOT already_downloaded)
message(STATUS "Downloading ${it} ...")
file(DOWNLOAD ${deps_server}/${it} ${LYX_DEPENDENCIES_DIR}/download/${it} SHOW_PROGRESS STATUS status LOG log)
list(GET status 0 status_code)
list(GET status 1 status_string)
if(NOT status_code EQUAL 0)
file(REMOVE ${LYX_DEPENDENCIES_DIR}/${it})
message(FATAL_ERROR "error: downloading '${it}' failed. status_code: ${status_code}, status_string: ${status_string}. \nLog: ${log} ")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${LYX_DEPENDENCIES_DIR}/download/${it}
WORKING_DIRECTORY ${LYX_DEPENDENCIES_DIR})
endif()
endforeach()
endif()
# Try to get some information from configure.ac
include(LyXPaths)
if(help OR HELP)
message(STATUS)
message(STATUS "Available options: (dis/enable with -DLYX_*=OFF/ON)")
message(STATUS)
LYX_OPTION_LIST_ALL(help)
message(STATUS)
unset(help CACHE)
unset(HELP CACHE)
RETURN()
endif()
if ("${LYX_SUFFIX_VALUE}" MATCHES "")
set(LYX_INSTALL_SUFFIX "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
else()
set(LYX_INSTALL_SUFFIX "${LYX_SUFFIX_VALUE}")
endif()
# Check option dependencies
if (LYX_ENABLE_VALGRIND_TESTS)
find_program(VALGRIND_EXECUTABLE "valgrind")
if (NOT VALGRIND_EXECUTABLE)
message(FATAL_ERROR "Cannot use valgrind tests, executable valgrind is missing. Please disable LYX_ENABLE_VALGRIND_TESTS")
endif()
endif()
if (LYX_DEBUG_GLIBC OR LYX_DEBUG_GLIBC_PEDANTIC OR LYX_STDLIB_DEBUG)
if (LYX_EXTERNAL_BOOST)
message(FATAL_ERROR "Using external boost not compatible with debug mode for stdlib")
endif()
endif()
if(LYX_DMG)
set(LYX_BUNDLE ON)
set(LYX_CPACK ON)
endif()
if(LYX_CPACK)
set(LYX_INSTALL ON)
endif()
if(LYX_INSTALL)
set(LYX_NLS ON)
if(WIN32 AND NOT MINGW)
set(LYX_HUNSPELL ON)
endif()
set(LYX_PACKAGE_SUFFIX ON)
if(NOT LYX_DEBUG)
set(LYX_RELEASE ON)
endif()
set(LYX_PROFILE OFF)
endif()
if(LYX_MERGE_FILES)
set(LYX_PCH OFF)
else()
set(LYX_MERGE_REBUILD OFF)
endif()
message(STATUS)
set(EXECUTABLE_OUTPUT_PATH ${TOP_BINARY_DIR}/bin)
if(WIN32)
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
else()
set(LIBRARY_OUTPUT_PATH ${TOP_BINARY_DIR}/lib)
endif()
set(LYX_IPO_SUPPORTED OFF)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
if(LYX_USE_IPO MATCHES "AUTO")
# Enable LTO if supported and not debugging
if (NOT LYX_DEBUG)
include(CheckIPOSupported)
check_ipo_supported(RESULT LYX_IPO_SUPPORTED)
endif()
else()
set(LYX_IPO_SUPPORTED ${LYX_USE_IPO})
endif()
endif()
if (LYX_IPO_SUPPORTED)
set(LYX_USE_IPO "ON" CACHE STRING "Use interprocedural optimization" FORCE)
else()
set(LYX_USE_IPO "OFF" CACHE STRING "Use interprocedural optimization" FORCE)
endif()
# Set to some meaningful default
find_package(CXX11Compiler)
if(NOT CXX11COMPILER_FOUND)
message(FATAL_ERROR "A C++11 compatible compiler is required.")
endif()
unset(LYX_GCC11_MODE)
if(UNIX OR MINGW)
if (CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$")
# ignore the GCC_VERSION for clang
message(STATUS "Using clang")
else()
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion OUTPUT_VARIABLE GCC_VERSION ERROR_VARIABLE _error RESULT_VARIABLE _err OUTPUT_STRIP_TRAILING_WHITESPACE)
#message(STATUS "dumpfullversion: error = ${_error}, result = ${_err}")
if (_err)
# previous check failed, try again with _old_ parameter
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION ERROR_VARIABLE _error RESULT_VARIABLE _err OUTPUT_STRIP_TRAILING_WHITESPACE)
#message(STATUS "dumpversion: error = ${_error}, result = ${_err}")
endif()
message(STATUS "Using GCC version ${GCC_VERSION}")
if(GCC_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR "gcc >= 4.9 is required.")
endif()
endif()
set(LYX_GCC11_MODE "${CXX11_FLAG}")
else()
if(MSVC_VERSION LESS 1900)
# Drop support for msvc versions prior to 1900 (Visual Studio 2015)
message(FATAL_ERROR "Visual Studio >= 2015 is required.")
endif()
endif()
if(LYX_3RDPARTY_BUILD)
# LYX_3RDPARTY_BUILD is not cached anymore, but for compatibility reasons
# this enables the build of all 3rd_party libs
set(LYX_EXTERNAL_Z OFF CACHE BOOL "Build 3rdparty lib zlib" FORCE)
set(LYX_EXTERNAL_ICONV OFF CACHE BOOL "Build 3rdparty iconvlib" FORCE)
set(LYX_EXTERNAL_HUNSPELL OFF CACHE BOOL "Build 3rdparty hunspelllib" FORCE)
set(LYX_EXTERNAL_MYTHES OFF CACHE STRING "Build 3rdparty mytheslib" FORCE)
endif()
FIND_PROGRAM(LYX_GITVERSION git)
#message(STATUS "gitversion = ${LYX_GITVERSION}")
set(LYX_REVISION_VERSION ${LYX_RELEASE_LEVEL})
set(LYX_PACKAGE_RELEASE "UNDEFINED")
if(LYX_GITVERSION)
if (LYX_LOCALVERSIONING)
# Find the revision number for later use
EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} describe --match 2.0.0 HEAD
WORKING_DIRECTORY "${TOP_SRC_DIR}"
RESULT_VARIABLE tmp_GIT_RESULT
OUTPUT_VARIABLE tmp_LYX_PACKAGE_RELEASE
ERROR_VARIABLE tmp_GIT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (tmp_GIT_RESULT EQUAL 0)
if (tmp_LYX_PACKAGE_RELEASE MATCHES "^2\\.0\\.0\\-\([0-9]+\)\\-\(.*\)$")
set(LYX_PACKAGE_RELEASE ${CMAKE_MATCH_2})
# We will add offset of 40000 to get appropriate value to
# previous svn.
# We use this value than also to set the package-patch-value
MATH(EXPR tmp_REVISION_VERSION "(${CMAKE_MATCH_1}+40000)")
set(LYX_REVISION_VERSION "${LYX_RELEASE_LEVEL}-${tmp_REVISION_VERSION}git")
set(ENABLE_DIST ON)
endif()
endif()
endif()
endif()
if (LYX_PACKAGE_RELEASE MATCHES "UNDEFINED")
set(LYX_PACKAGE_RELEASE "1")
if (LYX_RELEASE_PATCH GREATER 0)
set(LYX_REVISION_VERSION "${LYX_RELEASE_LEVEL}.${LYX_RELEASE_PATCH}")
endif()
endif()
# Set the programs (lyx, tex2lyx, etc.) suffix
# When building an OS X bundle, we will append
# the suffix only to the bundle, not to the programs
set(PROGRAM_SUFFIX "")
if(LYX_PROGRAM_SUFFIX AND NOT (APPLE AND LYX_BUNDLE))
set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}")
endif()
set(_lyx "${PACKAGE_BASE}${PROGRAM_SUFFIX}")
set(_tex2lyx tex2lyx${PROGRAM_SUFFIX})
set(_convert lyxconvert${PROGRAM_SUFFIX})
add_custom_target(lyx_version ALL
COMMAND ${CMAKE_COMMAND} -DTOP_SRC_DIR=${TOP_SRC_DIR} -DTOP_CMAKE_PATH=${TOP_CMAKE_PATH} -DTOP_BINARY_DIR=${TOP_BINARY_DIR} -DLYX_DATE=${LYX_DATE} -P ${TOP_SCRIPT_PATH}/LyXGetVersion.cmake
)
set_target_properties(lyx_version PROPERTIES FOLDER "applications")
# Default paths for installed utilities (tex2lyx, lyxclient, etc.)
set(LYX_UTILITIES_INSTALL_PATH bin)
if(LYX_BUNDLE)
set(LYX_CPACK ON)
message(STATUS)
message(STATUS "Bundle creation is enabled (experimental):")
message(STATUS " make")
message(STATUS " make install/strip")
message(STATUS " make package")
if(APPLE)
set(MACOSX_BUNDLE TRUE)
# This sets the bundle + executable names
set(_lyx "${PACKAGE_BASE}${LYX_INSTALL_SUFFIX}")
# This sets the Info.plist executable name
set(osx_bundle_program_name ${_lyx})
# Bundle name
set(LYX_BUNDLE_NAME ${_lyx})
# This will contain the list of files that need to be included
# in the bundle and their location within the bundle
set(OSX_BUNDLE_FILES "${TOP_SRC_DIR}/development/MacOSX/LyX.sdef;${TOP_SRC_DIR}/development/MacOSX/LyXapp.icns;${CMAKE_BINARY_DIR}/lyxrc.dist")
set(OSX_BUNDLE_DIRS "Resources;Resources;Resources")
# Process Info.plist and lyxrc.dist
# See development/cmake/Install.cmake
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/development/MacOSX/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
set(LYX_BUILD_BUNDLE MACOSX_BUNDLE)
set(LYX_DATA_SUBDIR ${LYX_BUNDLE_NAME}.app/Contents/Resources/ CACHE STRING "Bundle Contents dir" FORCE)
# Variables used by CPack
set(CPACK_BUNDLE_NAME ${LYX_BUNDLE_NAME})
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
set(MACOSX_BUNDLE_STARTUP_COMMAND ${LYX_BUNDLE_NAME}.app)
# Set the install paths
set(LYX_UTILITIES_INSTALL_PATH ${LYX_BUNDLE_NAME}.app/Contents/MacOS)
if(NOT LYX_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/LyX CACHE PATH "Mac bundle dir" FORCE)
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
# Change the owner so that the install can work
install(CODE "set(BU_CHMOD_BUNDLE_ITEMS 1)" COMPONENT Runtime)
elseif(UNIX)
message(STATUS "To embed Qt in this bundle don't build with your system Qt:")
message(STATUS " - fix PATH so a other qmake is found by cmake")
message(STATUS " - fix LD_LIBRARY_PATH so lyx doesn't use system's Qt")
elseif(WIN32)
message(STATUS "A zipped-only release could be created by building the 'PACKAGE' project")
endif()
endif()
if(LYX_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${LYX_INSTALL_PREFIX} CACHE PATH "LyX user's choice install prefix" FORCE)
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
set(LYX_INSTALL_PREFIX ${LYX_INSTALL_PREFIX} CACHE PATH "LyX user's choice install prefix" FORCE)
if(UNIX)
set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}/share")
elseif(CMAKE_INSTALL_PREFIX MATCHES "/lyx${LYX_INSTALL_SUFFIX}$")
string(REGEX REPLACE "/lyx${LYX_INSTALL_SUFFIX}$" "/share" SYSTEM_DATADIR ${CMAKE_INSTALL_PREFIX})
else()
set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}")
endif()
if(NOT CMAKE_COMPILER_IS_GNUCXX)
# Not a GCC compiler, programs do not have a suffix
set(suffixing ${LYX_PACKAGE_SUFFIX})
elseif(WIN32 AND MINGW)
# We want to use a suffix for the package in this case,
# even if not for the program
set(suffixing ${LYX_PACKAGE_SUFFIX})
else()
message(STATUS "CMAKE_COMPILER_IS_GNUCXX = ${CMAKE_COMPILER_IS_GNUCXX}")
set(suffixing ${LYX_PROGRAM_SUFFIX})
endif()
# The define PACKAGE below allows lyx-executable to find its default configuration files
# see routines
# Package::messages_file()
# get_default_user_support_dir()
# relative_system_support_dir()
# in src/support/Package.cpp
if(suffixing)
set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
else()
set(PACKAGE ${PACKAGE_BASE})
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# see http://www.cmake.org/pipermail/cmake/2006-October/011559.html
if (UNIX)
# use the default "/usr/local"
# but respect the user-choice on the command-line
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "LyX default install prefix" FORCE)
endif()
endif()
if(WIN32)
set(CMAKE_INSTALL_PREFIX LYX_INSTALLED CACHE PATH "LyX default install prefix" FORCE)
endif()
if(IS_ABSOLUTE)
set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_INSTALL_PREFIX})
else()
set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX})
endif()
if(NOT LYX_DATA_SUBDIR)
if (WIN32)
set(LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
else()
set(LYX_DATA_SUBDIR "share/${_lyx}/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
endif()
endif()
set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}/${LYX_DATA_SUBDIR}")
get_locale_destination(LYX_LOCALEDIR)
set(LYX_ABS_INSTALLED_LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LYX_LOCALEDIR}")
set(LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}")
if(LYX_BUNDLE AND APPLE)
set(LYX_MAN_DIR_tmp "${LYX_DATA_SUBDIR}")
else()
if(WIN32)
set(LYX_MAN_DIR_tmp "${CMAKE_BINARY_DIR}/usr/local/man/")
elseif(UNIX)
set(LYX_MAN_DIR_tmp "${CMAKE_INSTALL_PREFIX}/share/man/")
else()
set(LYX_MAN_DIR_tmp "${CMAKE_INSTALL_PREFIX}/man/")
endif()
endif()
if (NOT LYX_MAN_DIR_tmp EQUAL "${LYX_MAN_DIR}")
unset(LYX_MAN_DIR CACHE)
set(LYX_MAN_DIR "${LYX_MAN_DIR_tmp}" CACHE STRING "Install location for man pages.")
endif()
unset(LYX_MAN_DIR_tmp)
mark_as_advanced(LYX_MAN_DIR)
# The Win installer cannot be built by CMake because one needs to install plugins for NSIS
# see the Readme.txt of the installer
#if(LYX_INSTALL AND WIN32)
# message(STATUS "Configuring NSIS files")
# configure_file(development/Win32/packaging/installer/lyx.nsi.cmake ${CMAKE_BINARY_DIR}/installer/lyx.nsi @ONLY)
# configure_file(development/Win32/packaging/installer/settings.nsh.cmake ${CMAKE_BINARY_DIR}/installer/settings-cmake.nsh @ONLY)
# configure_file(development/Win32/packaging/installer/include/declarations.nsh.cmake ${CMAKE_BINARY_DIR}/installer/declarations-cmake.nsh @ONLY)
# message(STATUS "NSIS files are created in ${CMAKE_BINARY_DIR}/installer")
#endif()
if(NOT GROUP_CODE)
#set(GROUP_CODE "The Golden Code")
set(GROUP_CODE flat)
endif()
# lyx's source files
set(LYX_CPP_FILES [a-zA-Z]*.cpp)
set(LYX_HPP_FILES [a-zA-Z]*.h)
set(LYX_MOC_FILES moc_*.cpp)
include(ProjectSourceGroup)
if(LYX_PROFILE AND NOT MSVC)
set(CMAKE_BUILD_TYPE Profile CACHE STRING "Profile build type" FORCE)
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
else()
set(LYX_PROFILE OFF)
endif()
if(LYX_NO_OPTIMIZE)
set(CMAKE_BUILD_TYPE None)
set(LYX_DEBUG OFF)
set(LYX_RELEASE OFF)
set(LYX_PROFILE OFF)
elseif(LYX_RELEASE)
set(CMAKE_BUILD_TYPE Release)
set(LYX_DEBUG OFF)
set(LYX_PROFILE OFF)
elseif(LYX_PROFILE)
set(CMAKE_BUILD_TYPE Profile)
set(LYX_DEBUG OFF)
else()
set(CMAKE_BUILD_TYPE Debug)
set(LYX_DEBUG ON)
endif()
set(min_qt5_version "5.6")
if(LYX_USE_QT MATCHES "AUTO")
# try qt6 first
find_package(Qt6Core CONFIG QUIET)
if (Qt6Core_Found)
set(LYX_USE_QT "QT6" CACHE STRING "Valid qt version" FORCE)
message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
else()
find_package(Qt5Core CONFIG QUIET)
if(Qt5Core_FOUND)
set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE)
message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version})
message(FATAL_ERROR "No appropriate QT-version found")
endif()
else()
message(FATAL_ERROR "No appropriate QT-version found")
endif()
endif()
endif()
# When shared libs are supported enable this option
#LYX_OPTION(SHARED_LIBRARIES "Build shared libraries" OFF ALL)
if(LYX_SHARED_LIBRARIES)
set(library_type SHARED)
else()
set(library_type STATIC)
endif()
if(LYX_ENABLE_ASSERTIONS)
set(LYX_CXX_FLAGS " -DENABLE_ASSERTIONS=1")
else()
set(LYX_CXX_FLAGS "")
endif()
if (LYX_DEBUG_SANITIZE MATCHES "ADDRESS")
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
message(STATUS)
message(STATUS "Address sanitizer enabled. Usage:")
message(STATUS " wget https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py")
message(STATUS " chmod +x ./asan_symbolize.py")
message(STATUS " ./bin/${_lyx} 2>&1 | ./asan_symbolize.py | c++filt ")
message(STATUS)
elseif (LYX_DEBUG_SANITIZE MATCHES "UNSPECIFIED")
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
endif()
if(MSVC)
if (CXX11_FLAG MATCHES "\\+\\+([0-9]+)")
set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
message(STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${LYX_CXX_FLAGS}")
else()
if(NOT LYX_QUIET)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
if(LYX_GCC11_MODE MATCHES "\\+\\+([0-9][0-9])")
# Thanks to Brad King <[email protected]>
# for the pointer to https://cmake.org/cmake/help/v3.6/variable/CMAKE_CXX_STANDARD.html
# This allows us to use QT5.7 with recent g++ (version >= 4.9) compilers
# and still use our own c++ extension tests
set(std_num ${CMAKE_MATCH_1})
set(CMAKE_CXX_STANDARD ${std_num})
else()
message(STATUS "Setting CMAKE_CXX_STANDARD 11 as fallback")
set(CMAKE_CXX_STANDARD 11)
set(LYX_GCC11_MODE "--std=c++11")
endif()
# The following setting with LYX_GCC11_MODE is needed because cmake does not honor
# CMAKE_CXX_STANDARD while performing tests like
# check_cxx_source_compiles("..." HAVE_DEF_MAKE_UNIQUE)
include(CheckCXXCompilerFlag)
unset(CHECK_WNODEPRECATEDCOPY_FLAG CACHE)
CHECK_CXX_COMPILER_FLAG("-Wdeprecated-copy" CHECK_WNODEPRECATEDCOPY_FLAG)
if(${CHECK_WNODEPRECATEDCOPY_FLAG})
set(LYX_CXX_FLAGS "-Wall -Wextra -Wno-deprecated-copy ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}")
else()
set(LYX_CXX_FLAGS "-Wall -Wextra ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}")
endif()
message(STATUS "LYX_USE_QT = ${LYX_USE_QT}")
if(LYX_USE_QT MATCHES "QT6")
if (LYX_DEBUG_GLIBC OR LYX_DEBUG_GLIBC_PEDANTIC)
message(WARNING "Compiling LyX with stdlib-debug and Qt6 library may lead to crashes. Consider dropping -DLYX_DEBUG_GLIBC=ON and -DLYX_DEBUG_GLIBC_PEDANTIC=ON")
endif()
endif()
if(LYX_STDLIB_DEBUG OR LYX_DEBUG_GLIBC_ASSERTIONS)
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_ASSERTIONS")
endif()
if(LYX_DEBUG_GLIBC)
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG")
endif()
if(LYX_DEBUG_GLIBC_PEDANTIC)
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG_PEDANTIC")
endif()
set(CMAKE_CXX_FLAGS "${LYX_CXX_FLAGS} -fno-strict-aliasing " CACHE STRING "Set CXX flags" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -D_DEBUG" CACHE STRING "Set debug flags" FORCE)
if(MINGW)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Set release flags for Mingw" FORCE)
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Set release flags" FORCE)
endif()
endif()
set(LYX_CXX_FLAGS_EXTRA "" CACHE STRING "Desired semicolon separated list of extra cxx compile flags, like '-Werror'")
mark_as_advanced(LYX_CXX_FLAGS_EXTRA)
if(LYX_CXX_FLAGS_EXTRA)
foreach(_flag ${LYX_CXX_FLAGS_EXTRA})
add_definitions(${_flag})
endforeach()
endif()
if(LYX_XMINGW)
list(APPEND CMAKE_FIND_ROOT_PATH ${GNUWIN32_DIR})
endif()
set(QtCore5CompatLibrary)
set(QtCore5CompatModule)
if(LYX_USE_QT MATCHES "QT6|QT5")
if (LYX_USE_QT MATCHES "QT6")
set(QtVal "Qt6")
macro (qt_add_resources)
Qt6_add_resources(${ARGN})
endmacro()
macro (qt_wrap_uifiles)
Qt6_wrap_ui(${ARGN})
endmacro()
else()
set(QtVal "Qt5")
macro (qt_add_resources)
Qt5_add_resources(${ARGN})
endmacro()
macro (qt_wrap_uifiles)
Qt5_wrap_ui(${ARGN})
endmacro()
endif()
# set QPA_XCB if QT uses X11
find_package(${QtVal}Core CONFIG REQUIRED)
if (${QtVal}Core_FOUND)
find_package(${QtVal}Widgets CONFIG REQUIRED)
if(APPLE)
if (LYX_USE_QT MATCHES "QT6")
find_package(${QtVal}MacExtras CONFIG QUIET)
else()
find_package(${QtVal}MacExtras CONFIG REQUIRED)
endif()
endif()
find_package(${QtVal}X11Extras CONFIG QUIET)
find_package(${QtVal}WinExtras CONFIG QUIET)
set(QTVERSION ${${QtVal}Core_VERSION})
if (QTVERSION VERSION_LESS ${min_qt5_version})
message(STATUS "QTVERSION = \"${QTVERSION}\"")
message(STATUS "This version is not recommended,")
message(STATUS "please install QT-Version >= \"${min_qt5_version}\"")
# see thread in lyx-devel list
# From: Jean-Pierre Chrétien <[email protected]>
# Date 11.03.2017
# Subject: cmake compilation error
#message(FATAL_ERROR "Wrong Qt-Version")
endif()
macro (qt_use_modules lyxtarget)
foreach (_tg ${ARGN})
find_package(${QtVal}${_tg} CONFIG REQUIRED)
target_link_libraries(${lyxtarget} ${QtVal}::${_tg})
endforeach()
endmacro()
message(STATUS "Found Qt-Version ${QTVERSION}")
if(WIN32)
set(LYX_QTMAIN_LIBRARY ${${QtVal}Core_QTMAIN_LIBRARIES})
endif()
if (LYX_USE_QT MATCHES "QT6")
get_target_property(QT_MOC_EXECUTABLE Qt6::moc LOCATION)
#find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
# We don't know why QtZlib is included, and ideally we
# would have a different fix than relying on this
# variable (which as "Private" in the name indicates,
# it might be a fragile workaround).
# See ML discussion here:
# https://www.mail-archive.com/search?l=mid&q=CAGU9VOqpkngYBumnNh%3DcuzQ585GsS7TJbhHa903nJSfy-davRg%40mail.gmail.com
list(REMOVE_ITEM Qt6Core5Compat_INCLUDE_DIRS ${_Qt6ZlibPrivate_OWN_INCLUDE_DIRS})
include_directories(${Qt6Core5Compat_INCLUDE_DIRS})
#set(QtCore5CompatLibrary Qt6::Core5Compat)
#set(QtCore5CompatModule Core5Compat)
endif()
endif()
else()
message(FATAL_ERROR "Unhandled value for LYX_USE_QT (${LYX_USE_QT})")
endif()
find_package(Magic)
if(Magic_FOUND)
set(HAVE_MAGIC_H 1)
include_directories(${Magic_INCLUDE_DIR})
endif()
include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
set(Spelling_FOUND OFF)
set(Include_used_spellchecker) # String will be inserted into config.h
if (LYX_EXTERNAL_MYTHES MATCHES "AUTO")
# try system library first
find_package(MYTHESLIB)
if (MYTHESLIB_FOUND)
set(LYX_EXTERNAL_MYTHES ON CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE)
else()
set(LYX_EXTERNAL_MYTHES OFF CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE)
endif()
endif()
if (LYX_EXTERNAL_MYTHES MATCHES "ON")
find_package(MYTHESLIB REQUIRED)
else()
add_subdirectory(3rdparty/mythes)
endif()
set(MYTHES_DIR ${MYTHESLIB_INCLUDE_DIR})
if(NOT LYX_EXTERNAL_HUNSPELL)
add_subdirectory(3rdparty/hunspell)
add_definitions(-DHUNSPELL_STATIC)
set(HUNSPELL_FOUND ON)
message(STATUS " * Hunspell:")
message(STATUS " - include: ${HUNSPELL_INCLUDE_DIR}")
message(STATUS " - library: ${HUNSPELL_LIBRARY}")
endif()
foreach(_spell "ASPELL" "ENCHANT" "HUNSPELL")
string(TOUPPER ${_spell} _upspell)
if (NOT ${_upspell}_FOUND)
find_package(${_spell})
endif()
if (${_upspell}_FOUND)
include_directories(${${_upspell}_INCLUDE_DIR})
set(Spelling_FOUND ON)
message(STATUS "Building with USE_${_upspell}")
set(Include_used_spellchecker "${Include_used_spellchecker}#define USE_${_upspell} 1\n")
else()
if(LYX_${_upspell})
message(FATAL_ERROR "Required ${_spell} devel package not found")
else()
message(STATUS "${_upspell} not found, building without ${_spell} support")
endif()
endif()
endforeach()
if(GNUWIN32_DIR)
list(APPEND CMAKE_PROGRAM_PATH "${GNUWIN32_DIR}/Python" )
list(APPEND CMAKE_PROGRAM_PATH "${GNUWIN32_DIR}/Perl/bin" )
endif()
# Search for python default version first
unset(PYTHON_EXECUTABLE CACHE)
unset(LYX_PYTHON_EXECUTABLE CACHE)
unset(PYTHON_VERSION_MAJOR)
unset(PYTHON_VERSION_MINOR)
unset(PYTHON_VERSION_STRING)
if (CMAKE_VERSION VERSION_LESS "3.13")
find_package(PythonInterp 3.5 QUIET)
if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp 2.0 REQUIRED)
if(NOT PYTHON_VERSION_STRING VERSION_LESS 2.8)
message(FATAL_ERROR "Python interpreter found, but is not suitable")
endif()
endif()
set(LYX_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
else()
find_package(Python3 3.5 QUIET)
if(NOT Python3_Interpreter_FOUND)
unset(PYTHON_EXECUTABLE CACHE)
find_package(Python2 2.0 REQUIRED)
if(NOT Python2_VERSION VERSION_LESS 2.8)
message(FATAL_ERROR "Python interpreter found, but is not suitable")
endif()
set(LYX_PYTHON_EXECUTABLE ${Python2_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
else()
set(LYX_PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
endif()
endif()
if(LYX_NLS)
find_package(LyXGettext)
if(LYX_PYTHON_EXECUTABLE AND GETTEXT_FOUND)
add_subdirectory(po "${TOP_BINARY_DIR}/po")
else()
# Install only supplied .gmo-files
file(GLOB _gmofiles RELATIVE "${TOP_SRC_DIR}/po" "${TOP_SRC_DIR}/po/*.gmo")
message(STATUS "Installing provided .gmo-files only")
foreach( _gmo ${_gmofiles})
string(REGEX REPLACE "\\.gmo$" "" _lang ${_gmo})
install(FILES "${TOP_SRC_DIR}/po/${_gmo}" DESTINATION ${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
endforeach()
endif()
endif()
if(LYX_EXTERNAL_ICONV)
# Possible remnants of previous run without external iconv
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/libiconv" "${CMAKE_BINARY_DIR}/3rdparty/libiconv")
find_package(ICONV REQUIRED)
else()
add_subdirectory(3rdparty/libiconv)
set(HAVE_ICONV_CONST 1)
endif()
if(LYX_EXTERNAL_Z)
find_package(ZLIB REQUIRED)
else()
add_subdirectory(3rdparty/zlib)
endif()
if(NOT LYX_EXTERNAL_DTL)
add_subdirectory(3rdparty/dtl)
endif()
# Set only include path.
# Use internal boost, which is known to exist
# we don't need any libraries
set(Lyx_Boost_Libraries)
add_definitions(-DBOOST_USER_CONFIG=<config.h>)
include_directories(${TOP_SRC_DIR}/3rdparty/boost)
include_directories(${TOP_SRC_DIR}/3rdparty/nod)
if(WIN32)
if(LYX_CONSOLE)
set(LYX_QTMAIN_LIBRARY)
else()
set(WIN32_CONSOLE WIN32)
endif()
if(MSVC)
# -DPSAPI_VERSION=1 is needed to run on vista (bug 10186)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX -DPSAPI_VERSION=1)
# disable checked iterators for msvc release builds to get maximum speed
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /D_SECURE_SCL=0")
else()
# -DPSAPI_VERSION=1 is not needed for mingw, since the mingw psapi.h
# does not use it and always declares the vista compatible API.
# If this ever changes then -DPSAPI_VERSION might be needed here as well.
add_definitions(-DWINVER=0x0500)