Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rpavlik committed May 17, 2010
0 parents commit 3fe03cd
Show file tree
Hide file tree
Showing 135 changed files with 12,570 additions and 0 deletions.
198 changes: 198 additions & 0 deletions BoostTestTargets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# - Add tests using boost::test
#
# Add this line to your test files in place of including a basic boost test header:
# #include <BoostTestTargetConfig.h>
#
# If you cannot do that and must use the included form for a given test,
# include the line
# // OVERRIDE_BOOST_TEST_INCLUDED_WARNING
# in the same file with the boost test include.
#
# include(BoostTestTargets)
# add_boost_test(<testdriver_name> SOURCES <source1> [<more sources...>]
# [LIBRARIES <library> [<library>...]]
# [RESOURCES <resource> [<resource>...]]
# [TESTS <testcasename> [<testcasename>...]])
#
# If for some reason you need access to the executable target created,
# it is ${BOOST_TEST_TARGET_PREFIX}${testdriver_name} as specified when
# you called add_boost_test
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Requires:
# GetForceIncludeDefinitions
# CopyResourcesToBuildTree
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC

if(__add_boost_test)
return()
endif()
set(__add_boost_test YES)

set(BOOST_TEST_TARGET_PREFIX "boosttesttarget_")

if(NOT Boost_FOUND)
find_package(Boost 1.34.0 QUIET)
endif()
if("${Boost_VERSION}0" LESS "1034000")
set(_shared_msg "NOTE: boost::test-based targets and tests cannot "
"be added: boost >= 1.34.0 required but not found. "
"(found: '${Boost_VERSION}'; want >=103400) ")
if(BUILD_TESTING)
message(FATAL_ERROR ${_shared_msg}
"You may disable BUILD_TESTING to continue without the "
"tests.")
else()
message(STATUS ${_shared_msg}
"BUILD_TESTING disabled, so continuing anyway.")
endif()
endif()

include(GetForceIncludeDefinitions)
include(CopyResourcesToBuildTree)

