File: CMakeLists.txt

package info (click to toggle)
plplot 5.14.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 30,424 kB
  • sloc: ansic: 79,613; xml: 28,583; cpp: 20,037; ada: 19,456; tcl: 12,081; f90: 11,423; ml: 7,276; java: 6,863; python: 6,792; sh: 3,185; perl: 828; lisp: 75; makefile: 48; sed: 33; fortran: 5
file content (156 lines) | stat: -rw-r--r-- 6,065 bytes parent folder | download | duplicates (4)
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
# MAINTENANCE
# Use same minimum version for all platforms as the Linux platform minimum adopted for
# the PLplot project.
cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)

project(test_automoc CXX)

# Find the QtWidgets library
find_package(Qt5Widgets)

#_______________________________________________

# Example using qt5_wrap
qt5_wrap_cpp(
  QT_MOC_OUTFILES
  ${CMAKE_SOURCE_DIR}/include/test_q_object.h
  )
add_executable(helloworld_qt5_wrap src_noinclude/helloworld.cpp ${QT_MOC_OUTFILES})
target_link_libraries(helloworld_qt5_wrap Qt5::Widgets)

# header is in the source-tree include directory and the
# moc-generated result is part of the source files so does
# not need to be part of INCLUDE_DIRECTORIES.
target_include_directories(helloworld_qt5_wrap PRIVATE "${CMAKE_SOURCE_DIR}/include")

#_______________________________________________

# Example using automoc while adding header in separate directory to target source files

add_executable(helloworld_automoc_noinclude src_noinclude/helloworld.cpp ${CMAKE_SOURCE_DIR}/include/test_q_object.h)
# Use the Widgets module from Qt 5.
target_link_libraries(helloworld_automoc_noinclude Qt5::Widgets)

# Set automoc to ON.
set_target_properties(helloworld_automoc_noinclude
  PROPERTIES
  AUTOMOC ON
  )

# Note that the required test_q_object.h header is in the
# source-tree include directory.
# Also note that ${CMAKE_CURRENT_BUILD_DIR} is not required for g++
# and many other C++ compilers, but still best practice for AUTOMOC
# just in case there is a compiler out there that does not look in the
# source directory for the quoted form of #included headers in the
# automoc-generated source code
# ${CMAKE_CURRENT_BINARY_DIR}/<targetname>_automoc.cpp that is
# specifically added by automoc to the list of source files for the
# target.
target_include_directories(helloworld_automoc_noinclude PRIVATE
  "${CMAKE_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR}"
  )

#_______________________________________________

# Example using automoc with header with same basename in same directory, but no include
# of automoc result.

add_executable(helloworld_automoc_same_noinclude src_same_noinclude/helloworld.cpp )
# Use the Widgets module from Qt 5.
target_link_libraries(helloworld_automoc_same_noinclude Qt5::Widgets)

# Set automoc to ON.
set_target_properties(helloworld_automoc_same_noinclude
  PROPERTIES
  AUTOMOC ON
  )

# Note that the required helloworld.h header is in the
# same source directory.
# Also note that ${CMAKE_CURRENT_BUILD_DIR} is not required for g++
# and many other C++ compilers, but still best practice for AUTOMOC
# just in case there is a compiler out there that does not look in the
# source directory for the quoted form of #included headers in the
# automoc-generated source code
# ${CMAKE_CURRENT_BINARY_DIR}/<targetname>_automoc.cpp that is
# specifically added by automoc to the list of source files for the
# target.
target_include_directories(helloworld_automoc_same_noinclude PRIVATE
  "${CMAKE_SOURCE_DIR}/src_same_noinclude;${CMAKE_CURRENT_BINARY_DIR}"
  )

#_______________________________________________

# Example using automoc with header with different basename in same directory and with
# specific include of moc result that is generated by automoc.

add_executable(helloworld_automoc_same_include src_same_include/helloworld.cpp )
# Use the Widgets module from Qt 5.
target_link_libraries(helloworld_automoc_same_include Qt5::Widgets)

# Set automoc to ON.
set_target_properties(helloworld_automoc_same_include
  PROPERTIES
  AUTOMOC ON
  )

# Note that the required test_q_object.h header is in the same
# source-tree directory and the source file #includes the specific moc
# result produced by automoc so need to specify
# ${CMAKE_CURRENT_BINARY_DIR} as an include directory.
target_include_directories(helloworld_automoc_same_include PRIVATE
  "${CMAKE_SOURCE_DIR}/src_same_include;${CMAKE_CURRENT_BINARY_DIR}"
  )

#_______________________________________________

# Second (identical except for target name to demonstrate nameclash)
# example using automoc with header with different basename in same directory and with
# specific include of moc result that is generated by automoc.

add_executable(helloworld_automoc_same_include1 src_same_include/helloworld.cpp )
# Use the Widgets module from Qt 5.
target_link_libraries(helloworld_automoc_same_include1 Qt5::Widgets)

# Set automoc to ON.
set_target_properties(helloworld_automoc_same_include1
  PROPERTIES
  AUTOMOC ON
  )

# Note that the required test_q_object.h header is in the same
# source-tree directory and the source file #includes the specific moc
# result produced by automoc so need to specify
# ${CMAKE_CURRENT_BINARY_DIR} as an include directory.
target_include_directories(helloworld_automoc_same_include1 PRIVATE
  "${CMAKE_SOURCE_DIR}/src_same_include;${CMAKE_CURRENT_BINARY_DIR}"
  )

#_______________________________________________

# Third (identical except for target name to demonstrate nameclash)
# example using automoc with header with different basename in same directory and with
# specific include of moc result that is generated by automoc.  However, instead
# of using the same directory for the header and implementation file
# for this target we use a distinct src_same_include_alt directory
# that contains an identical copy of the same header and implementation
# file.

add_executable(helloworld_automoc_same_include2 src_same_include_alt/helloworld.cpp )
# Use the Widgets module from Qt 5.
target_link_libraries(helloworld_automoc_same_include2 Qt5::Widgets)

# Set automoc to ON.
set_target_properties(helloworld_automoc_same_include2
  PROPERTIES
  AUTOMOC ON
  )

# Note that the required test_q_object.h header is in the same
# source-tree directory and the source file #includes the specific moc
# result produced by automoc so need to specify
# ${CMAKE_CURRENT_BINARY_DIR} as an include directory.
target_include_directories(helloworld_automoc_same_include2 PRIVATE
  "${CMAKE_SOURCE_DIR}/src_same_include_alt;${CMAKE_CURRENT_BINARY_DIR}"
  )