-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
418 lines (314 loc) · 13.2 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
PROJECT(ponyprog)
# Configure CMake ...
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
# CMAKE_POLICY(SET CMP0003 OLD)
# CMAKE_POLICY(SET CMP0015 OLD)
IF(WIN32)
CMAKE_POLICY(SET CMP0020 NEW)
ENDIF()
# set the Qt version to 4 or 5
OPTION (USE_QT5 "Using of Qt5 version for compiling" ON)
IF(${USE_QT5})
SET(USE_QT_VERSION 5)
ELSE(${USE_QT5})
SET(USE_QT_VERSION 4)
ENDIF(${USE_QT5})
# # SET(FILES_TO_TRANSLATE)
IF(WIN32)
IF(MSVC)
SET (CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}:${QTDIR}\\msvc2015\\")
ENDIF()
IF(MinGW)
SET (CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}:${QTDIR}\\mingw53_32\\")
ENDIF()
ENDIF()
#disable -rdynamic
# SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
# SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
# FILE (GLOB TRANSLATIONS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts)
# OPTION (UPDATE_TRANSLATIONS "Update source translation ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts" OFF)
MESSAGE(STATUS "Qt version for compiling: " ${USE_QT_VERSION})
OPTION (USE_DEBUGGER "Include in binary file debug information" OFF)
OPTION (USE_PROFILER "Include in binary file profiling information" OFF)
IF(${USE_DEBUGGER})
SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
ELSE()
SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
ENDIF()
MESSAGE(STATUS "CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFileCXX)
INCLUDE(TestCXXAcceptsFlag)
INCLUDE(CheckCXXCompilerFlag)
SET(TARGET_NAME ponyprog )
SET(CMAKE_HELPERS_BINARY_DIR ${PROJECT_SOURCE_DIR}/cmake)
SET(CMAKE_HELPERS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/cmake)
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
INCLUDE(OutOfSourceBuild) # Disallow in-source builds
INCLUDE(GenerateDEF) # Convenience macro for linking Win32 DLLs using MSVC
INCLUDE(Dependencies)
SET(CURRENT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
INCLUDE(FindLibUSB-1.0)
IF(NOT ${LIBUSB_VERSION} LESS "1.0.16")
MESSAGE(STATUS "LibUSB version ${LIBUSB_VERSION}")
ELSE()
MESSAGE(FATAL_ERROR "-- LibUSB version ${LIBUSB_VERSION} TOO OLD! Please Install this library newer as 1.0.16")
ENDIF()
# Set the PonyProg version
# this for generating of version file from HISTORY file
# the idea is to descript all changes in this file, last changes with version are in the top of file
FILE(READ "HISTORY" DESCRIBE_STRING)
STRING(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" APP_VERSION "${DESCRIBE_STRING}" )
MESSAGE(STATUS "Version info: ${APP_VERSION}")
SET(VERSION ${APP_VERSION})
#
# SET(APP_VERSION "3.0.0")
SET(APP_AUTHOR "Claudio Lanconelli")
SET(APP_EMAIL "[email protected]")
SET(APP_NAME "PonyProg")
SET(AUTHORWEB "http://www.LancOS.com")
SET(APP_YEAR "2022")
SET(PORTERGQT "Eduard Kalinowski")
SET(PORTERMAIL "[email protected]")
IF(WIN32)
EXECUTE_PROCESS (
COMMAND "cmd" " /c date /t"
OUTPUT_VARIABLE APP_BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE()
EXECUTE_PROCESS (
COMMAND date +"%d-%m-%Y"
OUTPUT_VARIABLE APP_BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "\"" "" APP_BUILD_DATE ${APP_BUILD_DATE})
ENDIF()
MESSAGE(STATUS "Version build date: ${APP_BUILD_DATE}")
#
SET(PONYPROG_PACKAGE ponyprog)
SET(PONYPROG_HOST ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR})
#SET(PONYPROG_COPYRIGHT "Copyright (c) 1997-${APP_YEAR} ${APP_AUTHOR}, All Rights Reserved.")
SET(PONYPROG_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
# Setup high-level build options
# IF(MSVC)
# SET(PONYPROG_ENABLE_SYMBOL_VISIBILITY_DEFAULT ON)
# ELSE(MSVC)
# SET(PONYPROG_ENABLE_SYMBOL_VISIBILITY_DEFAULT OFF)
# ENDIF(MSVC)
IF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fno-exceptions")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions")
ENDIF()
# options for gprof
IF(${USE_PROFILER})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
# after execution of program: gprof ./build/ponyprog
# and get the information from gprof.txt file
MESSAGE(STATUS "Compile with profiling information")
ELSE()
MESSAGE(STATUS "Compile without profiling information")
ENDIF()
IF(${USE_QT_VERSION} MATCHES "4")
SET(HAVE_QT_PRINTSUPPORT true)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
IF(NOT QT4_FOUND)
MESSAGE(FATAL_ERROR "Qt4 could not be found. "
"If it's INSTALLed in a non-standard location, specify the path to qmake in QT_QMAKE_EXECUTABLE. "
"You can do it in interactive mode (ccmake instead of cmake) or using -DVAR=VAL syntax.")
ENDIF()
ELSE()
FIND_PACKAGE(Qt5 COMPONENTS Core PrintSupport Gui Widgets Multimedia REQUIRED QUIET)
IF(NOT Qt5Widgets_FOUND)
MESSAGE(FATAL_ERROR "Qt5 could not be found. "
"If it's INSTALLed in a non-standard location, specify the path to qmake in QT_QMAKE_EXECUTABLE. "
"You can do it in interactive mode (ccmake instead of cmake) or using -DVAR=VAL syntax.")
ENDIF(NOT Qt5Widgets_FOUND)
IF(NOT Qt5PrintSupport_FOUND)
MESSAGE(FATAL_ERROR "Qt5 PrintSupport development files are not found. "
"Qt5PrintSupport development package is to install.")
ENDIF(NOT Qt5PrintSupport_FOUND)
IF(NOT Qt5Multimedia_FOUND)
MESSAGE(FATAL_ERROR "Qt5 Multimedia development files are not found. "
"Qt5Multimedia development package is to install.")
ENDIF(NOT Qt5Multimedia_FOUND)
ENDIF()
IF (NOT WIN32)
FIND_PACKAGE ( LibFTDI1 NO_MODULE REQUIRED )
IF(NOT LibFTDI1_FOUND)
MESSAGE(FATAL_ERROR "LibFTDI1 files are not found. "
"LibFTDI1 and LibFTDIPP1 development packages are to install.")
ENDIF(NOT LibFTDI1_FOUND)
INCLUDE ( ${LIBFTDI_USE_FILE} )
ELSE()
SET ( BOOST_DIR "C:/Libraries/boost_1_77_0" )
SET ( LIBFTDI_ROOT_DIR "C:/libftdi1-1.5_devkit_x86_x64_19July2020" )
SET ( LIBFTDI_LIBRARY "ftdi1" )
SET ( LIBFTDIPP_LIBRARY "ftdipp1" )
SET ( LIBFTDI_VERSION_STRING "1.5" )
SET ( LIBFTDI_VERSION_MAJOR "1" )
SET ( LIBFTDI_VERSION_MINOR "5" )
INCLUDE_DIRECTORIES("${BOOST_DIR}")
INCLUDE_DIRECTORIES("${LIBFTDI_ROOT_DIR}/include")
INCLUDE_DIRECTORIES("${LIBFTDI_ROOT_DIR}/include/libftdi")
LINK_DIRECTORIES("${LIBFTDI_ROOT_DIR}/lib32")
ENDIF()
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
# for this feature install debhelper or
SET(PONYPROG_CPACK_PACKAGE_SHLIBDEPS ON)
IF(${USE_QT_VERSION} MATCHES "4")
INCLUDE_DIRECTORIES(${QT_INCLUDES})
MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES}")
ELSE()
INCLUDE_DIRECTORIES(${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS})
#MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${Qt5Multimedia_EXECUTABLE_COMPILE_FLAGS} ${Qt5PrintSupport_EXECUTABLE_COMPILE_FLAGS}")
ENDIF()
configure_file (
"${PROJECT_SOURCE_DIR}/SrcPony/version-cmake.h.in"
"${PROJECT_SOURCE_DIR}/SrcPony/version.h" )
SET ( OBJECTS_DIR temp )
SET ( MOC_DIR temp )
SET ( UI_HEADERS_DIR temp )
SET ( UI_SOURCES_DIR temp )
ADD_SUBDIRECTORY(qhexedit2/src)
ADD_SUBDIRECTORY(SrcPony)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/qhexedit2/src/ ${CMAKE_CURRENT_SOURCE_DIR}/SrcPony/ )
IF(${USE_QT_VERSION} MATCHES "4")
# QT4_ADD_TRANSLATION(APP_TRANSLATIONS ${TRANSLATION})
QT4_WRAP_CPP(APP_HEADERS_MOC ${HEX_HEADERS} ${PONY_HEADERS} )
QT4_WRAP_UI(APP_FORMS_HEADERS ${PONY_FORMS} )
QT4_ADD_RESOURCES(APP_RESOURCES_RCC ${APP_RESOURCES})
ELSE()
# QT5_ADD_TRANSLATION(APP_TRANSLATIONS ${TRANSLATION})
QT5_WRAP_CPP(APP_HEADERS_MOC ${HEX_HEADERS} ${PONY_HEADERS} )
QT5_WRAP_UI(APP_FORMS_HEADERS ${PONY_FORMS} )
QT5_ADD_RESOURCES(APP_RESOURCES_RCC ${APP_RESOURCES})
ENDIF()
MESSAGE(STATUS "PONY_RESOURCES ${APP_RESOURCES_RCC}")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
SOURCE_GROUP( "Generated Files" FILES
${MOC_FILES_CPP}
${APP_FORMS_HEADERS}
${APP_RESOURCES_RCC}
)
message(STATUS "Include dirs ")
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
IF(NOT ${USE_DEBUGGER})
ADD_DEFINITIONS(${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
ELSE()
ADD_DEFINITIONS(${QT_DEFINITIONS} -DQT_DEBUG)
ENDIF()
IF(${USE_QT_VERSION} MATCHES "4")
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS} -DNO_QT3SUPPORT -DDISABLE_QT3SUPPORT -DQT_PROJECT)
ELSE()
ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS} ${Qt5Multimedia_DEFINITIONS} -DQT_PROJECT)
ENDIF()
IF(WIN32)
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
ENDIF()
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME}
${APP_SOURCES}
${HEX_SOURCES}
${PONY_SOURCES}
${APP_HEADERS_MOC}
${APP_FORMS_HEADERS}
# ${APP_TRANSLATIONS}
${APP_RESOURCES_RCC}
)
IF(${USE_QT_VERSION} MATCHES "4")
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES})
ELSE()
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5PrintSupport_LIBRARIES})
#MESSAGE(STATUS "QT LIBRARIES: ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${Qt5Core_LIBRARIES}")
ENDIF()
#TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${LIBFTDI_LIBRARIES} )
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${LIBFTDIPP_LIBRARY} ${LIBFTDI_LIBRARY} ${LIBUSB_LIBRARIES})
ADD_CUSTOM_TARGET (tags
COMMAND ctags -R -f tags ${CMAKE_SOURCE_DIR}/SrcPony
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
#message(STATUS "Link Libraries ")
#get_target_property(OUTP ${CMAKE_PROJECT_NAME} LINK_LIBRARIES)
#message(STATUS ${OUTP})
# Setup module enabled/disabled defaults ...
IF(MSVC)
SET(PONYPROG_BUILD_GLX_MODULE_DEFAULT ON)
SET(PONYPROG_BUILD_OSX_MODULE_DEFAULT OFF)
SET(PONYPROG_BUILD_VIRTUAL_OFFSCREEN_MODULE_DEFAULT OFF)
ENDIF(MSVC)
IF(UNIX AND NOT APPLE)
SET(PONYPROG_BUILD_GLX_MODULE_DEFAULT ON)
SET(PONYPROG_BUILD_OSX_MODULE_DEFAULT OFF)
SET(PONYPROG_BUILD_VIRTUAL_OFFSCREEN_MODULE_DEFAULT OFF)
ENDIF(UNIX AND NOT APPLE)
IF(APPLE)
SET(PONYPROG_BUILD_GLX_MODULE_DEFAULT ON)
SET(PONYPROG_BUILD_OSX_MODULE_DEFAULT ON)
SET(PONYPROG_BUILD_VIRTUAL_OFFSCREEN_MODULE_DEFAULT OFF)
ENDIF(APPLE)
OPTION(PONYPROG_ENABLE_SYMBOL_VISIBILITY "Minimize the number of symbols exported from shared libraries." ${PONYPROG_ENABLE_SYMBOL_VISIBILITY_DEFAULT})
MARK_AS_ADVANCED(PONYPROG_ENABLE_SYMBOL_VISIBILITY)
# OPTION(PONYPROG_ENABLE_TESTING "Build the Ponyprog regression test suite." OFF)
# SET(BUILD_TESTING ${PONYPROG_ENABLE_TESTING} CACHE INTERNAL "" FORCE)
# INCLUDE(CTest)
# MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
# IF(PONYPROG_ENABLE_TESTING)
# CMAKE_MINIMUM_REQUIRED(VERSION 2.6.1 FATAL_ERROR)
# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake @ONLY)
# ENDIF(PONYPROG_ENABLE_TESTING)
# Capture system configuration
INCLUDE(SystemConfiguration)
# MSVC configuration
IF(MSVC)
IF(NOT MSVC)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-runtime-pseudo-reloc" CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-runtime-pseudo-reloc -Wl,--export-all-symbols" CACHE STRING "" FORCE)
ENDIF(NOT MSVC)
ENDIF(MSVC)
# Setup output directories ...
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PONYPROG_BINARY_DIR}/bin)
IF(MSVC)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PONYPROG_BINARY_DIR}/bin)
ELSE(MSVC)
SET(PONYPROG_LIBDIR lib) # Allows us to handle 64-bit libs if/when it becomes necessary.
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PONYPROG_BINARY_DIR}/${PONYPROG_LIBDIR})
ENDIF(MSVC)
# Setup a macro for compiling resources ...
MACRO(PONYPROG_COMPILE_RESOURCE OUTPUT INPUT RESOURCE_PATH)
SET(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
SET(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${INPUT}.cpp")
GET_FILENAME_COMPONENT(OUTPUT_PATH ${OUTPUT_FILE} PATH)
GET_TARGET_PROPERTY(PONYPROG_RESOURCE_COMPILER ponyprog-resource-compiler LOCATION)
ADD_CUSTOM_COMMAND(
DEPENDS ponyprog-resource-compiler
DEPENDS ${INPUT_FILE}
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_PATH}
COMMAND ${PONYPROG_RESOURCE_COMPILER} --input ${INPUT_FILE} --path \"<path>${RESOURCE_PATH}</path>\" --output ${OUTPUT_FILE}
OUTPUT ${OUTPUT_FILE}
COMMENT "Compiling resource ${INPUT_FILE}"
)
LIST(APPEND ${OUTPUT} ${OUTPUT_FILE})
ENDMACRO(PONYPROG_COMPILE_RESOURCE)
# Setup subdirectories ...
PONYPROG_CONDITIONAL_BUILD(MSVC gendef)
#
OPTION(PONYPROG_ENABLE_DISTRIBUTION "Enable distribution targets." ON)
PONYPROG_CONDITIONAL_BUILD(PONYPROG_ENABLE_DISTRIBUTION distribution)
# Hide some cruft ...
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
MARK_AS_ADVANCED(CMAKE_EXECUTABLE_FORMAT)
MARK_AS_ADVANCED(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES)
MARK_AS_ADVANCED(CMAKE_OSX_DEPLOYMENT_TARGET)
MARK_AS_ADVANCED(CMAKE_OSX_SYSROOT)
MARK_AS_ADVANCED(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
MARK_AS_ADVANCED(CMAKE_USE_CHRPATH)