############################################################################### # Find OpenSG path and set Compiler/Linker flags ############################################################################### # the user can decide in the gui, for which version of OpenSG he wants to build inVrs: set (BUILD_FOR_OPENSG_VERSION "AUTO" CACHE STRING "Decide which version of OpenSG to build against. AUTO for autodetection, 1 for OpenSG-1.x, 2 for OpenSG-2.x" ) # the FindOpenSG script can use OPENSG_ROOT to find the correct location of OpenSG: set (OPENSG_ROOT "" CACHE STRING "The prefix of your OpenSG installation (e.g. /usr/local)" ) mark_as_advanced( OPENSG_ROOT ) ### SET OPENSG_VERSION ### if ( ${BUILD_FOR_OPENSG_VERSION} STREQUAL "AUTO" ) # try executing opensg2?-config: foreach ( _osgconfig "osg2-config" "osg-config" "osg1-config" ) get_filename_component( _osgconfig ${_osgconfig} PROGRAM) if ( _osgconfig ) execute_process ( COMMAND ${_osgconfig} "--version" RESULT_VARIABLE _exitcode OUTPUT_VARIABLE OPENSG_VERSION ) if ( _exitcode EQUAL 0 ) # success -> OPENSG_VERSION is set; osg-config does work set (OPENSG_BIN_EXECUTABLE ${_osgconfig}) break() endif ( _exitcode EQUAL 0 ) endif ( _osgconfig ) endforeach ( _osgconfig ) if ( NOT _exitcode EQUAL 0 ) message ( FATAL_ERROR "Could not determine OpenSG-Version automatically! Please set BUILD_FOR_OPENSG_VERSION..." ) endif ( NOT _exitcode EQUAL 0 ) string ( STRIP ${OPENSG_VERSION} OPENSG_VERSION) message (STATUS "OpenSG seems to be version ${OPENSG_VERSION}") elseif ( ${BUILD_FOR_OPENSG_VERSION} MATCHES "[12]" ) set (OPENSG_VERSION ${BUILD_FOR_OPENSG_VERSION} ) endif ( ${BUILD_FOR_OPENSG_VERSION} STREQUAL "AUTO" ) string(TOLOWER ${OPENSG_VERSION} OPENSG_VERSION ) # derive OPENSG_VERSION_MAJOR from OPENSG_VERSION: # the version strings "opensg-1.8", "1.8", "1.8.0", "1" all yield OPENSG_VERSION_MAJOR to be "1" string(REGEX REPLACE "(opensg-)?([1-9]).*" "\\2" OPENSG_VERSION_MAJOR ${OPENSG_VERSION}) ############################################################################### # Find OpenSG include path ############################################################################### # when building without inVRs, be careful! # (and look at inVRs/cmake/config.cmake for the corresponding code) if ( "${OPENSG_VERSION_MAJOR}" STREQUAL "1" ) message (STATUS "OpenSG version 1.x detected. Using old FindOpenSG script...") # OpenSG 1.x # use old script: find_package (OpenSG1 REQUIRED) else ( "${OPENSG_VERSION_MAJOR}" STREQUAL "1" ) # OpenSG 2.x (default) if ( NOT "" STREQUAL "$ENV{OPENSG_ROOT}" ) set (OPENSG_ROOT $ENV{OPENSG_ROOT} ) endif ( NOT "" STREQUAL "$ENV{OPENSG_ROOT}" ) # OPENSG_COMPONENTS is used for finding the OpenSG package, as # well as for calling osg2-config: set (OPENSG_COMPONENTS OSGBase OSGSystem OSGWindowGLUT OSGDrawable OSGUtil OSGGroup) # FindOpenSG for OpenSG2: find_package(OpenSG REQUIRED COMPONENTS ${OPENSG_COMPONENTS}) # split release and debug libraries in variables (as done in old script): #parse OpenSG_LIBRARY_DIRS: # the words "debug" and "optimized" signify that the following parts should go into the appropriate variable foreach(part ${OpenSG_LIBRARY_DIRS}) if ( ${part} STREQUAL "debug" ) set(__split_part OpenSG_LIBRARY_DIRS_DEBUG) elseif ( ${part} STREQUAL "optimized" ) set(__split_part OpenSG_LIBRARY_DIRS_RELEASE) else ( ${part} STREQUAL "optimized" ) set(${__split_part} ${${__split_part}} ${part}) endif ( ${part} STREQUAL "debug" ) endforeach(part) #parse OpenSG_LIBRARIES: # the words "debug" and "optimized" signify that the following parts should go into the appropriate variable foreach(part ${OpenSG_LIBRARIES}) if ( ${part} STREQUAL "debug" ) set(__split_part OpenSG_LIBRARIES_DEBUG) elseif ( ${part} STREQUAL "optimized" ) set(__split_part OpenSG_LIBRARIES_RELEASE) else ( ${part} STREQUAL "optimized" ) set(${__split_part} ${${__split_part}} ${part}) endif ( ${part} STREQUAL "debug" ) endforeach(part) if (WIN32) set (OpenSG_DEFINITIONS_DEBUG "/D WIN32 /D _LIB /D _DEBUG /D _WINDOWS /D _OSG_HAVE_CONFIGURED_H_ /D OSG_BUILD_DLL /D OSG_DEBUG /D OSG_WITH_GLUT /D OSG_WITH_GIF /D OSG_WITH_TIF /D OSG_WITH_JPG") set (OpenSG_DEFINITIONS_RELEASE "/D WIN32 /D _LIB /D _WINDOWS /D _OSG_HAVE_CONFIGURED_H_ /D OSG_BUILD_DLL /D OSG_WITH_GLUT /D OSG_WITH_GIF /D OSG_WITH_TIF /D OSG_WITH_JPG") endif (WIN32) endif ( "${OPENSG_VERSION_MAJOR}" STREQUAL "1" ) if ( "${OPENSG_VERSION_MAJOR}" STREQUAL "2" ) # Find BOOST headers needed for OpenSG2 find_package(Boost REQUIRED) message(STATUS "adding ${Boost_INCLUDE_DIR} to opensg2 include dirs") set(OpenSG_INCLUDE_DIRS ${OpenSG_INCLUDE_DIRS} ${Boost_INCLUDE_DIR}) endif("${OPENSG_VERSION_MAJOR}" STREQUAL "2" ) ############################################################################### # Set definition/includes/libs for OpenSG ############################################################################### set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenSG_DEFINITIONS_DEBUG}") set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OpenSG_DEFINITIONS_RELEASE}")