-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (114 loc) · 4.76 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
###############
# (C) 2014 by Matteo Pasotti <[email protected]>
# License: GPLv3
###############
SET( VERSION_MAJOR "1")
SET( VERSION_MINOR "3" )
SET( VERSION_PATCH "0" )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${GIT_SHA1_VERSION}" )
cmake_minimum_required(VERSION 2.8.11)
project(getaircrafts)
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
message( STATUS ${CMAKE_MODULE_PATH} )
# 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)
# 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)
find_package( ZLIB REQUIRED )
find_package( LibZip REQUIRED )
if( LIBZIP_FOUND )
# include zip.h
include_directories( ${LIBZIP_INCLUDE_DIR} )
# include zipconf.h
include_directories( ${LIBZIP_CONF_INCLUDE_DIR} )
else( LIBZIP_FOUND )
message( FATAL_ERROR "LibZip not found" )
endif( LIBZIP_FOUND )
# 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)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=gnu++0x")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message( STATUS "Building on MacOSX" )
set( MACOSX ON )
else()
unset( MACOSX )
endif()
add_definitions(-DVERSION=${VERSION})
file(GLOB YI_SOURCES *.cpp)
file(GLOB YI_HEADERS *.h)
file(GLOB YI_RESOURCES *.qrc)
file(GLOB YI_FORMS *.ui)
file(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/languages/*.ts)
file(GLOB CSS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/css/*.css)
file(GLOB JS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/js/*.js)
QT5_WRAP_UI(UIS_HDRS ${YI_FORMS})
qt5_add_resources(RC_ADDED ${YI_RESOURCES})
qt5_add_translation( QM_FILES ${TS_FILES} )
add_executable(getaircrafts ${YI_SOURCES} ${UIS_HDRS} ${RC_ADDED} ${QM_FILES})
qt5_use_modules( getaircrafts Widgets LinguistTools Network WebKitWidgets)
target_link_libraries( getaircrafts ${LIBZIP_LIBRARY} )
if(UNIX)
# NOTE: using qt5_use_modules target_link_libraries can refer just to the other libraries
# target_link_libraries(getaircrafts 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(getaircrafts ${YALIB_LIBRARY} z)
else(YALIB_LIBRARY)
message( STATUS "YaLib Not Found")
endif(YALIB_LIBRARY)
else(MACOSX)
target_link_libraries(getaircrafts yalib z)
endif()
elseif(WIN32)
if(YALIB_LIBRARIES)
target_link_libraries(getaircrafts ${YALIB_LIBRARIES} z)
else(YALIB_LIBRARIES)
message( FATAL_ERROR "YaLib Not Found")
endif(YALIB_LIBRARIES)
endif()
# setup version and soversion
set_target_properties( getaircrafts PROPERTIES VERSION ${VERSION})
install( TARGETS getaircrafts DESTINATION bin )
install( FILES ${QM_FILES} DESTINATION share/getaircrafts/languages )
install( FILES ${CSS_FILES} DESTINATION share/getaircrafts/css )
install( FILES ${JS_FILES} DESTINATION share/getaircrafts/js )