-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
CMakeLists.txt
106 lines (88 loc) · 2.92 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
cmake_minimum_required(VERSION 3.16) # Qt requires CMake 3.16
project(qmarkdowntextedit LANGUAGES CXX VERSION 1.0.0)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# add option to disable test executable
option(QMARKDOWNTEXTEDIT_EXE "Build test executable" ON)
# find qt
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Quick)
# needed for windows
if(WIN32)
set(INTL_LDFLAGS -lintl)
endif(WIN32)
# QMarkdownTextEdit library
set(RC_FILES
media.qrc
)
# Translations arent loaded so don't include them
set(TS_FILES
trans/qmarkdowntextedit_de.ts
trans/qmarkdowntextedit_ur.ts
trans/qmarkdowntextedit_zh_CN.ts
)
set(QMARKDOWNTEXTEDIT_SOURCES
${RC_FILES}
linenumberarea.h # We need to keep this here, otherwise the build fails
markdownhighlighter.cpp
qmarkdowntextedit.cpp
qownlanguagedata.cpp
qownlanguagedata.h
qplaintexteditsearchwidget.cpp
qplaintexteditsearchwidget.ui
)
set(QMARKDOWNTEXTEDIT_HEADERS
markdownhighlighter.h
qmarkdowntextedit.h
qplaintexteditsearchwidget.h
)
add_library(qmarkdowntextedit ${QMARKDOWNTEXTEDIT_SOURCES})
set_target_properties(qmarkdowntextedit PROPERTIES
PUBLIC_HEADER "${QMARKDOWNTEXTEDIT_HEADERS}"
)
target_link_libraries(qmarkdowntextedit PUBLIC
Qt${QT_VERSION_MAJOR}::Widgets
${INTL_LDFLAGS}
)
if (Qt${QT_VERSION_MAJOR}Quick_FOUND)
target_link_libraries(qmarkdowntextedit PUBLIC Qt${QT_VERSION_MAJOR}::Quick)
add_executable(QtQuickExample examples/qml/example.cpp examples/qml/ressources.qrc)
target_link_libraries(QtQuickExample PRIVATE Qt${QT_VERSION_MAJOR}::Quick qmarkdowntextedit)
endif()
# QMarkdownTextEdit executable
if(QMARKDOWNTEXTEDIT_EXE)
set(SOURCE_FILES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
)
add_executable(qmarkdowntextedit-exe ${SOURCE_FILES})
set_target_properties(qmarkdowntextedit-exe PROPERTIES OUTPUT_NAME "qmarkdowntextedit")
target_link_libraries(qmarkdowntextedit-exe PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
${INTL_LDFLAGS}
qmarkdowntextedit
)
endif()
include(GNUInstallDirs) # Doesn't fail on windows
# Install the lib
install(TARGETS qmarkdowntextedit
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Add PkgConfig config file
configure_file(qmarkdowntextedit.pc.in ${CMAKE_BINARY_DIR}/qmarkdowntextedit.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/qmarkdowntextedit.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
# Install exe
if(QMARKDOWNTEXTEDIT_EXE)
install(TARGETS qmarkdowntextedit-exe DESTINATION bin)
endif()