Skip to content

Commit

Permalink
first try at making osgWorks found by third party packages the CMake …
Browse files Browse the repository at this point in the history
…way.

git-svn-id: http://osgworks.googlecode.com/svn/trunk@441 c67418bc-a6eb-11de-8ba5-91705c1537ed
  • Loading branch information
[email protected] committed Jun 10, 2012
1 parent e9971b0 commit 3651250
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 3 deletions.
40 changes: 39 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set( OSGWORKS_MAJOR_VERSION 2 )
set( OSGWORKS_MINOR_VERSION 0 )
set( OSGWORKS_SUB_VERSION 2 )

SET( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}" )
SET( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules" ${CMAKE_MODULE_PATH} )


set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
Expand Down Expand Up @@ -119,4 +119,42 @@ if(MSVC)
)
endif(MSVC)

# The interesting stuff goes here
# ===============================

# Add all targets to the build-tree export set
export(TARGETS osgwTools osgwQuery osgwMx
FILE "${PROJECT_BINARY_DIR}/lib/osgWorksLibraryDepends.cmake")

# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE osgWorks)

# Create a osgWorksBuildTreeSettings.cmake file for the use from the build tree
configure_file(osgWorksBuildTreeSettings.cmake.in
"${PROJECT_BINARY_DIR}/lib/osgWorksBuildTreeSettings.cmake" @ONLY)

#configure_file(osgWorksConfig.cmake.in
# "${PROJECT_BINARY_DIR}/lib/osgWorksConfig.cmake" @ONLY)
configure_file(osgWorksConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/lib/osgWorksConfigVersion.cmake" @ONLY)
configure_file(UseosgWorks.cmake.in
"${PROJECT_BINARY_DIR}/lib/UseosgWorks.cmake" @ONLY)

# Install the export set for use with the install-tree
install(EXPORT osgworks-targets DESTINATION lib)

include( CMakePackageConfigHelpers )
# Create the osgWorksConfig.cmake and osgWorksConfigVersion files
file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/lib"
"${CMAKE_INSTALL_PREFIX}/include")

configure_package_config_file(
osgWorksConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/lib/osgWorksConfig.cmake
INSTALL_DESTINATION lib
PATH_VARS CONF_REL_INCLUDE_DIR )

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/osgWorksConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/lib/osgWorksConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/lib/UseosgWorks.cmake
DESTINATION lib )
45 changes: 45 additions & 0 deletions CMakeModules/FindosgWorks.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# - Find a osgWorks installation or build tree.
# The following variables are set if osgWorks is found. If osgWorks is not
# found, osgWorks_FOUND is set to false.
# osgWorks_FOUND - Set to true when osgWorks is found.
# osgWorks_USE_FILE - CMake file to use osgWorks.
# osgWorks_MAJOR_VERSION - The osgWorks major version number.
# osgWorks_MINOR_VERSION - The osgWorks minor version number
# (odd non-release).
# osgWorks_BUILD_VERSION - The osgWorks patch level
# (meaningless for odd minor).
# osgWorks_INCLUDE_DIRS - Include directories for osgWorks
# osgWorks_LIBRARY_DIRS - Link directories for osgWorks libraries

# The following cache entries must be set by the user to locate osgWorks:
# osgWorks_DIR - The directory containing osgWorksConfig.cmake.
# This is either the root of the build tree,
# or the lib directory. This is the
# only cache entry.


# Assume not found.
SET(osgWorks_FOUND 0)

# Construct consitent error messages for use below.
SET(osgWorks_DIR_DESCRIPTION "directory containing osgWorksConfig.cmake. This is either the root of the build tree, or PREFIX/lib for an installation.")
SET(osgWorks_DIR_MESSAGE "osgWorks not found. Set the osgWorks_DIR cmake cache entry to the ${osgWorks_DIR_DESCRIPTION}")

# Use the Config mode of the find_package() command to find osgWorksConfig.
# If this succeeds (possibly because osgWorks_DIR is already set), the
# command will have already loaded osgWorksConfig.cmake and set osgWorks_FOUND.
IF(NOT osgWorks_FOUND)
FIND_PACKAGE(osgWorks QUIET NO_MODULE)
ENDIF()