if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")
if(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
find_package(Boost 1.34.0 QUIET COMPONENTS unit_test_framework)
endif()
if(Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
set(_boosttesttargets_libs ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
if(Boost_USE_STATIC_LIBS)
set(_boostConfig "BoostTestTargetsStatic.h")
else()
set(_boostConfig "BoostTestTargetsDynamic.h")
endif()
else()
set(_boosttesttargets_libs)
set(_boostConfig "BoostTestTargetsIncluded.h")
endif()
get_filename_component(_moddir ${CMAKE_CURRENT_LIST_FILE} PATH)
configure_file("${_moddir}/${_boostConfig}" "${CMAKE_CURRENT_BINARY_DIR}/BoostTestTargetConfig.h" COPYONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
endif()

function(add_boost_test _name)
if(NOT BUILD_TESTING)
return()
endif()
# parse arguments
set(_nowhere)
set(_curdest _nowhere)
set(_val_args
SOURCES
LIBRARIES
RESOURCES
TESTS)
set(_bool_args
USE_COMPILED_LIBRARY)
foreach(_arg ${_val_args} ${_bool_args})
set(${_arg})
endforeach()
foreach(_element ${ARGN})
list(FIND _val_args "${_element}" _val_arg_find)
list(FIND _bool_args "${_element}" _bool_arg_find)
if("${_val_arg_find}" GREATER "-1")
set(_curdest "${_element}")
elseif("${_bool_arg_find}" GREATER "-1")
set("${_element}" ON)
set(_curdest _nowhere)
else()
list(APPEND ${_curdest} "${_element}")
endif()
endforeach()

if(_nowhere)
message(FATAL_ERROR "Syntax error in use of add_boost_test!")
endif()

if(NOT SOURCES)
message(FATAL_ERROR "Syntax error in use of add_boost_test: at least one source file required!")
endif()

if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")

include_directories(${Boost_INCLUDE_DIRS})

set(includeType)
foreach(src ${SOURCES})
file(READ ${src} thefile)
if("${thefile}" MATCHES ".*BoostTestTargetConfig.h.*")
set(includeType CONFIGURED)
set(includeFileLoc ${src})
break()
elseif("${thefile}" MATCHES ".*boost/test/included/unit_test.hpp.*")
set(includeType INCLUDED)
set(includeFileLoc ${src})
set(_boosttesttargets_libs) # clear this out - linking would be a bad idea
if(NOT "${thefile}" MATCHES ".*OVERRIDE_BOOST_TEST_INCLUDED_WARNING.*")
message("Please replace the include line in ${src} with this alternate include line instead:")
message(" \#include <BoostTestTargetConfig.h>")
message("Once you've saved your changes, re-run CMake. (See BoostTestTargets.cmake for more info)")
endif()
break()
endif()
endforeach()

if(NOT _boostTestTargetsNagged${_name} STREQUAL "${includeType}")
if("includeType" STREQUAL "CONFIGURED")
message(STATUS "Test '${_name}' uses the CMake-configurable form of the boost test framework - congrats! (Including File: ${includeFileLoc})")
elseif("${includeType}" STREQUAL "INCLUDED")
message("In test '${_name}': ${includeFileLoc} uses the 'included' form of the boost unit test framework.")
else()
message("In test '${_name}': Didn't detect the CMake-configurable boost test include.")
message("Please replace your existing boost test include in that test with the following:")
message(" \#include <BoostTestTargetConfig.h>")
message("Once you've saved your changes, re-run CMake. (See BoostTestTargets.cmake for more info)")
endif()
endif()
set(_boostTestTargetsNagged${_name} "${includeType}" CACHE INTERNAL "" FORCE)


if(RESOURCES)
list(APPEND SOURCES ${RESOURCES})
endif()

add_executable(${BOOST_TEST_TARGET_PREFIX}${_name} ${SOURCES})

#if(USE_COMPILED_LIBRARY)
list(APPEND LIBRARIES ${_boosttesttargets_libs})
#endif()
if(LIBRARIES)
target_link_libraries(${BOOST_TEST_TARGET_PREFIX}${_name} ${LIBRARIES})
endif()

if(RESOURCES)
set_property(TARGET
${BOOST_TEST_TARGET_PREFIX}${_name}
PROPERTY
RESOURCE
${RESOURCES})
copy_resources_to_build_tree(${BOOST_TEST_TARGET_PREFIX}${_name})
endif()

if(NOT Boost_TEST_FLAGS)
# set(Boost_TEST_FLAGS --catch_system_error=yes --output_format=XML)
set(Boost_TEST_FLAGS --catch_system_error=yes)
endif()

# TODO: Figure out why only recent boost handles individual test running properly
if(TESTS AND ("${Boost_VERSION}" VERSION_GREATER "103799"))
foreach(_test ${TESTS})
add_test(${_name}-${_test} ${BOOST_TEST_TARGET_PREFIX}${_name} --run_test=${_test} ${Boost_TEST_FLAGS})
endforeach()
else()
add_test(${_name}-boost::test ${BOOST_TEST_TARGET_PREFIX}${_name} ${Boost_TEST_FLAGS})
endif()

# CppCheck the test if we can.
if(COMMAND add_cppcheck)
add_cppcheck(${BOOST_TEST_TARGET_PREFIX}${_name} STYLE UNUSED_FUNCTIONS)
endif()

endif()
endfunction()
7 changes: 7 additions & 0 deletions BoostTestTargetsDynamic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Small header computed by CMake to set up boost test.
// include AFTER #define BOOST_TEST_MODULE whatever
// but before any other boost test includes.

#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

5 changes: 5 additions & 0 deletions BoostTestTargetsIncluded.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Small header computed by CMake to set up boost test.
// include AFTER #define BOOST_TEST_MODULE whatever
// but before any other boost test includes.

#include <boost/test/included/unit_test.hpp>
6 changes: 6 additions & 0 deletions BoostTestTargetsStatic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Small header computed by CMake to set up boost test.
// include AFTER #define BOOST_TEST_MODULE whatever
// but before any other boost test includes.

#include <boost/test/unit_test.hpp>

77 changes: 77 additions & 0 deletions BundleOSGRuntime.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# - Include the OpenSceneGraph runtime files in an installation or built package.
#
# OSGRUNTIME_BUNDLE - Set to "yes" to enable this behavior
# OSGRUNTIME_zlib1dll - Must be set to the location of zlib1.dll on Windows
# OSGRUNTIME_zlib1ddll - Can be set to the location of zlib1d.dll (debug) on Windows.
# If set, will be installed.
#
# Requires these CMake modules:
# no additional modules required
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC

if(OPENSCENEGRAPH_FOUND)
if(WIN32)
get_filename_component(_osglibdir "${OSG_LIBRARY}" PATH)
get_filename_component(_osgroot "${_osglibdir}/.." ABSOLUTE)
find_file(OSGBUNDLE_zlib1dll
zlib1.dll
PATHS
"${_osgroot}/bin"
"${_osgroot}/lib")
find_file(OSGBUNDLE_zlib1ddll
zlib1d.dll
PATHS
"${_osgroot}/bin"
"${_osgroot}/lib")
mark_as_advanced(OSGBUNDLE_zlib1dll OSGBUNDLE_zlib1ddll)
set(_osgbundle_required OSGBUNDLE_zlib1dll)
set(_osgbundle_platformOK on)
else()
# TODO - how to handle when not on Windows?
endif()
endif()

if(_osgbundle_platformOK)
set(_osgbundle_caninstall on)
foreach(_var ${_osgbundle_required})
if(NOT ${_var})
# If we are missing a single required file, cut out now.
set(_osgbundle_caninstall off)
option(OSGRUNTIME_BUNDLE
"Install a local copy of the OpenSceneGraph runtime files with the project."
off)
endif()
endforeach()
if(_osgbundle_caninstall)
option(OSGRUNTIME_BUNDLE
"Install a local copy of the OpenSceneGraph runtime files with the project."
on)
endif()
endif()

mark_as_advanced(OSGRUNTIME_BUNDLE)

if(OSGRUNTIME_BUNDLE AND OPENSCENEGRAPH_FOUND AND _osgbundle_caninstall)
if(WIN32)
install(FILES "${OSGBUNDLE_zlib1dll}"
DESTINATION bin)

if(OSGBUNDLE_zlib1ddll)
install(FILES "${OSGBUNDLE_zlib1ddll}"
DESTINATION bin)
endif()

install(DIRECTORY "${_osgroot}/bin/" "${_osgroot}/lib/"
DESTINATION bin
FILES_MATCHING

# Runtime files
PATTERN "*.dll")
else()
# TODO - how to handle when not on Windows?
endif()
endif()
93 changes: 93 additions & 0 deletions BundleVRJ22Runtime.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# - Include the VR Juggler runtime files in an installation or built package.
#
# VRJUGGLERRUNTIME_BUNDLE
# VRJUGGLERRUNTIME_BUNDLE_DEBUG - set to yes to include debug dll's as well
#
# Requires these CMake modules:
# FindVRJuggler22 and its dependencies
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC

if(WIN32)
option(VRJUGGLERRUNTIME_BUNDLE
"Install a local copy of the VR Juggler runtime files with the project."
on)
option(VRJUGGLERRUNTIME_BUNDLE_DEBUG
"Install the VR Juggler debug runtime files as well."
off)
mark_as_advanced(VRJUGGLERRUNTIME_BUNDLE_DEBUG)
else()
# TODO - how to handle when not on Windows?
#option(VRJUGGLERRUNTIME_BUNDLE "Install a local copy of the VR Juggler runtime files with the project." off)
endif()

mark_as_advanced(VRJUGGLERRUNTIME_BUNDLE VRJUGGLERRUNTIME_BUNDLE_DEBUG)

if(VRJUGGLERRUNTIME_BUNDLE AND VRJUGGLER22_FOUND)
if(WIN32)
get_filename_component(_vrjroot ${VRJ22_LIBRARY_DIR}/../ ABSOLUTE)

# TODO - make sure gadgeteer and sonix can find their DSO's at runtime...

foreach(_dir bin lib)
if(VRJUGGLERRUNTIME_BUNDLE_DEBUG)
install(DIRECTORY ${_vrjroot}/${_dir}/
DESTINATION bin
PATTERN "*.lib" EXCLUDE # exclude static and link libraries
PATTERN "*.exe" EXCLUDE # exclude unneeded executables
PATTERN "*.py" EXCLUDE # exclude unneeded python executables
PATTERN "*.pyc" EXCLUDE # exclude unneeded python executables
)
else()
install(DIRECTORY ${_vrjroot}/${_dir}/
DESTINATION bin
PATTERN "*.lib" EXCLUDE # exclude static and link libraries
PATTERN "*.exe" EXCLUDE # exclude unneeded executables
PATTERN "*.py" EXCLUDE # exclude unneeded python executables
PATTERN "*.pyc" EXCLUDE # exclude unneeded python executables

PATTERN "*d.dll" EXCLUDE # exclude debug dll's
PATTERN "*-gd-*.dll" EXCLUDE # exclude Boost debug dll's
)
endif()

endforeach()

install(DIRECTORY ${_vrjroot}/share/
DESTINATION share
FILES_MATCHING

# Runtime files
PATTERN "*.dll"
PATTERN "*.jar"

# Data files
PATTERN "*.wav"
PATTERN "*.xml"
PATTERN "*.xsl"
PATTERN "*.xsd"
PATTERN "*.flt"
PATTERN "*.dat"
PATTERN "*.table"


# Config files
PATTERN "*.jdef"
PATTERN "*.jconf"
PATTERN "*.cfg"
PATTERN "hosts.allow"

# Other Files
PATTERN "*.txt"
PATTERN "COPYING*"
PATTERN "ChangeLog"
)

endif()



endif()
Loading

0 comments on commit 3fe03cd

Please sign in to comment.