Skip to content

Commit 658e2fe

Browse files
committed
Merge branch 'jongough-cmake_changes' (PR #50)
2 parents 37025a5 + 1516c00 commit 658e2fe

File tree

9 files changed

+551
-273
lines changed

9 files changed

+551
-273
lines changed

CMakeLists.txt

Lines changed: 234 additions & 169 deletions
Large diffs are not rendered by default.

buildosx/InstallOSX/squiddio_pi.pkgproj.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@
14491449
</dict>
14501450
</array>
14511451
<key>NAME</key>
1452-
<string>${VERBOSE_NAME}-Plugin_${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}</string>
1452+
<string>${VERBOSE_NAME}-Plugin_${PACKAGE_VERSION}-${OCPN_MIN_VERSION}-${OCPN_API_VERSION_MAJOR}.${OCPN_API_VERSION_MINOR}</string>
14531453
<key>REFERENCE_FOLDER_PATH</key>
14541454
<string>.</string>
14551455
</dict>

cmake/PluginConfigure.cmake

Lines changed: 212 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
SET(PLUGIN_SOURCE_DIR .)
88

9-
# This should be 2.8.0 to have FindGTK2 module
10-
119
MESSAGE (STATUS "*** Staging to build ${PACKAGE_NAME} ***")
1210

1311
# Do the version.h & wxWTranslateCatalog configuration into the build output directory,
@@ -18,13 +16,10 @@ FILE(REMOVE ${PROJECT_SOURCE_DIR}/include/wxWTranslateCatalog.h)
1816
IF(NOT SKIP_VERSION_CONFIG)
1917
SET(BUILD_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
2018
configure_file(cmake/version.h.in ${BUILD_INCLUDE_PATH}/include/version.h)
21-
#configure_file(cmake/wxWTranslateCatalog.h.in ${BUILD_INCLUDE_PATH}/include/wxWTranslateCatalog.h)
19+
configure_file(cmake/wxWTranslateCatalog.h.in ${BUILD_INCLUDE_PATH}/include/wxWTranslateCatalog.h)
2220
INCLUDE_DIRECTORIES(${BUILD_INCLUDE_PATH}/include)
2321
ENDIF(NOT SKIP_VERSION_CONFIG)
2422

25-
SET(PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
26-
27-
#SET(CMAKE_BUILD_TYPE Debug)
2823
SET(CMAKE_VERBOSE_MAKEFILE ON)
2924

3025
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src)
@@ -35,77 +30,236 @@ IF(CMAKE_BUILD_TYPE STREQUAL Debug)
3530
MESSAGE (STATUS "DEBUG available")
3631
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
3732

38-
# IF NOT DEBUGGING CFLAGS="-O2 -march=native"
39-
IF(NOT MSVC)
40-
IF(PROFILING)
41-
ADD_DEFINITIONS( "-Wall -g -fprofile-arcs -ftest-coverage -fexceptions" )
42-
ELSE(PROFILING)
43-
# ADD_DEFINITIONS( "-Wall -g -fexceptions" )
44-
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
45-
ADD_DEFINITIONS( " -O0")
46-
ELSE(CMAKE_BUILD_TYPE MATCHES "Debug")
47-
ADD_DEFINITIONS( " -O2")
48-
ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
49-
50-
ADD_DEFINITIONS( "-Wall -Wno-unused-result -g -fexceptions -fPIC" )
51-
ENDIF(PROFILING)
52-
53-
IF(NOT APPLE)
54-
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
55-
ELSE(NOT APPLE)
56-
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl -undefined dynamic_lookup")
57-
ENDIF(NOT APPLE)
58-
59-
ENDIF(NOT MSVC)
33+
IF(NOT WIN32 AND NOT APPLE )
34+
ADD_DEFINITIONS( "-Wall -Wno-unused -fexceptions -rdynamic -fvisibility=hidden" )
35+
ADD_DEFINITIONS( " -fno-strict-aliasing")
36+
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
37+
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
38+
ADD_DEFINITIONS(" -O0 -g")
39+
MESSAGE(STATUS "Optimisation: -O0 -g")
40+
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Release")
41+
ADD_DEFINITIONS(" -O2 -march=native")
42+
MESSAGE(STATUS "Optimisation: -O2 -march=native")
43+
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
44+
ADD_DEFINITIONS(" -O2 -march=native -g")
45+
MESSAGE(STATUS "Optimisation: -O2 -march=native -g")
46+
ELSE(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
47+
ADD_DEFINITIONS(" -O2")
48+
MESSAGE(STATUS "Optimisation: -O2")
49+
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
50+
51+
52+
ADD_DEFINITIONS( " -DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\"")
53+
# profiling with gprof
54+
# ADD_DEFINITIONS( -pg )
55+
# SET(CMAKE_EXE_LINKER_FLAGS -pg)
56+
# profiling with gcov
57+
# ADD_DEFINITIONS( "-fprofile-arcs -ftest-coverage" )
58+
# SET(EXTRA_LIBS ${EXTRA_LIBS} "gcov")
59+
ENDIF(NOT WIN32 AND NOT APPLE)
60+
61+
IF(MINGW)
62+
ADD_DEFINITIONS( "-Wall -Wno-unused -Wno-cpp -fexceptions" )
63+
ADD_DEFINITIONS( " -g -fno-strict-aliasing")
64+
ENDIF(MINGW)
65+
66+
IF( APPLE )
67+
ADD_DEFINITIONS( "-Wall -Wno-unused -fexceptions -Wno-overloaded-virtual" )
68+
ADD_DEFINITIONS( " -g -fno-strict-aliasing")
69+
ADD_DEFINITIONS( " -Wno-deprecated -Wno-deprecated-declarations -Wno-unknown-pragmas" )
70+
ADD_DEFINITIONS( " -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_" )
71+
ENDIF(APPLE)
6072

6173
# Add some definitions to satisfy MS
6274
IF(MSVC)
63-
ADD_DEFINITIONS(-D__MSVC__)
64-
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
75+
ADD_DEFINITIONS(-D__MSVC__)
76+
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
77+
ADD_DEFINITIONS(-D HAVE_SNPRINTF)
78+
MESSAGE(STATUS "Set SNPRINTF")
79+
ELSE(MSVC)
80+
IF(NOT APPLE)
81+
SET( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
82+
ELSE(NOT APPLE)
83+
SET( CMAKE_SHARED_LINKER_FLAGS "-Wl -undefined dynamic_lookup")
84+
ENDIF(NOT APPLE)
6585
ENDIF(MSVC)
6686

6787
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
68-
SET(BUILD_SHARED_LIBS "ON")
88+
SET(BUILD_SHARED_LIBS TRUE)
89+
90+
# Allow multiprocess compile
91+
IF(MSVC)
92+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
93+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
94+
ENDIF(MSVC)
95+
96+
IF(WIN32)
97+
IF(MSVC)
98+
SET(CMAKE_C_FLAGS_DEBUG "/MP /MDd /Ob0 /Od /D_DEBUG /Zi /RTC1" )
99+
SET(CMAKE_C_FLAGS_MINSIZEREL "/MP /MD /O1 /Ob1 /D NDEBUG")
100+
SET(CMAKE_C_FLAGS_RELEASE "/MP /MD /O2 /Ob2 /D NDEBUG /Zi")
101+
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/MP /MD /O2 /Ob1 /D NDEBUG /Zi")
102+
SET(CMAKE_CXX_FLAGS_DEBUG "/MP /MDd /Ob0 /Od /D_DEBUG /Zi /RTC1 /EHa")
103+
SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MP /MD /O1 /Ob1 /D NDEBUG /EHa")
104+
SET(CMAKE_CXX_FLAGS_RELEASE "/MP /MD /O2 /Ob2 /D NDEBUG /Zi /EHa")
105+
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MP /MD /O2 /Ob1 /D NDEBUG /Zi /EHa" )
106+
SET(CMAKE_EXE_LINKER_FLAGS /DEBUG)
107+
ENDIF(MSVC)
108+
ENDIF(WIN32)
69109

110+
SET(wxWidgets_USE_LIBS base core net xml html adv aui)
111+
112+
OPTION (USE_GL "Enable OpenGL support" ON)
113+
114+
# Search for opengles, short of running a program to test the speed
115+
# of acceleration, I simply use gles on "native linux" arm systems
116+
IF (ARCH MATCHES "arm*" AND (NOT QT_ANDROID) )
117+
find_path(OPENGLESv1_INCLUDE_DIR GLES/gl.h )
118+
IF (OPENGLESv1_INCLUDE_DIR)
119+
MESSAGE (STATUS "Found OpenGLESv1")
120+
ADD_DEFINITIONS(-DocpnUSE_GLES)
121+
ADD_DEFINITIONS(-DocpnUSE_GL)
122+
123+
SET(OPENGLES_FOUND "YES")
124+
SET(OPENGL_FOUND "YES")
125+
126+
SET(wxWidgets_USE_LIBS ${wxWidgets_USE_LIBS} gl )
127+
add_subdirectory(src/glshim)
128+
129+
SET(OPENGL_LIBRARIES "GL_static" "EGL" "X11" "drm" )
130+
ENDIF()
131+
ENDIF()
132+
133+
# Building for QT_ANDROID involves a cross-building environment,
134+
# So the include directories, flags, etc must be stated explicitly
135+
# without trying to locate them on the host build system.
136+
IF(QT_ANDROID)
137+
MESSAGE (STATUS "Using GLESv1 for Android")
138+
ADD_DEFINITIONS(-DocpnUSE_GLES)
139+
ADD_DEFINITIONS(-DocpnUSE_GL)
140+
ADD_DEFINITIONS(-DARMHF)
141+
142+
SET(OPENGLES_FOUND "YES")
143+
SET(OPENGL_FOUND "YES")
144+
145+
SET(wxWidgets_USE_LIBS ${wxWidgets_USE_LIBS} gl )
146+
add_subdirectory(src/glshim)
147+
ENDIF(QT_ANDROID)
148+
149+
IF ((NOT OPENGLES_FOUND) AND (NOT QT_ANDROID))
150+
151+
IF(USE_GL)
152+
FIND_PACKAGE(OpenGL)
153+
ELSE(USE_GL)
154+
MESSAGE (STATUS "OpenGL disabled by option..." )
155+
ENDIF(USE_GL)
156+
157+
IF(OPENGL_FOUND)
158+
159+
SET(wxWidgets_USE_LIBS ${wxWidgets_USE_LIBS} gl)
160+
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
161+
162+
MESSAGE (STATUS "Found OpenGL..." )
163+
MESSAGE (STATUS " Lib: " ${OPENGL_LIBRARIES})
164+
MESSAGE (STATUS " Include: " ${OPENGL_INCLUDE_DIR})
165+
ADD_DEFINITIONS(-DocpnUSE_GL)
166+
167+
# We need to remove GLU from the OPENGL_LIBRARIES list
168+
FOREACH (_currentLibFile ${OPENGL_LIBRARIES})
169+
SET(UCNAME ${_currentLibFile})
170+
string(TOUPPER ${UCNAME} UCNAME)
171+
IF(NOT ${UCNAME} MATCHES "(.*)GLU(.*)")
172+
SET( REVISED_OPENGL_LIBRARIES ${_currentLibFile} ${REVISED_OPENGL_LIBRARIES})
173+
ENDIF()
174+
ENDFOREACH (_currentLibFile )
175+
176+
SET( OPENGL_LIBRARIES ${REVISED_OPENGL_LIBRARIES})
177+
MESSAGE (STATUS " Revised GL Lib: " ${OPENGL_LIBRARIES})
178+
179+
ELSE(OPENGL_FOUND)
180+
MESSAGE (STATUS "OpenGL not found..." )
181+
ENDIF(OPENGL_FOUND)
182+
ENDIF()
183+
184+
IF(USE_LOCAL_GLU)
185+
MESSAGE (STATUS " Adding local GLU" )
186+
add_subdirectory(ocpnsrc/glu)
187+
SET( OPENGL_LIBRARIES "GLU_static" ${OPENGL_LIBRARIES})
188+
MESSAGE (STATUS " Revised GL Lib (with local): " ${OPENGL_LIBRARIES})
189+
ENDIF(USE_LOCAL_GLU)
70190

71-
# QT_ANDROID is a cross-build, so the native FIND_PACKAGE(wxWidgets...) and wxWidgets_USE_FILE is not useful.
72191
IF(NOT QT_ANDROID)
73-
IF(NOT DEFINED wxWidgets_USE_FILE)
74-
SET(wxWidgets_FIND_COMPONENTS base core net xml html adv aui)
75-
SET(BUILD_SHARED_LIBS TRUE)
76-
set (WXWIDGETS_FORCE_VERSION CACHE VERSION "Force usage of a specific wxWidgets version.")
192+
# Find wxWidgets here, and the setting get inherited by all plugins.
193+
# These options can be used to set the linux widgets build type
194+
SET( wxWidgets_USE_DEBUG OFF)
195+
SET( wxWidgets_USE_UNICODE ON)
196+
SET( wxWidgets_USE_UNIVERSAL OFF)
197+
SET( wxWidgets_USE_STATIC OFF)
198+
199+
set (WXWIDGETS_FORCE_VERSION CACHE STRING "Force usage of a specific wxWidgets version.")
77200
if(WXWIDGETS_FORCE_VERSION)
78201
set (wxWidgets_CONFIG_OPTIONS --version=${WXWIDGETS_FORCE_VERSION})
79202
endif()
80-
FIND_PACKAGE(wxWidgets REQUIRED COMPONENTS ${wxWidgets_FIND_COMPONENTS})
81-
ENDIF(NOT DEFINED wxWidgets_USE_FILE)
203+
204+
MESSAGE(STATUS "wxWidgets components: ${wxWidgets_USE_LIBS}")
205+
FIND_PACKAGE(wxWidgets REQUIRED COMPONENTS ${wxWidgets_USE_LIBS})
82206

83-
INCLUDE(${wxWidgets_USE_FILE})
84-
ENDIF(NOT QT_ANDROID)
207+
IF(MSVC)
208+
# Exclude wxexpat.lib, since we use our own version.
209+
# Other things are excluded as well, but we don't need them
210+
SET(wxWidgets_EXCLUDE_COMMON_LIBRARIES TRUE)
211+
ENDIF(MSVC)
85212

86-
IF(MSYS)
87-
# this is just a hack. I think the bug is in FindwxWidgets.cmake
88-
STRING( REGEX REPLACE "/usr/local" "\\\\;C:/MinGW/msys/1.0/usr/local" wxWidgets_INCLUDE_DIRS ${wxWidgets_INCLUDE_DIRS} )
89-
ENDIF(MSYS)
213+
IF(WIN32 OR APPLE OR QT_ANDROID)
214+
IF(MSYS)
215+
# this is to convert msys to windows paths, and handle the missing /usr
216+
STRING( REGEX REPLACE "/usr/local" ";C:/MinGW/msys/1.0/local" wxWidgets_INCLUDE_DIRS ${wxWidgets_INCLUDE_DIRS} )
217+
ENDIF(MSYS)
218+
ENDIF(WIN32 OR APPLE OR QT_ANDROID)
219+
220+
INCLUDE(${wxWidgets_USE_FILE})
90221

91-
# QT_ANDROID is a cross-build, so the native FIND_PACKAGE(OpenGL) is not useful.
92-
#
93-
IF (NOT QT_ANDROID )
94-
FIND_PACKAGE(OpenGL)
95-
IF(OPENGL_GLU_FOUND)
222+
MESSAGE (STATUS "Found wxWidgets..." )
223+
MESSAGE (STATUS " wxWidgets Include: ${wxWidgets_INCLUDE_DIRS}")
224+
MESSAGE (STATUS " wxWidgets Libraries: ${wxWidgets_LIBRARIES}")
96225

97-
SET(wxWidgets_FIND_COMPONENTS ${wxWidgets_FIND_COMPONENTS} gl)
98-
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
226+
# We need to remove GLU from the wxWidgets_LIBRARIES list
227+
# It only appears to get on the list for MSW...
228+
FOREACH (_currentLibFile ${wxWidgets_LIBRARIES})
229+
SET(UCNAME ${_currentLibFile})
230+
string(TOUPPER ${UCNAME} UCNAME)
231+
IF(NOT ${UCNAME} MATCHES "(.*)GLU(.*)")
232+
SET( REVISED_wxWidgets_LIBRARIES ${REVISED_wxWidgets_LIBRARIES} ${_currentLibFile})
233+
ENDIF()
234+
ENDFOREACH (_currentLibFile )
235+
SET( wxWidgets_LIBRARIES ${REVISED_wxWidgets_LIBRARIES})
99236

100-
MESSAGE (STATUS "Found OpenGL..." )
101-
MESSAGE (STATUS " Lib: " ${OPENGL_LIBRARIES})
102-
MESSAGE (STATUS " Include: " ${OPENGL_INCLUDE_DIR})
103-
ADD_DEFINITIONS(-DocpnUSE_GL)
104-
ELSE(OPENGL_GLU_FOUND)
105-
MESSAGE (STATUS "OpenGL not found..." )
106-
ENDIF(OPENGL_GLU_FOUND)
237+
MESSAGE (STATUS " Revised wxWidgets Libraries: ${wxWidgets_LIBRARIES}")
107238
ENDIF(NOT QT_ANDROID)
108239

240+
IF(NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID)
241+
OPTION(OCPN_FORCE_GTK3 "Force the build to use GTK3" OFF)
242+
243+
IF(NOT OCPN_FORCE_GTK3)
244+
FIND_PACKAGE(GTK2)
245+
ENDIF(NOT OCPN_FORCE_GTK3)
246+
247+
IF(GTK2_FOUND)
248+
set(wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --toolkit=gtk2)
249+
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
250+
SET(GTK_LIBRARIES ${GTK2_LIBRARIES})
251+
MESSAGE(STATUS "Building against GTK2...")
252+
ELSE(GTK2_FOUND)
253+
FIND_PACKAGE(GTK3)
254+
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
255+
SET(GTK_LIBRARIES ${GTK3_LIBRARIES})
256+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__WXGTK3__")
257+
set(wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --toolkit=gtk3)
258+
MESSAGE(STATUS "Building against GTK3...")
259+
ENDIF(GTK2_FOUND)
260+
SET(EXTRA_LIBS ${EXTRA_LIBS} ${GTK_LIBRARIES})
261+
ENDIF(NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID)
262+
109263
# On Android, PlugIns need a specific linkage set....
110264
IF (QT_ANDROID )
111265
# These libraries are needed to create PlugIns on Android.

0 commit comments

Comments
 (0)