#-----------------------------------------------------------------------------
IF(NOT osgWorks_FOUND)
# osgWorks not found, explain to the user how to specify its location.
IF(osgWorks_FIND_REQUIRED)
MESSAGE(FATAL_ERROR ${osgWorks_DIR_MESSAGE})
ELSE(osgWorks_FIND_REQUIRED)
IF(NOT osgWorks_FIND_QUIETLY)
MESSAGE(STATUS ${osgWorks_DIR_MESSAGE})
ENDIF(NOT osgWorks_FIND_QUIETLY)
ENDIF(osgWorks_FIND_REQUIRED)
ENDIF(osgWorks_FOUND)
3 changes: 1 addition & 2 deletions CMakeModules/ModuleInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ INSTALL(
# FIXME: Do not run for OS X framework
INSTALL(
FILES ${LIB_PUBLIC_HEADERS}
#EXPORT osgworks-targets
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
COMPONENT libosgworks-dev
)

# EXPORT osgworks-targets
25 changes: 25 additions & 0 deletions UseosgWorks.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# This module is provided as osgWorks_USE_FILE by osgWorksConfig.cmake. It can
# be INCLUDEd in a project to load the needed compiler and linker
# settings to use osgWorks.
#

IF(NOT osgWorks_USE_FILE_INCLUDED)
SET(osgWorks_USE_FILE_INCLUDED 1)

# Update CMAKE_MODULE_PATH so includes work.
#SET (CMAKE_MODULE_PATH
# ${CMAKE_MODULE_PATH}
# ${VTK_CMAKE_DIR})

# Add compiler flags needed to use osgWorks.
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VTK_REQUIRED_C_FLAGS}")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VTK_REQUIRED_CXX_FLAGS}")
#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${VTK_REQUIRED_EXE_LINKER_FLAGS}")
#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${VTK_REQUIRED_SHARED_LINKER_FLAGS}")
#SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${VTK_REQUIRED_MODULE_LINKER_FLAGS}")

# Add include directories needed to use osgWorks.
INCLUDE_DIRECTORIES(${OSGWORKS_INCLUDE_DIRS})

ENDIF(NOT osgWorks_USE_FILE_INCLUDED)
3 changes: 3 additions & 0 deletions osgWorksBuildTreeSettings.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(OSGWORKS_INCLUDE_DIRS
"@PROJECT_SOURCE_DIR@/include"
"@PROJECT_BINARY_DIR@")
29 changes: 29 additions & 0 deletions osgWorksConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# - Config file for the osgWorks package
# It defines the following variables
# OSGWORKS_INCLUDE_DIRS - include directories for FooBar
# OSGWORKS_LIBRARIES - libraries to link against
# OSGWORKS_EXECUTABLE - the bar executable

@PACKAGE_INIT@

# These are IMPORTED targets created by osgWorksLibraryDepends.cmake
set(OSGWORKS_LIBRARIES "osgwTools;osgwQuery;osgwMx" )
set(OSGWORKS_EXECUTABLE test)

# Compute paths
# get_filename_component(OSGWORKS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(EXISTS "${PACKAGE_PREFIX_DIR}/CMakeCache.txt")
# In build tree
include("${PACKAGE_PREFIX_DIR}/lib/osgWorksBuildTreeSettings.cmake")
# Our library dependencies (contains definitions for IMPORTED targets)
include("${PACKAGE_PREFIX_DIR}/lib/osgWorksLibraryDepends.cmake")
else()
set_and_check(OSGWORKS_INCLUDE_DIRS "@PACKAGE_CONF_REL_INCLUDE_DIR@")
# The osgWorks targets file.
if(EXISTS "${PACKAGE_PREFIX_DIR}/lib/osgworks-targets.cmake")
include("${PACKAGE_PREFIX_DIR}/lib/osgworks-targets.cmake")
endif()
endif()

# The location of the UseosgWorks.cmake file.
set(osgWorks_USE_FILE "${PACKAGE_PREFIX_DIR}/lib/UseosgWorks.cmake")
11 changes: 11 additions & 0 deletions osgWorksConfigVersion.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@OSGWORKS_VERSION@")

# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

0 comments on commit 3651250

Please sign in to comment.