From Luigi Calori, added marco support

This commit is contained in:
Robert Osfield 2007-03-05 13:27:55 +00:00
parent b428aee852
commit 71ec26ba62
7 changed files with 708 additions and 2 deletions

View File

@ -141,7 +141,7 @@ ENDIF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(src)
# OSG Applications
OPTION(BUILD_OSG_APPLICATIONS "Enable to build OSG Applications (e.g. osgviewer)" OFF)
OPTION(BUILD_OSG_APPLICATIONS "Enable to build OSG Applications (e.g. osgviewer)" ON)
IF (BUILD_OSG_APPLICATIONS)
ADD_SUBDIRECTORY(applications)
ENDIF(BUILD_OSG_APPLICATIONS)

View File

@ -0,0 +1,111 @@
#miscellaneous macros
################### macros from http://www.cmake.org/Wiki/CMakeMacroListOperations
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO(CAR)
MACRO(CDR var junk)
SET(${var} ${ARGN})
ENDMACRO(CDR)
MACRO(LIST_INDEX var index)
SET(list . ${ARGN})
FOREACH(i RANGE 1 ${index})
CDR(list ${list})
ENDFOREACH(i)
CAR(${var} ${list})
ENDMACRO(LIST_INDEX)
######### LIST_CONTAINS usage
#SET(MYLIST hello world foo bar)
#LIST_CONTAINS(contains foo ${MYLIST})
#IF (contains)
# MESSAGE("MYLIST contains foo")
#ENDIF (contains)
#LIST_CONTAINS(contains baz ${MYLIST})
#IF (NOT contains)
# MESSAGE("MYLIST does not contain baz")
#ENDIF (NOT contains)
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF (${value} STREQUAL ${value2})
ENDFOREACH (value2)
ENDMACRO(LIST_CONTAINS)
############################################################
################### macros from http://www.cmake.org/Wiki/CMakeMacroParseArguments
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
#MESSAGE("!!!! ${prefix} args-->${arg_names}<-- opt-->${option_names}<--")
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
#debug#MESSAGE("---->${arg}<------")
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name)
LIST_CONTAINS(is_option ${arg} ${option_names})
IF (is_option)
SET(${prefix}_${arg} TRUE)
ELSE (is_option)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option)
ENDIF (is_arg_name)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
#############################################################
#MACRO(SHOW_USAGE_OF_PARSE_ARGUMENTS)
# PARSE_ARGUMENTS(PLUGIN
# "EXPORTS;AUTOLOAD_SCRIPTS;LINK_LIBRARIES;DEPENDS"
# "AUTO_INSTALL;NO_MODULE"
# ${ARGN}
# )
# CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
# CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
#
# MESSAGE("*** Arguments for ${PLUGIN_NAME}")
# MESSAGE("Sources: ${PLUGIN_SOURCES}")
# MESSAGE("Exports: ${PLUGIN_EXPORTS}")
# MESSAGE("Autoload scripts: ${PLUGIN_AUTOLOAD_SCRIPTS}")
# MESSAGE("Link libraries: ${PLUGIN_LINK_LIBRARIES}")
# MESSAGE("Depends: ${PLUGIN_DEPENDS}")
# IF (PLUGIN_AUTO_INSTALL)
# MESSAGE("Auto install")
# ENDIF (PLUGIN_AUTO_INSTALL)
# IF (PLUGIN_NO_MODULE)
# MESSAGE("No module")
# ENDIF (PLUGIN_NO_MODULE)
#ENDMACRO(SHOW_USAGE_OF_PARSE_ARGUMENTS)
#examples
#SHOW_USAGE_OF_PARSE_ARGUMENTS(MyAppCore NO_MODULE CoreSource1.cxx CoreSource2.cxx EXPORTS RequiredObject1 RequredObject2 AUTOLOAD_SCRIPTS startup.py initialize.py)
#SHOW_USAGE_OF_PARSE_ARGUMENTS(MyAppDefaultComponents
# Component1.cxx Component2.cxx
# EXPORTS Component1 Component2
# DEPENDS MyAppCore
# AUTO_INSTALL
# )
########################################################

View File

@ -0,0 +1,28 @@
# INSTALL and SOURCE_GROUP commands for OSG/OT/Producer Modules
# Required Vars:
# ${LIB_NAME}
# ${LIB_PUBLIC_HEADERS}
SET(INSTALL_BINDIR bin)
SET(INSTALL_INCDIR include)
SET(INSTALL_LIBDIR lib)
SET(HEADERS_GROUP "Header Files")
SOURCE_GROUP(
${HEADERS_GROUP}
FILES ${LIB_PUBLIC_HEADERS}
)
INSTALL(
TARGETS ${LIB_NAME}
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
)
# FIXME: Do not run for OS X framework
INSTALL(
FILES ${LIB_PUBLIC_HEADERS}
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
)

