Skip to content

Commit

Permalink
CMake: Add osgQtQuick_WITH_OSGQT option
Browse files Browse the repository at this point in the history
Also add osgQt imported module
  • Loading branch information
podsvirov committed Sep 21, 2017
1 parent bd72ba7 commit 906d6fb
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ set(osgQtQuick_BUILD_DOCS OFF
set(osgQtQuick_BUILD_DEBUGGER OFF
CACHE BOOL "Set to ON to build debugger application (By default is OFF)")

set(osgQtQuick_WITH_OSGQT ON
CACHE BOOL "Set to OFF to build without osgQt library support (By default is ON)")

set(osgQtQuick_WITH_EARTH OFF
CACHE BOOL "Set to ON to build with osgEarth library support (By default is OFF)")

Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ list(APPEND CMAKE_MODULE_PATH "${osgQtQuick_ROOT_DIR}/cmake")
# OpenSceneGraph
find_package(OpenSceneGraph 3.0 REQUIRED
osg
osgQt
osgDB
osgGA
osgManipulator
osgUtil
osgViewer
osgText)

# osgQt
if(osgQtQuick_WITH_OSGQT)
find_package(osgQt 3.0 REQUIRED)
endif()

# Qt
if(osgQtQuick_WITH_QT_PRIVATE)
find_package(Qt5Quick CONFIG REQUIRED
Expand Down
2 changes: 2 additions & 0 deletions src/debugger/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ int main(int argc, char *argv[])
osgText::registerQtQmlTypes("osgText");
osgViewer::registerQtQmlTypes("osgViewer");
osgViewer::registerQtQuickTypes("osgViewer");
#if defined(OSGQTQUICK_WITH_OSGQT)
osgQt::registerQtQmlTypes("osgQt");
#endif
#if defined(OSGQTQUICK_WITH_EARTH)
osgEarth::Util::registerQtQmlTypes("osgEarthUtil");
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/imports/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ add_subdirectory(osgmanipulator)
add_subdirectory(osgtext)
add_subdirectory(osgviewer)

if(osgQtQuick_WITH_OSGQT)
add_subdirectory(osgqt)
endif()

if(osgQtQuick_WITH_EARTH)
add_subdirectory(osgearthutil)
endif()
2 changes: 2 additions & 0 deletions src/imports/osgqt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Module configuration
osgqtquick_imported_module("osgQt")
19 changes: 19 additions & 0 deletions src/imports/osgqt/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <QtQml/QtQml>

#include <osgQt/ModuleQtQml>

class osgQtQtPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")

public:
void registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("osgQt"));
// osgQt types from osgQtQml library
osgQt::registerQtQmlTypes(uri);
}
};

#include "plugin.moc"
19 changes: 15 additions & 4 deletions src/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ META_Node(osgText FontImplementation)
META_Node(osgText TextBase)
META_Node(osgText Text3D)

META_Node(osgQt QFontImplementation)
if(osgQtQuick_WITH_OSGQT)
META_Node(osgQt QFontImplementation)
endif()

META_Node(osgViewer CompositeViewer)

Expand Down Expand Up @@ -114,13 +116,17 @@ list(APPEND _srcs
osgmanipulator/module.cpp
# osgText
osgtext/module.cpp
# osgQt
osgqt/module.cpp
# osgViewer
osgviewer/compositeviewer.cpp
osgviewer/module.cpp
)

if(osgQtQuick_WITH_OSGQT)
list(APPEND _srcs
# osgQt
osgqt/module.cpp)
endif()

if(osgQtQuick_WITH_EARTH)
list(APPEND _moc_hdrs
# osgEarthUtil
Expand Down Expand Up @@ -149,7 +155,6 @@ osgqtquick_library(osgQtQml)
target_link_libraries(osgQtQml
${OPENTHREADS_LIBRARIES}
${OSG_LIBRARIES}
${OSGQT_LIBRARIES}
${OSGDB_LIBRARIES}
${OSGGA_LIBRARIES}
${OSGMANIPULATOR_LIBRARIES}
Expand All @@ -159,6 +164,12 @@ target_link_libraries(osgQtQml
Qt5::Gui
Qt5::Qml)

if(osgQtQuick_WITH_OSGQT)
target_link_libraries(osgQtQml ${OSGQT_LIBRARIES})
target_compile_definitions(osgQtQml
PUBLIC "OSGQTQUICK_WITH_OSGQT=1")
endif()

file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/osgQtQml")

file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/include/osgQtQml/Export"
Expand Down

0 comments on commit 906d6fb

Please sign in to comment.