Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OS native interface lib, with objective-c++ interface to Mac Coco…
…a libraries
- Loading branch information
1 parent
f8f7d60
commit f6bd7b3
Showing
17 changed files
with
559 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
############################################################# | ||
# locate native libs | ||
|
||
SET(NATIVE_LINK_LIBS) | ||
|
||
IF(APPLE) | ||
SET(APPLE_LIB_LIST ApplicationServices CoreFoundation IOKit AppKit) | ||
FOREACH(_lib ${APPLE_LIB_LIST}) | ||
STRING(TOUPPER ${_lib} _lib_var) | ||
# prefer /System/Library/Frameworks, in case CMAKE_FIND_FRAMEWORK=LAST, etc. | ||
FIND_LIBRARY(APPLE_${_lib_var}_LIBRARY | ||
NAMES ${_lib} | ||
PATHS /System/Library/Frameworks | ||
NO_DEFAULT_PATH | ||
) | ||
# if not found, drop back to standard find paths | ||
FIND_LIBRARY(APPLE_${_lib_var}_LIBRARY ${_lib}) | ||
|
||
IF(NOT APPLE_${_lib_var}_LIBRARY) | ||
MESSAGE(FATAL_ERROR "Couldn't find Apple's '${_lib}' framework or library") | ||
ENDIF(NOT APPLE_${_lib_var}_LIBRARY) | ||
|
||
LIST(APPEND NATIVE_LINK_LIBS "-framework ${_lib}") | ||
ENDFOREACH(_lib ${APPLE_LIB_LIST}) | ||
ENDIF(APPLE) | ||
|
||
############################################################# | ||
# sources | ||
|
||
SET(QGIS_CORE_SRCS) | ||
|
||
IF(APPLE) | ||
SET(QGIS_APP_OBJC_SRCS | ||
mac/cocoainitializer.mm | ||
mac/qgsmacappkit.mm | ||
) | ||
|
||
SET_SOURCE_FILES_PROPERTIES(${QGIS_APP_OBJC_SRCS} PROPERTIES COMPILE_FLAGS "-x objective-c++") | ||
|
||
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS} | ||
${QGIS_APP_OBJC_SRCS} | ||
mac/qgsmacnative.cpp | ||
) | ||
ENDIF(APPLE) | ||
|
||
SET(QGIS_CORE_MOC_HDRS) | ||
|
||
QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS}) | ||
|
||
# install headers | ||
|
||
IF(APPLE) | ||
SET (QGIS_CORE_HDRS ${QGIS_CORE_HDRS} | ||
mac/qgsmacnative.h | ||
mac/cocoainitializer.h | ||
mac/qgsmacappkit.h | ||
) | ||
ENDIF(APPLE) | ||
|
||
INCLUDE_DIRECTORIES( | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
IF(APPLE) | ||
INCLUDE_DIRECTORIES(mac) | ||
ENDIF(APPLE) | ||
|
||
# Test data dir for QgsRenderChecker | ||
ADD_DEFINITIONS(-DTEST_DATA_DIR="\\"${TEST_DATA_DIR}\\"") | ||
|
||
############################################################# | ||
# qgis_native library | ||
|
||
ADD_LIBRARY(qgis_native SHARED ${QGIS_CORE_SRCS} ${QGIS_CORE_MOC_SRCS} ${QGIS_CORE_HDRS} ${QGIS_CORE_MOC_HDRS}) | ||
|
||
IF(NOT APPLE) | ||
INSTALL(FILES ${QGIS_CORE_HDRS} ${QGIS_CORE_MOC_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) | ||
ELSE(NOT APPLE) | ||
SET_TARGET_PROPERTIES(qgis_native PROPERTIES | ||
CLEAN_DIRECT_OUTPUT 1 | ||
FRAMEWORK 1 | ||
FRAMEWORK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}" | ||
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/mac/framework.info.plist.in" | ||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION} | ||
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis2_native | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
PUBLIC_HEADER "${QGIS_CORE_HDRS};${QGIS_CORE_MOC_HDRS}" | ||
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" | ||
) | ||
ENDIF(NOT APPLE) | ||
|
||
#generate unversioned libs for android | ||
IF(NOT ANDROID) | ||
SET_TARGET_PROPERTIES(qgis_native PROPERTIES | ||
VERSION ${COMPLETE_VERSION} | ||
SOVERSION ${COMPLETE_VERSION} | ||
) | ||
ENDIF(NOT ANDROID) | ||
|
||
TARGET_LINK_LIBRARIES(qgis_native "${NATIVE_LINK_LIBS}") | ||
|
||
# install | ||
|
||
INSTALL(TARGETS qgis_native | ||
RUNTIME DESTINATION ${QGIS_BIN_DIR} | ||
LIBRARY DESTINATION ${QGIS_LIB_DIR} | ||
ARCHIVE DESTINATION ${QGIS_LIB_DIR} | ||
FRAMEWORK DESTINATION ${QGIS_FW_SUBDIR} | ||
PUBLIC_HEADER DESTINATION ${QGIS_INCLUDE_DIR}) | ||
|
||
# Mac dev frameworks | ||
|
||
IF (APPLE AND QGIS_MACAPP_INSTALL_DEV) | ||
INSTALL(TARGETS qgis_native FRAMEWORK DESTINATION ${QGIS_MACAPP_DEV_PREFIX}) | ||
INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -id \"${QGIS_MACAPP_DEV_PREFIX}/qgis_native.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_native\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_native.framework/qgis_native\")") | ||
ENDIF (APPLE AND QGIS_MACAPP_INSTALL_DEV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
README for qgis_native lib | ||
========================== | ||
|
||
This library is intended to offer abstraction to the host OS's underlying public | ||
interfaces. This is useful for OSes that provide interfaces in languages other | ||
than C/C++, or for grouping calls to OS-specific code so that it only needs to | ||
be updated in one place in the source tree. It is advisable to leverage existing | ||
functions provided by Qt, rather than rely upon OS-specific code, unless such | ||
code extends the application to provide a better OS-specific user experience or | ||
solve a problem. | ||
|
||
Example | ||
------- | ||
|
||
As of Mac OS X 10.9 (Mavericks) many system public API calls to Carbon libraries | ||
(based upon C) have been deprecated in favor of modern Cocoa libraries (written | ||
in Objective-C), which can no longer be directly called from C++. Coalescing | ||
and mixing these new calls in a library, using Objective-C++ allows not only | ||
access to the Apple system Objective-C libraries and frameworks, but also those | ||
from third-parties, like the auto-updating Sparkle.framework. | ||
|
||
See also: http://el-tramo.be/blog/mixing-cocoa-and-qt/ | ||
http://sparkle.andymatuschak.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*************************************************************************** | ||
cocoaInitializer.h - used to enable Cocoa’s memory management | ||
------------------- | ||
copyright : (C) 2008 by Remko Troncon | ||
email : remco at el-tramo dot be | ||
url : http://el-tramo.be/blog/mixing-cocoa-and-qt/ | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
(1) Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
(2) Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
(3)The name of the author may not be used to | ||
endorse or promote products derived from this software without | ||
specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
***************************************************************************/ | ||
|
||
#ifndef COCOAINITIALIZER_H | ||
#define COCOAINITIALIZER_H | ||
|
||
|
||
class CocoaInitializer | ||
{ | ||
public: | ||
CocoaInitializer(); | ||
~CocoaInitializer(); | ||
|
||
private: | ||
class Private; | ||
Private* d; | ||
}; | ||
|
||
#endif // COCOAINITIALIZER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*************************************************************************** | ||
cocoaInitializer.mm - used to enable Cocoa’s memory management | ||
------------------- | ||
copyright : (C) 2008 by Remko Troncon | ||
email : remco at el-tramo dot be | ||
url : http://el-tramo.be/blog/mixing-cocoa-and-qt/ | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
(1) Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
(2) Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
(3)The name of the author may not be used to | ||
endorse or promote products derived from this software without | ||
specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
***************************************************************************/ | ||
|
||
#include "CocoaInitializer.h" | ||
|
||
#include <AppKit/AppKit.h> | ||
#include <Cocoa/Cocoa.h> | ||
|
||
class CocoaInitializer::Private | ||
{ | ||
public: | ||
NSAutoreleasePool* autoReleasePool_; | ||
}; | ||
|
||
CocoaInitializer::CocoaInitializer() | ||
{ | ||
d = new CocoaInitializer::Private(); | ||
NSApplicationLoad(); | ||
d->autoReleasePool_ = [[NSAutoreleasePool alloc] init]; | ||
} | ||
|
||
CocoaInitializer::~CocoaInitializer() | ||
{ | ||
[d->autoReleasePool_ release]; | ||
delete d; | ||
} |
Oops, something went wrong.