-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
189 lines (152 loc) · 6.95 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
##**************************************************************************
## Project: OpenCPN PositionReport Plugin
## Author: David Tischler
##
##**************************************************************************
## Copyright (C) 2011 by David Tischler *
## [email protected] *
## *
## This program is free software: you can redistribute it and/or modify *
## it under the terms of the GNU General Public License as published by *
## the Free Software Foundation, either version 3 of the License, or *
## (at your option) any later version. *
## *
## This program is distributed in the hope that it will be useful, *
## but WITHOUT ANY WARRANTY; without even the implied warranty of *
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
## GNU General Public License for more details. *
## *
## You should have received a copy of the GNU General Public License *
## along with this program. If not, see <http://www.gnu.org/licenses/>. *
##**************************************************************************
# define minimum cmake version
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2)
# This should be 2.8.0 to have FindGTK2 module
if(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0003 OLD)
CMAKE_POLICY(SET CMP0005 OLD)
CMAKE_POLICY(SET CMP0011 OLD)
ENDif(COMMAND cmake_policy)
PROJECT(positionreport_pi)
SET(PACKAGE_NAME positionreport_pi)
SET(PLUGIN_SOURCE_DIR .)
MESSAGE (STATUS "")
MESSAGE (STATUS "*** Building ${PACKAGE_NAME} ***")
#SET(CMAKE_BUILD_TYPE Debug)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
# require proper c++
#ADD_DEFINITIONS( "-Wall -ansi -pedantic -Wno-variadic-macros" )
#TODO: Should we use -fno-stack-protector
# IF NOT DEBUGGING CFLAGS="-O2 -march=native"
if(NOT WIN32)
ADD_DEFINITIONS( "-Wall -O3 -fexceptions -fvisibility=hidden" )
if(NOT APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
ELSE(NOT APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl -undefined dynamic_lookup")
ENDif(NOT APPLE)
ENDif(NOT WIN32)
#SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
# Add some definitions to satisfy MS
if(WIN32)
ADD_DEFINITIONS(-D__MSVC__)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
ENDif(WIN32)
#SET(wxWidgets_USE_LIBS base core net xml html adv aui)
#SET(BUILD_SHARED_LIBS TRUE)
#SET( wxWidgets_USE_DEBUG OFF)
#SET( wxWidgets_USE_UNICODE ON)
#FIND_PACKAGE(wxWidgets REQUIRED)
INCLUDE(${wxWidgets_USE_FILE})
FIND_PACKAGE(Gettext REQUIRED)
# For convenience we define the sources as a variable. You can add
# header files and cpp/c files and CMake will sort them out
SET(SRC_POSITIONREPORT
src/positionreport_pi.h
src/positionreport_pi.cpp
src/positionreport_ui.h
src/icons.h
src/positionreport_ui.cpp
src/positionreportfile.h
src/positionreportfile.cpp
src/icons.cpp
../../include/cutil.h
../../src/cutil.c
../../include/georef.h
../../src/georef.c
)
ADD_LIBRARY(${PACKAGE_NAME} SHARED ${SRC_POSITIONREPORT})
if(WIN32)
SET(OPENCPN_IMPORT_LIB "../../${CMAKE_CFG_INTDIR}/${PARENT}")
TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${OPENCPN_IMPORT_LIB} )
ADD_DEPENDENCIES(${PACKAGE_NAME} ${PARENT})
ENDif(WIN32)
TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${wxWidgets_LIBRARIES} )
if(APPLE)
INSTALL(TARGETS ${PACKAGE_NAME} BUNDLE LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/OpenCPN.app/Contents/PlugIns)
ENDif(APPLE)
if(UNIX AND NOT APPLE)
INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION ${PREFIX_PLUGINS})
ENDif(UNIX AND NOT APPLE)
if(WIN32)
INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins")
ENDif(WIN32)
# find src/ -name \*.cpp -or -name \*.h -or -name \*.hpp >po/POTFILES.in
FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
if(GETTEXT_XGETTEXT_EXECUTABLE)
ADD_CUSTOM_COMMAND(
OUTPUT po/${PACKAGE_NAME}.pot.dummy
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} --force-po --package-name=${PACKAGE_NAME} --package-version="${PACKAGE_VERSION}" --output=po/${PACKAGE_NAME}.pot --keyword=_ --width=80 --files-from=${CMAKE_CURRENT_SOURCE_DIR}/po/POTFILES.in
DEPENDS po/POTFILES.in po/${PACKAGE_NAME}.pot
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "PositionReport-pot-update [${PACKAGE_NAME}]: Generated pot file."
)
ADD_CUSTOM_TARGET(PositionReport-pot-update COMMENT "PositionReport-pot-update: Done." DEPENDS po/${PACKAGE_NAME}.pot.dummy)
ENDif(GETTEXT_XGETTEXT_EXECUTABLE )
MACRO(GETTEXT_UPDATE_PO _potFile)
SET(_poFiles ${_potFile})
GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
FOREACH (_currentPoFile ${ARGN})
GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE)
GET_FILENAME_COMPONENT(_poBasename ${_absFile} NAME_WE)
ADD_CUSTOM_COMMAND(
OUTPUT ${_absFile}.dummy
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --width=80 --strict --quiet --update --backup=none --no-location -s ${_absFile} ${_absPotFile}
DEPENDS ${_absPotFile} ${_absFile}
COMMENT "PositionReport-po-update [${_poBasename}]: Updated po file."
)
SET(_poFiles ${_poFiles} ${_absFile}.dummy)
ENDFOREACH (_currentPoFile )
ADD_CUSTOM_TARGET(PositionReport-po-update COMMENT "PositionReport-po-update: Done." DEPENDS ${_poFiles})
ENDMACRO(GETTEXT_UPDATE_PO)
if(GETTEXT_MSGMERGE_EXECUTABLE)
FILE(GLOB PACKAGE_PO_FILES po/*.po)
GETTEXT_UPDATE_PO(po/${PACKAGE_NAME}.pot ${PACKAGE_PO_FILES})
ENDif(GETTEXT_MSGMERGE_EXECUTABLE)
SET(_gmoFiles)
MACRO(GETTEXT_BUILD_MO)
FOREACH (_poFile ${ARGN})
GET_FILENAME_COMPONENT(_absFile ${_poFile} ABSOLUTE)
GET_FILENAME_COMPONENT(_poBasename ${_absFile} NAME_WE)
SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_poBasename}.mo)
ADD_CUSTOM_COMMAND(
OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_absFile}
DEPENDS ${_absFile}
COMMENT "PositionReport-i18n [${_poBasename}]: Created mo file."
)
if(APPLE)
INSTALL(FILES ${_gmoFile} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/OpenCPN.app/Contents/Resources/${_poBasename}.lproj RENAME opencpn-${PACKAGE_NAME}.mo )
ELSE(APPLE)
INSTALL(FILES ${_gmoFile} DESTINATION ${PREFIX_DATA}/locale/${_poBasename}/LC_MESSAGES RENAME opencpn-${PACKAGE_NAME}.mo )
ENDif(APPLE)
SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
ENDFOREACH (_poFile )
ENDMACRO(GETTEXT_BUILD_MO)
if(GETTEXT_MSGFMT_EXECUTABLE)
FILE(GLOB PACKAGE_PO_FILES po/*.po)
GETTEXT_BUILD_MO(${PACKAGE_PO_FILES})
ADD_CUSTOM_TARGET(PositionReport-i18n COMMENT "PositionReport-i18n: Done." DEPENDS ${_gmoFiles})
#ADD_DEPENDENCIES(PositionReport-i18n ${PACKAGE_PO_FILES})
ADD_DEPENDENCIES(${PACKAGE_NAME} PositionReport-i18n)
ENDif(GETTEXT_MSGFMT_EXECUTABLE)