-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
151 lines (125 loc) · 5.11 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
###############
# (C) 2014-2020 by Matteo Pasotti <[email protected]>
# License: GPLv3
###############
SET( VERSION_MAJOR "1")
SET( VERSION_MINOR "0" )
SET( VERSION_PATCH "6" )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${GIT_SHA1_VERSION}" )
cmake_minimum_required(VERSION 2.8.11)
project(yaflight)
# Debug, RelWithDebInfo, Release
# set(CMAKE_BUILD_TYPE Debug)
# Find includes in corresponding build directories
# usefull for MOC
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
if(WIN32)
# W/A for QTBUG-34940
set(CMAKE_LIBRARY_PATH C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.18362.0\\um\\x86)
endif(WIN32)
# Find the QtCore library - Not Really Needed as Qt5Widgets already requires it!
find_package(Qt5Core REQUIRED)
# Find the QtWidgets library
find_package(Qt5Widgets REQUIRED)
# Find the Qt5Network library
find_package(Qt5Network REQUIRED)
# Find the Qt5WebKitWidgets library
find_package(Qt5WebKitWidgets REQUIRED)
# Find the Qt5LinguistTools library (libqt5help-devel)
find_package(Qt5LinguistTools REQUIRED)
# TODO: check if qttools5 is installed (lrelease)
find_package( ZLIB REQUIRED)
# The Qt5Widgets_INCLUDES also includes the include directories for
# dependencies QtCore and QtGui
# NOTE: using qt5_use_modules makes include_directories droppable
# include_directories(${Qt5Widgets_INCLUDE_DIRS})
# include_directories(${Qt5Network_INCLUDE_DIRS})
# include_directories(${Qt5WebKitWidgets_INCLUDE_DIRS})
# DETECT YALIB ON WIN32
if(WIN32)
find_path(YALIB_INCLUDE_DIR NAMES yalib.h
HINTS ${PC_YALIB_INCLUDEDIR} ${PC_YALIB_INCLUDE_DIRS}
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/../yalib/src/ )
find_library(YALIB_LIBRARY NAMES libyalib yalib
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/../yalib-build/src/
HINTS ${PC_YALIB_LIBDIR} ${PC_YALIB_LIBRARY_DIRS} )
set(YALIB_LIBRARIES ${YALIB_LIBRARY} )
set(YALIB_INCLUDE_DIRS ${YALIB_INCLUDE_DIR} )
message(STATUS "Found YaLib library at: ${YALIB_LIBRARIES}")
include_directories( ${YALIB_INCLUDE_DIRS} )
message( STATUS "Include YaLib: ${YALIB_INCLUDE_DIRS}" )
endif(WIN32)
if(NOT DATA_DIR)
set( DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}" )
endif(NOT DATA_DIR)
if(NOT TRANSLATIONS_DIR)
set( TRANSLATIONS_DIR "${DATA_DIR}/languages" )
endif(NOT TRANSLATIONS_DIR)
if(NOT THEMES_DIR)
set( THEMES_DIR "${DATA_DIR}/themes" )
endif(NOT THEMES_DIR)
message( STATUS "DATA_DIR: ${DATA_DIR}" )
message( STATUS "TRANSLATIONS_DIR: ${TRANSLATIONS_DIR}" )
message( STATUS "THEMES_DIR: ${THEMES_DIR}" )
add_definitions(-DMAX_VERSION=${VERSION_MAJOR})
add_definitions(-DMIN_VERSION=${VERSION_MINOR})
add_definitions(-DPATCH_VERSION=${VERSION_PATCH})
add_definitions(-DVERSION="${VERSION}")
add_definitions(-DDATA_DIR="${DATA_DIR}")
add_definitions(-DTRANSDIR="${TRANSLATIONS_DIR}")
add_definitions(-DTHEMES_DIR="${THEMES_DIR}")
add_definitions(-DSTRVERSION="${VERSION}")
# if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=gnu++0x")
# endif()
file(GLOB YF_SOURCES *.cpp)
file(GLOB YF_HEADERS *.h)
file(GLOB YF_RESOURCES *.qrc)
file(GLOB YF_FORMS *.ui)
file(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/languages/*.ts)
file(GLOB YF_THEMES ${CMAKE_CURRENT_SOURCE_DIR}/themes/*.qss)
QT5_WRAP_UI(UIS_HDRS ${YF_FORMS})
qt5_add_resources(RC_ADDED ${YF_RESOURCES})
qt5_add_translation( QM_FILES ${TS_FILES} )
add_executable(yaflight ${YF_SOURCES} ${UIS_HDRS} ${RC_ADDED} ${QM_FILES})
# qt5_use_modules( yaflight Widgets LinguistTools Network WebKitWidgets)
target_link_libraries( yaflight Qt5::Widgets Qt5::Network Qt5::WebKitWidgets)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message( STATUS "Building on MacOSX" )
set( MACOSX ON )
else()
unset( MACOSX )
endif()
if(UNIX)
# NOTE: using qt5_use_modules target_link_libraries can refer just to the other libraries
# target_link_libraries(yaflight yalib Qt5::Widgets Qt5::Network Qt5::WebKitWidgets z)
if(MACOSX)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../yalib-build/src")
message( STATUS "Including ${CMAKE_CURRENT_SOURCE_DIR}/../yalib-build/src" )
#Determine Yalib library
FIND_LIBRARY(YALIB_LIBRARY NAMES yalib
PATH_SUFFIXES lib
PATHS $CMAKE_CURRENT_SOURCE_DIR/../yalib-build/src # Extension to localize MinGW root
DOC "The file that corresponds to the base il library."
)
if(YALIB_LIBRARY)
message(STATUS "Found YaLib library at: ${YALIB_LIBRARY}")
target_link_libraries(yaflight ${YALIB_LIBRARY} z)
else(YALIB_LIBRARY)
message( STATUS "YaLib Not Found")
endif(YALIB_LIBRARY)
else(MACOSX)
target_link_libraries(yaflight yalib z)
endif()
elseif(WIN32)
if(YALIB_LIBRARIES)
target_link_libraries(yaflight ${YALIB_LIBRARIES} z)
else(YALIB_LIBRARIES)
message( FATAL_ERROR "YaLib Not Found")
endif(YALIB_LIBRARIES)
endif()
install( TARGETS yaflight DESTINATION bin )
install( FILES ${QM_FILES} DESTINATION ${TRANSLATIONS_DIR} )
install( FILES ${YF_THEMES} DESTINATION ${THEMES_DIR} )