Skip to content

Commit

Permalink
osgdb_ngp loader.
Browse files Browse the repository at this point in the history
Creating an osgdb_ngp loader from existing ngp interface code.
  • Loading branch information
XenonofArcticus committed Sep 2, 2014
1 parent 3aa13bc commit 6354aed
Show file tree
Hide file tree
Showing 11 changed files with 810 additions and 0 deletions.
63 changes: 63 additions & 0 deletions integrations/osgdb_ngp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# osgngp top-level CMakeLists.txt
# https://github.com/XenonofArcticus/osgngp
#

cmake_minimum_required( VERSION 2.8.5 )
project( osgdb_ngp )

# Define project-specific macros.
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH} )
include( CMakeMacros )


# Installation directories
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )


#
# OpenSceneGraph.
# Set OSG_DIR (env or cmake) as hint, if necessary.
set( _osgComponents osgGA osgText osgViewer osgSim osgDB osgUtil osg OpenThreads )
find_package( OpenSceneGraph 2.8.5 COMPONENTS ${_osgComponents} REQUIRED )

#
# require ngpcore.
# Set NGPCORE_ROOT (env or cmake) as hint, if necessary.
find_package( NGPCORE REQUIRED )

#
# By default, build shared libraries.
set( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared or static libs" )

if( WIN32 )
# Common debug postfix for Windows.
set( CMAKE_DEBUG_POSTFIX d )
endif()



add_subdirectory( src )



#
# Install pdb files for Debug and RelWithDebInfo builds
if( MSVC )
install(
DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/\${CMAKE_INSTALL_CONFIG_NAME}/
DESTINATION lib
USE_SOURCE_PERMISSIONS
COMPONENT libprc-dev
FILES_MATCHING PATTERN "*.pdb"
)
install(
DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/\${CMAKE_INSTALL_CONFIG_NAME}/
DESTINATION lib
USE_SOURCE_PERMISSIONS
COMPONENT libprc-dev
FILES_MATCHING PATTERN "*.pdb"
)
endif()
22 changes: 22 additions & 0 deletions integrations/osgdb_ngp/CMakeModules/CMakeMacros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
macro( _addOSGPlugin TRGTNAME )
if( BUILD_SHARED_LIBS )
add_library( ${TRGTNAME} MODULE ${ARGN} )
else()
add_library( ${TRGTNAME} STATIC ${ARGN} )
endif()

include_directories(
${OPENSCENEGRAPH_INCLUDE_DIRS}
${NGPCORE_INCLUDE_DIRS}
)

target_link_libraries( ${TRGTNAME}
${OPENSCENEGRAPH_LIBRARIES}
${NGPCORE_LIBRARIES}
)

set_target_properties( ${TRGTNAME} PROPERTIES PROJECT_LABEL "Plugin ${TRGTNAME}" )

set( _libName ${TRGTNAME} )
include( ModuleInstall REQUIRED )
endmacro()
76 changes: 76 additions & 0 deletions integrations/osgdb_ngp/CMakeModules/FindNGPCORE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# - Find ngpcore
# Find the ngplantcopre includes and libraries
# This module defines
# NGPCORE_INCLUDE_DIRS, where to find ngpcore folder
# NGPCORE_LIBRARIES, libraries to link against to use ngpcore.
# NGPCORE_FOUND, If false, do not try to use ngpcore.
#
# Search hint (in CMake or as an environment variable):
# NGPCORE_ROOT, the ngpcore install directory root.
#
# Find ngpcore static or dynamic libs? Set as a CMake veriable:
# NGPCORE_STATIC, find the static libs if ON, dynamic by default



# Find the main libHaru header.
set( NGPCORE_INCLUDE_DIRS )
find_path( NGPCORE_INCLUDE_DIRS ngpcore
PATHS ${NGPCORE_ROOT} ENV NGPCORE_ROOT
PATH_SUFFIXES include
)


# Get a list of libraries, with static 's' suffix if necessary.
set( _requestedComponents ngpcore )
set( _components )
foreach( lib ${_requestedComponents} )
if( NGPCORE_STATIC )
list( APPEND _components ${lib}s )
else()
list( APPEND _components ${lib} )
endif()
endforeach()

# Find each library.
set( NGPCORE_LIBRARIES )
foreach( lib ${_components} )
find_library( NGPCORE_${lib}_LIBRARY
NAMES ${lib}
PATHS ${NGPCORE_ROOT} ENV NGPCORE_ROOT
PATH_SUFFIXES lib
)
find_library( NGPCORE_${lib}_LIBRARY_DEBUG
NAMES ${lib}d
PATHS ${NGPCORE_ROOT} ENV NGPCORE_ROOT
PATH_SUFFIXES lib
)

if( NOT NGPCORE_${lib}_LIBRARY )
message( WARNING "Could not find NGPCORE component library ${lib}" )
else()
if( NGPCORE_${lib}_LIBRARY_DEBUG AND
( NOT NGPCORE_${lib}_LIBRARY_DEBUG STREQUAL NGPCORE_${lib}_LIBRARY ) )
list( APPEND NGPCORE_LIBRARIES "optimized" ${NGPCORE_${lib}_LIBRARY} )
list( APPEND NGPCORE_LIBRARIES "debug" ${NGPCORE_${lib}_LIBRARY_DEBUG} )
else()
list( APPEND NGPCORE_LIBRARIES ${NGPCORE_${lib}_LIBRARY} )
endif()
mark_as_advanced( NGPCORE_${lib}_LIBRARY )
mark_as_advanced( NGPCORE_${lib}_LIBRARY_DEBUG )
endif()
endforeach()


# handle the QUIETLY and REQUIRED arguments and set NGPCORE_FOUND to TRUE if
# all listed variables are TRUE
include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( NGPCORE
REQUIRED_VARS NGPCORE_INCLUDE_DIRS NGPCORE_LIBRARIES
)


mark_as_advanced(
ASSIMP_INCLUDE_DIR
ASSIMP_LIBRARIES
)
21 changes: 21 additions & 0 deletions integrations/osgdb_ngp/CMakeModules/ModuleInstall.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Required Vars:
# ${_libName}
SET( LIB_NAME ${_libName} )

SET( INSTALL_INCDIR include )
SET( INSTALL_BINDIR bin )
IF( WIN32 )
SET( INSTALL_LIBDIR bin )
SET( INSTALL_ARCHIVEDIR lib )
ELSE()
SET( INSTALL_LIBDIR lib${LIB_POSTFIX} )
SET( INSTALL_ARCHIVEDIR lib${LIB_POSTFIX} )
ENDIF()

install(
TARGETS ${LIB_NAME}
EXPORT libprc-targets
RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libprc
LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT libprc
ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} COMPONENT libprc-dev
)
3 changes: 3 additions & 0 deletions integrations/osgdb_ngp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if( OPENSCENEGRAPH_FOUND )
add_subdirectory( osgdb_ngp )
endif()
7 changes: 7 additions & 0 deletions integrations/osgdb_ngp/src/osgdb_ngp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_addOSGPlugin( osgdb_ngp
ReaderWriterNgp.cpp
NgpFileName.cpp
NgpFileName.h
UtlString.h
UtlString.cpp
)
Loading

0 comments on commit 6354aed

Please sign in to comment.