View File

@ -0,0 +1,269 @@
INCLUDE(UtilityMacros)
#---------------------------------------------------
# ADD_OSG_LIB ( SUBDIR )
# collects source files from given subdir and generates a shared library from them
# additional parameters specify symbols, link libraries and omited files
# begin these with keyword DEFINE LINK or EXCLUDE
# e.g. ADD_OSG_LIB( osgDB DEFINE OSGDB_EXPORT LINK osg EXCLUDE osg_mac.cxx )
# if OSG_PROJECT_LABEL_PREFIX is defined the project label is augmented with prefix
#---------------------------------------------------
MACRO(ADD_OSG_LIB SUBDIR EXPORTDEF)
#MESSAGE(STATUS "=== ADD_OSG_LIB ${SUBDIR}")
MACRO_MESSAGE("---source dir -->${OPENSCENEGRAPH_DIR}/src/${SUBDIR}<---")
SET(TARGET_NAME ${SUBDIR})
FILE(GLOB SRC_FILES ${OPENSCENEGRAPH_DIR}/src/${SUBDIR}/*.cpp)
#FILE(GLOB H_FILES ${OPENSCENEGRAPH_DIR}/include/${SUBDIR}/*)
GET_HEADERS_EXTENSIONLESS("${OPENSCENEGRAPH_DIR}/include/${SUBDIR}" "*" H_FILES)
#patch luigi osgwrapper FILE(GLOB SRC_FILES_SUB ${OPENSCENEGRAPH_DIR}/src/${SUBDIR}/*/*.cpp)
#patch luigi osgwrapper SET(SRC_FILES ${SRC_FILES} ${SRC_FILES_SUB})
#-- extract link files, defines, exclude files form additional arguments
SET(LISTNAME "TEMP")
SET(DEFSTR "")
#--- parse remaining args
FOREACH(ARG ${ARGN})
#MESSAGE(STATUS "+ [${ARG}]")
# if we find our keywords set the active list to given keyname
STRING(COMPARE EQUAL "${ARG}" "LINK" IS_LINK)
STRING(COMPARE EQUAL "${ARG}" "DEFINE" IS_DEFINE)
STRING(COMPARE EQUAL "${ARG}" "EXCLUDE" IS_EXCLUDE)
#MESSAGE(STATUS "STRSTUFF L ${IS_LINK} D ${IS_DEFINE} E ${IS_EXCLUDE}")
#--- check for label change
SET(LIST_CHANGED ${IS_LINK} OR ${IS_DEFINE} OR ${IS_EXCLUDE})
IF(${LIST_CHANGED})
SET(${LISTNAME} ${CURRLIST}) # in this case change the current list
#MESSAGE(STATUS "STORED LIST [${LISTNAME}] = (${CURRLIST})")
SET(LISTNAME ${ARG}) # new list name
REMOVE(CURRLIST ${CURRLIST} ) # clear current list
ELSE(${LIST_CHANGED})
SET(CURRLIST ${CURRLIST} ${ARG}) # otherwise just add current entry to current list
ENDIF(${LIST_CHANGED})
ENDFOREACH(ARG)
SET(${LISTNAME} ${CURRLIST}) # copy current list to active list
#MESSAGE(STATUS "STORED LIST [${LISTNAME}] = (${CURRLIST})")
REMOVE(CURRLIST ${CURRLIST} ) # clear current list
#MESSAGE(STATUS "AFTER: EXC (${EXCLUDE}) DEF (${DEFINE}) LINK (${LINK})")
#--- exclude files from exclude list
FOREACH(EXF ${EXCLUDE})
REMOVE(SRC_FILES ${OPENSCENEGRAPH_DIR}/src/${SUBDIR}/${EXF})
ENDFOREACH(EXF)
SOURCE_GROUP("Header Files" FILES ${H_FILES})
SET_SOURCE_FILES_PROPERTIES(${H_FILES} PROPERTIES HEADER_FILE_ONLY ON)
#--- add symbols, first assemble string with multiple /D "symbol" entries
FOREACH(DEF ${DEFINE})
IF(WIN32)
SET(DEFSTR "${DEFSTR} /D \"${DEF}\"")
#MESSAGE(STATUS "add symbol : " ${DEF})
ENDIF(WIN32)
IF(UNIX)
SET(DEFSTR "${DEFSTR} -D\"${DEF}\"")
#MESSAGE(STATUS "add symbol : " ${DEF})
ENDIF(UNIX)
ENDFOREACH(DEF)
IF(NOT DEFSTR STREQUAL "") # then set defines
SET_SOURCE_FILES_PROPERTIES(${SRC_FILES} PROPERTIES COMPILE_FLAGS ${DEFSTR})
#MESSAGE(STATUS "********* ADD COMPILE FLAGS ${DEFSTR} **********")
ENDIF(NOT DEFSTR STREQUAL "")
#--- add library with given name
ADD_LIBRARY(${TARGET_NAME} SHARED ${SRC_FILES} ${H_FILES})
SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES DEFINE_SYMBOL "${EXPORTDEF}" PROJECT_LABEL "${OSG_PROJECT_LABEL_PREFIX} ${TARGET_NAME}")
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LINK})
#speed#TARGET_LOCATIONS_ACCUM(${TARGET_NAME})
REMOVE(DEFINE ${DEFINE})
REMOVE(LINK ${LINK})
REMOVE(EXCLUDE ${EXCLUDE})
#old form# INSTALL_TARGETS(/lib ${TARGET_NAME} )
INSTALL(TARGETS ${TARGET_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
INSTALL(FILES ${H_FILES} DESTINATION include/${TARGET_NAME} )
ENDMACRO(ADD_OSG_LIB)
MACRO(ADD_OSG_APP SUBDIR)
SET(TARGET "${SUBDIR}_app")
FILE(GLOB APP_SRC ${OPENSCENEGRAPH_DIR}/applications/${SUBDIR}/*.cpp)
FILE(GLOB APP_H ${OPENSCENEGRAPH_DIR}/applications/${SUBDIR}/*.h)
ADD_EXECUTABLE(${TARGET} ${APP_SRC} ${APP_H})
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${SUBDIR})
MESSAGE(STATUS "adding osg app ${TARGET}")
#orig#TARGET_LINK_LIBRARIES(${TARGET} osg osgDB osgUtil osgProducer ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
# IF(UNIX)
# MESSAGE("so no qui!!!!!!!!!!")
FOREACH(LINKLIB osg osgDB osgGA osgUtil osgText OpenThreads ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
IF(${LINKLIB} MATCHES "osg")
#MESSAGE("TARGET_LINK_LIBRARIES(${TARGET} ${LINKLIB}")
TARGET_LINK_LIBRARIES(${TARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ELSE(${LINKLIB} MATCHES "osg")
IF(${LINKLIB} MATCHES "Producer")
#MESSAGE("TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
TARGET_LINK_LIBRARIES(${TARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ELSE(${LINKLIB} MATCHES "Producer")
IF(${LINKLIB} MATCHES "OpenThreads")
#MESSAGE("TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
IF(MSVC)
TARGET_LINK_LIBRARIES(${TARGET} optimized "${LINKLIB}Win32" debug "${LINKLIB}Win32d" )
ELSE(MSVC)
TARGET_LINK_LIBRARIES(${TARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(MSVC)
ELSE(${LINKLIB} MATCHES "OpenThreads")
#MESSAGE("EXTERNAL LIB:TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB} )
ENDIF(${LINKLIB} MATCHES "OpenThreads")
ENDIF(${LINKLIB} MATCHES "Producer")
ENDIF(${LINKLIB} MATCHES "osg")
ENDFOREACH(LINKLIB)
# ELSE(UNIX)
# TARGET_LINK_LIBRARIES(${TARGET} osg osgDB osgUtil osgProducer ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
# ENDIF(UNIX)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES PROJECT_LABEL "Application ${TARGET}")
SET_TARGET_PROPERTIES(${MYTARGET} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
#speed#TARGET_LOCATIONS_ACCUM(${TARGET})
MESSAGE(STATUS "install_target->${TARGET}<--")
#old form#INSTALL_TARGETS(/bin ${TARGET} )
INSTALL(TARGETS ${TARGET} RUNTIME DESTINATION bin )
ENDMACRO(ADD_OSG_APP)
MACRO(ADD_OSG_EXAMPLE SUBDIR)
#PROJECT("Example_${SUBDIR}")
SET(MYTARGET ${SUBDIR}_example)
FILE(GLOB EXAMPLE_SRC ${OPENSCENEGRAPH_EXAMPLE_DIR}/${SUBDIR}/*.cpp)
FILE(GLOB EXAMPLE_H ${OPENSCENEGRAPH_EXAMPLE_DIR}/${SUBDIR}/*.h)
IF(NOT EXAMPLE_SRC)
MESSAGE("Example_${SUBDIR}")
ELSE(NOT EXAMPLE_SRC)
ADD_EXECUTABLE(${MYTARGET} ${EXAMPLE_SRC} ${EXAMPLE_H})
ENDIF(NOT EXAMPLE_SRC)
SET_TARGET_PROPERTIES(${MYTARGET} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
SET_TARGET_PROPERTIES(${MYTARGET} PROPERTIES OUTPUT_NAME ${SUBDIR})
#IF(UNIX)
# MESSAGE("so no qui!!!!!!!!!!")
FOREACH(LINKLIB osg osgDB osgUtil osgViewer osgText osgGA OpenThreads ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
IF(${LINKLIB} MATCHES "osg")
#MESSAGE("TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
TARGET_LINK_LIBRARIES(${MYTARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ELSE(${LINKLIB} MATCHES "osg")
IF(${LINKLIB} MATCHES "Producer")
#MESSAGE("TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
TARGET_LINK_LIBRARIES(${MYTARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ELSE(${LINKLIB} MATCHES "Producer")
IF(${LINKLIB} MATCHES "OpenThreads")
#MESSAGE("TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
IF(MSVC)
#change in name from standar VS projects TARGET_LINK_LIBRARIES(${MYTARGET} optimized "${LINKLIB}Win32" debug "${LINKLIB}Win32d" )
TARGET_LINK_LIBRARIES(${MYTARGET} optimized "${LINKLIB}" debug "${LINKLIB}d" )
ELSE(MSVC)
TARGET_LINK_LIBRARIES(${MYTARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(MSVC)
ELSE(${LINKLIB} MATCHES "OpenThreads")
#MESSAGE("EXTERNAL LIB:TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB}")
TARGET_LINK_LIBRARIES(${MYTARGET} ${LINKLIB} )
ENDIF(${LINKLIB} MATCHES "OpenThreads")
ENDIF(${LINKLIB} MATCHES "Producer")
ENDIF(${LINKLIB} MATCHES "osg")
ENDFOREACH(LINKLIB)
#ELSE(UNIX)
# TARGET_LINK_LIBRARIES(${MYTARGET} osg osgDB osgUtil osgProducer ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
#ENDIF(UNIX)
SET_TARGET_PROPERTIES(${MYTARGET} PROPERTIES PROJECT_LABEL "Example ${SUBDIR}")
#speed#TARGET_LOCATIONS_ACCUM(${MYTARGET})
#MESSAGE(STATUS "adding osg example ${MYTARGET}")
##INSTALL_TARGETS(/bin ${MYTARGET} )
INSTALL(TARGETS ${MYTARGET} RUNTIME DESTINATION bin )
ENDMACRO(ADD_OSG_EXAMPLE)
#---------------------------------------------------
# MACRO GET_TARGETNAME SUBDIR RESULT
# generates a plugin target name for given SUBDIR and sets RESULT accordingly
# e.g. GET_TARGETNAME(osg OSG_TARGET) -> OSG_TARGET is osgdb_osg
MACRO(GET_TARGETNAME SUBDIR RESULT)
SET(${RESULT} osgdb_${SUBDIR})
ENDMACRO(GET_TARGETNAME)
#---------------------------------------------------
# MACRO ADD_OSG_PLUGIN SUBDIR [additional libs to link to]
# adds a plugin project for given SUBDIR, links libraries given as additional arguments
# e.g. ADD_OSG_PLUGIN(osg osgSim) -> generates is osgdb_osg and links with osgSim
MACRO(ADD_OSG_PLUGIN SUBDIR)
GET_TARGETNAME(${SUBDIR} TARGET)
FILE(GLOB PLUGIN_SRC ${OPENSCENEGRAPH_DIR}/src/osgPlugins/${SUBDIR}/*.cpp)
FILE(GLOB PLUGIN_H ${OPENSCENEGRAPH_DIR}/src/osgPlugins/${SUBDIR}/*.h)
#ADD_LIBRARY(${TARGET} SHARED ${PLUGIN_SRC} ${PLUGIN_H})
ADD_LIBRARY(${TARGET} MODULE ${PLUGIN_SRC} ${PLUGIN_H})
IF(NOT MSVC)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES DEBUG_POSTFIX "")
ENDIF(NOT MSVC)
FOREACH(LINKLIB osg osgDB osgUtil ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
IF(${LINKLIB} MATCHES "osg")
#MESSAGE("TARGET_LINK_LIBRARIES(${TARGET} optimized ${LINKLIB}")
TARGET_LINK_LIBRARIES(${TARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ELSE(${LINKLIB} MATCHES "osg")
TARGET_LINK_LIBRARIES(${TARGET} ${LINKLIB})
ENDIF(${LINKLIB} MATCHES "osg")
ENDFOREACH(LINKLIB)
#ELSE(UNIX)
# SET_TARGET_PROPERTIES(${TARGET} PROPERTIES PROJECT_LABEL "osgPlugin ${SUBDIR}")
# TARGET_LINK_LIBRARIES(${TARGET} osg osgDB osgUtil ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
#ENDIF(UNIX)
#speed#TARGET_LOCATIONS_ACCUM(${TARGET})
#old_form#INSTALL_TARGETS(/lib ${TARGET} )
INSTALL(TARGETS ${TARGET} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION bin )
ENDMACRO(ADD_OSG_PLUGIN)
MACRO(ADD_OSG_PLUGIN_EXTERN SOURCE_DIR _TARGET)
FILE(GLOB PLUGIN_SRC ${SOURCE_DIR}/*.cpp)
FILE(GLOB PLUGIN_H ${SOURCE_DIR}/*.h)
#ADD_LIBRARY(${TARGET} SHARED ${PLUGIN_SRC} ${PLUGIN_H})
ADD_LIBRARY(${_TARGET} MODULE ${PLUGIN_SRC} ${PLUGIN_H})
IF(UNIX)
SET_TARGET_PROPERTIES(${_TARGET} PROPERTIES DEBUG_POSTFIX "")
ENDIF(UNIX)
FOREACH(LINKLIB osg osgDB osgUtil ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
IF(${LINKLIB} MATCHES "osg")
#MESSAGE("TARGET_LINK_LIBRARIES(${TARGET} optimized ${LINKLIB}")
TARGET_LINK_LIBRARIES(${_TARGET} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ELSE(${LINKLIB} MATCHES "osg")
TARGET_LINK_LIBRARIES(${_TARGET} ${LINKLIB})
ENDIF(${LINKLIB} MATCHES "osg")
ENDFOREACH(LINKLIB)
#ELSE(UNIX)
# SET_TARGET_PROPERTIES(${TARGET} PROPERTIES PROJECT_LABEL "osgPlugin ${SUBDIR}")
# TARGET_LINK_LIBRARIES(${TARGET} osg osgDB osgUtil ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5})
#ENDIF(UNIX)
#speed#TARGET_LOCATIONS_ACCUM(${_TARGET})
##INSTALL_TARGETS(/lib ${_TARGET} )
INSTALL(TARGETS ${_TARGET} RUNTIME DESTINATION bin )
ENDMACRO(ADD_OSG_PLUGIN_EXTERN)

View File

@ -0,0 +1,180 @@
INCLUDE(ListHandle)
MACRO(FILTER_OUT FILTERS INPUTS OUTPUT)
# Mimicks Gnu Make's $(filter-out) which removes elements
# from a list that match the pattern.
# Arguments:
# FILTERS - list of patterns that need to be removed
# INPUTS - list of inputs that will be worked on
# OUTPUT - the filtered list to be returned
#
# Example:
# SET(MYLIST this that and the other)
# SET(FILTS this that)
#
# FILTER_OUT("${FILTS}" "${MYLIST}" OUT)
# MESSAGE("OUTPUT = ${OUT}")
#
# The output -
# OUTPUT = and;the;other
#
SET(FOUT "")
FOREACH(INP ${INPUTS})
SET(FILTERED 0)
FOREACH(FILT ${FILTERS})
IF(${FILTERED} EQUAL 0)
IF("${FILT}" STREQUAL "${INP}")
SET(FILTERED 1)
ENDIF("${FILT}" STREQUAL "${INP}")
ENDIF(${FILTERED} EQUAL 0)
ENDFOREACH(FILT ${FILTERS})
IF(${FILTERED} EQUAL 0)
SET(FOUT ${FOUT} ${INP})
ENDIF(${FILTERED} EQUAL 0)
ENDFOREACH(INP ${INPUTS})
SET(${OUTPUT} ${FOUT})
ENDMACRO(FILTER_OUT FILTERS INPUTS OUTPUT)
MACRO(GET_HEADERS_EXTENSIONLESS DIR GLOB_PATTERN OUTPUT)
FILE(GLOB TMP "${DIR}/${GLOB_PATTERN}" )
#FOREACH(F ${TMP})
# MESSAGE(STATUS "header-->${F}<--")
#ENDFOREACH(F ${TMP})
FILTER_OUT("${DIR}/CVS" "${TMP}" TMP)
FILTER_OUT("${DIR}/cvs" "${TMP}" ${OUTPUT})
FILTER_OUT("${DIR}/.svn" "${TMP}" ${OUTPUT})
ENDMACRO(GET_HEADERS_EXTENSIONLESS DIR GLOB_PATTERN OUTPUT)
MACRO(ADD_DIRS_TO_ENV_VAR _VARNAME )
FOREACH(_ADD_PATH ${ARGN})
FILE(TO_NATIVE_PATH ${_ADD_PATH} _ADD_NATIVE)
#SET(_CURR_ENV_PATH $ENV{PATH})
#LIST(SET _CURR_ENV_PATH ${_ADD_PATH})
#SET(ENV{PATH} ${_CURR_ENV_PATH})${_FILE}
IF(WIN32)
SET(ENV{${_VARNAME}} "$ENV{${_VARNAME}};${_ADD_NATIVE}")
ELSE(WIN32)
SET(ENV{${_VARNAME}} "$ENV{${_VARNAME}}:${_ADD_NATIVE}")
ENDIF(WIN32)
#MESSAGE(" env ${_VARNAME} --->$ENV{${_VARNAME}}<---")
ENDFOREACH(_ADD_PATH)
ENDMACRO(ADD_DIRS_TO_ENV_VAR _VARNAME )
#---------------------------------------------------
# MACRO CORRECT_PATH VAR PATH
# corrects slashes in PATH to be cmake conformous ( / )
# and puts result in VAR
#---------------------------------------------------
MACRO(CORRECT_PATH VAR PATH)
SET(${VAR} ${PATH})
IF(WIN32)
STRING(REGEX REPLACE "/" "\\\\" ${VAR} "${PATH}")
ENDIF(WIN32)
ENDMACRO(CORRECT_PATH)
MACRO(TARGET_LOCATIONS_SET_FILE FILE)
SET(ACCUM_FILE_TARGETS ${FILE})
FILE(WRITE ${ACCUM_FILE_TARGETS} "")
ENDMACRO(TARGET_LOCATIONS_SET_FILE FILE)
MACRO(TARGET_LOCATIONS_ACCUM TARGET_NAME)
IF(ACCUM_FILE_TARGETS)
IF(EXISTS ${ACCUM_FILE_TARGETS})
GET_TARGET_PROPERTY(_FILE_LOCATION ${TARGET_NAME} LOCATION)
FILE(APPEND ${ACCUM_FILE_TARGETS} "${_FILE_LOCATION};")
#SET(_TARGETS_LIST ${_TARGETS_LIST} "${_FILE_LOCATION}" CACHE INTERNAL "lista dll")
#MESSAGE("adding target -->${TARGET_NAME}<-- file -->${_FILE_LOCATION}<-- to list -->${_TARGETS_LIST}<--")
#SET(ACCUM_FILE_TARGETS ${ACCUM_FILE_TARGETS} ${_FILE_LOCATION})
ENDIF(EXISTS ${ACCUM_FILE_TARGETS})
ENDIF(ACCUM_FILE_TARGETS)
ENDMACRO(TARGET_LOCATIONS_ACCUM TARGET_NAME)
MACRO(TARGET_LOCATIONS_GET_LIST _VAR)
IF(ACCUM_FILE_TARGETS)
IF(EXISTS ${ACCUM_FILE_TARGETS})
FILE(READ ${ACCUM_FILE_TARGETS} ${_VAR})
ENDIF(EXISTS ${ACCUM_FILE_TARGETS})
ENDIF(ACCUM_FILE_TARGETS)
ENDMACRO(TARGET_LOCATIONS_GET_LIST _VAR)
MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY SEARCHPATHLIST)
MESSAGE(STATUS "searching ${DEPNAME} -->${INCLUDEFILE}<-->${LIBRARY}<-->${SEARCHPATHLIST}<--")
SET(MY_PATH_INCLUDE )
SET(MY_PATH_LIB )
SET(MY_PATH_BIN )
FOREACH( MYPATH ${SEARCHPATHLIST} )
SET(MY_PATH_INCLUDE ${MY_PATH_INCLUDE} ${MYPATH}/include)
SET(MY_PATH_LIB ${MY_PATH_LIB} ${MYPATH}/lib)
SET(MY_PATH_BIN ${MY_PATH_BIN} ${MYPATH}/bin)
ENDFOREACH( MYPATH ${SEARCHPATHLIST} )
SET(MYLIBRARY "${LIBRARY}")
SEPARATE_ARGUMENTS(MYLIBRARY)
#MESSAGE( " include paths: -->${MY_PATH_INCLUDE}<--")
#MESSAGE( " ${DEPNAME}_INCLUDE_DIR --> ${${DEPNAME}_INCLUDE_DIR}<--")
FIND_PATH("${DEPNAME}_INCLUDE_DIR" ${INCLUDEFILE}
${MY_PATH_INCLUDE}
)
MARK_AS_ADVANCED("${DEPNAME}_INCLUDE_DIR")
#MESSAGE( " ${DEPNAME}_INCLUDE_DIR --> ${${DEPNAME}_INCLUDE_DIR}<--")
FIND_LIBRARY("${DEPNAME}_LIBRARY"
NAMES ${MYLIBRARY}
PATHS ${MY_PATH_LIB}
)
IF(${DEPNAME}_LIBRARY)
GET_FILENAME_COMPONENT(MYLIBNAME ${${DEPNAME}_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MYBINPATH ${${DEPNAME}_LIBRARY} PATH)
GET_FILENAME_COMPONENT(MYBINPATH ${MYBINPATH} PATH)
SET(MYBINPATH "${MYBINPATH}/bin")
IF(EXISTS ${MYBINPATH})
SET(MYFOUND 0)
FOREACH(MYPATH ${MY_ACCUM_BINARY_DEP})
IF(MYPATH MATCHES ${MYBINPATH})
SET(MYFOUND 1)
#MESSAGE("found -->${MYPATH}<-->${MYBINPATH}<--")
ENDIF(MYPATH MATCHES ${MYBINPATH})
ENDFOREACH(MYPATH )
IF(MYFOUND EQUAL 0)
SET(MY_ACCUM_BINARY_DEP ${MY_ACCUM_BINARY_DEP} ${MYBINPATH})
ENDIF(MYFOUND EQUAL 0)
ENDIF(EXISTS ${MYBINPATH})
#MESSAGE("${DEPNAME}_BINDEP searching -->${MYLIBNAME}${CMAKE_SHARED_MODULE_SUFFIX}<--in-->${MY_PATH_BIN}<--")
# FIND_FILE("${DEPNAME}_BINDEP"
# ${MYLIBNAME}${CMAKE_SHARED_MODULE_SUFFIX}
# PATHS ${MY_PATH_BIN}
# )
# FIND_LIBRARY("${DEPNAME}_BINDEP"
# NAMES ${MYLIBRARY}
# PATHS ${MY_PATH_BIN}
# )
ENDIF(${DEPNAME}_LIBRARY)
MARK_AS_ADVANCED("${DEPNAME}_LIBRARY")
#MESSAGE( " ${DEPNAME}_LIBRARY --> ${${DEPNAME}_LIBRARY}<--")
IF(${DEPNAME}_INCLUDE_DIR)
IF(${DEPNAME}_LIBRARY)
SET( ${DEPNAME}_FOUND "YES" )
SET( ${DEPNAME}_LIBRARIES ${${DEPNAME}_LIBRARY} )
ENDIF(${DEPNAME}_LIBRARY)
ENDIF(${DEPNAME}_INCLUDE_DIR)
ENDMACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY SEARCHPATHLIST)
#SET(MACRO_MESSAGE_DEBUG TRUE)
MACRO(MACRO_MESSAGE MYTEXT)
IF(MACRO_MESSAGE_DEBUG)
MESSAGE("in file -->${CMAKE_CURRENT_LIST_FILE}<-- line -->${CMAKE_CURRENT_LIST_LINE}<-- message ${MYTEXT}")
ELSE(MACRO_MESSAGE_DEBUG)
MESSAGE(STATUS "in file -->${CMAKE_CURRENT_LIST_FILE}<-- line -->${CMAKE_CURRENT_LIST_LINE}<-- message ${MYTEXT}")
ENDIF(MACRO_MESSAGE_DEBUG)
ENDMACRO(MACRO_MESSAGE MYTEXT)

118
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,118 @@
PROJECT(OSG_EXAMPLES)
SET(OSGCORE_BUNDLED TRUE)
IF(NOT OSGCORE_BUNDLED)
FIND_PACKAGE(OSGCORE)
IF(OSGCORE_FOUND)
INCLUDE(${OSGCORE_USE_FILE})
ELSE(OSGCORE_FOUND)
MESSAGE(ERROR "OSGCORE neeeded but NOT FOUND")
ENDIF(OSGCORE_FOUND)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../Macros)
ENDIF(NOT OSGCORE_BUNDLED)
SET(OPENSCENEGRAPH_EXAMPLE_DIR ${PROJECT_SOURCE_DIR})
INCLUDE(OsgMacroUtils)
#ADD_OSG_EXAMPLE( osgviewer )
ADD_OSG_EXAMPLE( osganimate osgSim )
ADD_OSG_EXAMPLE( osgautotransform )
ADD_OSG_EXAMPLE( osgbillboard )
ADD_OSG_EXAMPLE( osgblendequation osgGA)
ADD_OSG_EXAMPLE( osgcallback )
ADD_OSG_EXAMPLE( osgcamera )
ADD_OSG_EXAMPLE( osgcatch osgParticle)
#ADD_OSG_EXAMPLE( osgcegui )
ADD_OSG_EXAMPLE( osgclip )
#to add subject to find socket#ADD_OSG_EXAMPLE( osgcluster ${OSG_SOCKET_LIBS} )
ADD_OSG_EXAMPLE( osgcopy )
ADD_OSG_EXAMPLE( osgcubemap )
ADD_OSG_EXAMPLE( osgdelaunay osgGA)
ADD_OSG_EXAMPLE( osgdepthpartition )
ADD_OSG_EXAMPLE( osgdepthshadow osgShadow)
ADD_OSG_EXAMPLE( osgdistortion )
ADD_OSG_EXAMPLE( osgfadetext osgText)
ADD_OSG_EXAMPLE( osgforest osgGA)
ADD_OSG_EXAMPLE( osgfxbrowser osgFX osgGA)
ADD_OSG_EXAMPLE( osggeodemo osgGA)
ADD_OSG_EXAMPLE( osggeometry )
#to add subject to find Glut
#ADD_OSG_EXAMPLE( osgGLUTkeyboardmouse )
#ADD_OSG_EXAMPLE( osgGLUTsimple )
ADD_OSG_EXAMPLE( osghangglide )
ADD_OSG_EXAMPLE( osghud )
ADD_OSG_EXAMPLE( osgimpostor osgSim )
ADD_OSG_EXAMPLE( osgintersection osgSim)
ADD_OSG_EXAMPLE( osgintrospection osgIntrospection )
ADD_OSG_EXAMPLE( osgkeyboard osgFX )
ADD_OSG_EXAMPLE( osgkeyboardmouse osgFX )
ADD_OSG_EXAMPLE( osglauncher )
ADD_OSG_EXAMPLE( osglight )
ADD_OSG_EXAMPLE( osglightpoint osgSim )
ADD_OSG_EXAMPLE( osglogicop osgGA)
ADD_OSG_EXAMPLE( osglogo )
ADD_OSG_EXAMPLE( osgmanipulator osgManipulator )
ADD_OSG_EXAMPLE( osgmotionblur )
ADD_OSG_EXAMPLE( osgmovie osgGA)
ADD_OSG_EXAMPLE( osgmultiplecameras osgFX)
ADD_OSG_EXAMPLE( osgmultitexture )
ADD_OSG_EXAMPLE( osgoccluder osgGA)
ADD_OSG_EXAMPLE( osgpagedlod )
ADD_OSG_EXAMPLE( osgparametric )
ADD_OSG_EXAMPLE( osgparticle osgParticle)
ADD_OSG_EXAMPLE( osgparticleeffects osgParticle osgGA)
ADD_OSG_EXAMPLE( osgphotoalbum )
ADD_OSG_EXAMPLE( osgpick osgGA)
ADD_OSG_EXAMPLE( osgplanets osgGA)
ADD_OSG_EXAMPLE( osgpoints osgGA)
ADD_OSG_EXAMPLE( osgpointsprite )
ADD_OSG_EXAMPLE( osgprecipitation osgParticle)
ADD_OSG_EXAMPLE( osgprerender )
ADD_OSG_EXAMPLE( osgprerendercubemap )
ADD_OSG_EXAMPLE( osgreflect )
ADD_OSG_EXAMPLE( osgscalarbar osgSim )
ADD_OSG_EXAMPLE( osgscribe )
ADD_OSG_EXAMPLE( osgsequence )
ADD_OSG_EXAMPLE( osgshaders )
ADD_OSG_EXAMPLE( osgshaderterrain OpenThreads)
ADD_OSG_EXAMPLE( osgshadowtexture osgShadow)
ADD_OSG_EXAMPLE( osgshadow osgShadow)
ADD_OSG_EXAMPLE( osgshape )
ADD_OSG_EXAMPLE( osgsimple )
##################################################
#ADD_OSG_EXAMPLE( osgsimpleviewerXXX )
##################################################
ADD_OSG_EXAMPLE( osgsimplifier )
#IF(GDAL_FOUND)
# ADD_OSG_EXAMPLE( osgsimulation osgSim osgTerrain Producer osgGA)
#ENDIF(GDAL_FOUND)
ADD_OSG_EXAMPLE( osgslice )
ADD_OSG_EXAMPLE( osgspacewarp )
ADD_OSG_EXAMPLE( osgspheresegment osgSim osgParticle)
ADD_OSG_EXAMPLE( osgspotlight )
ADD_OSG_EXAMPLE( osgstereoimage )
ADD_OSG_EXAMPLE( osgteapot ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
ADD_OSG_EXAMPLE( osgtessellate)
ADD_OSG_EXAMPLE( osgtext osgText)
ADD_OSG_EXAMPLE( osgtexture1D )
ADD_OSG_EXAMPLE( osgtexture2D )
ADD_OSG_EXAMPLE( osgtexture3D )
ADD_OSG_EXAMPLE( osgtexturerectangle )
ADD_OSG_EXAMPLE( osgunittests )
ADD_OSG_EXAMPLE( osgvertexprogram )
ADD_OSG_EXAMPLE( osgvolume )
ADD_OSG_EXAMPLE( osgwindows )
#MESSAGE("---->${MY_EXAMPLE_LIST}<---------")
##########to get all the variables of Cmake
#GET_CMAKE_PROPERTY(MYVARS VARIABLES)
#FOREACH(myvar ${MYVARS})
# FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt
# "${myvar} -->${${myvar}}<-\n"
# )
#ENDFOREACH(myvar)

View File

@ -15,7 +15,7 @@ SUBDIRS(
osgTerrain
)
OPTION(BUILD_OSG_PLUGINS "Enable to build OSG Plugins" OFF)
OPTION(BUILD_OSG_PLUGINS "Enable to build OSG Plugins" ON)
IF (BUILD_OSG_PLUGINS)
ADD_SUBDIRECTORY(osgPlugins)
ENDIF(BUILD_OSG_PLUGINS)