set(ECLIPSE_VERISON "3.4" CACHE STRING "Set ECLIPSE_VERISON either of 3.2(Callisto) or 3.4(Ganymede)." )
set(GrxUI_ON_ECLIPSE_DIR ${OpenHRP_SOURCE_DIR}/GrxUIonEclipse-project-0.9.8)
set(DEFAULT_GRXUIRC_XML_VERSION "1.1")

set(GRXUIRC_XML_VERSION ${DEFAULT_GRXUIRC_XML_VERSION} CACHE STRING "If you change grxuirc.xml format, you should increment GRXUIRC_XML_VERSION.")

set(FIXED_CONFIGURE_COMMENT "# CMAKE generated file: DO NOT EDIT!
# Generated by \"Unix Makefiles\" Generator, CMake.
# If you want to enable the changes permanently, edit")


# GrxUI Preference Default Setting
if(CMAKE_INSTALL_PREFIX)
  STRING(REGEX REPLACE "\\\\" "/" CMAKE_INSTALL_PREFIX_TMP "${CMAKE_INSTALL_PREFIX}")
  STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX_TMP "${CMAKE_INSTALL_PREFIX_TMP}")
  set(PREFERENCE_PROJECT_DIR "${CMAKE_INSTALL_PREFIX_TMP}/share/OpenHRP-3.1/sample/project")
  set(PREFERENCE_SERVER_DIR "${CMAKE_INSTALL_PREFIX_TMP}/bin")
else()
  set(PREFERENCE_PROJECT_DIR "")
  set(PREFERENCE_SERVER_DIR "")
endif()
if(JYTHON_HOME)
  STRING(REGEX REPLACE "\\\\" "/" PREFERENCE_JYTHON_LIB "${JYTHON_HOME}")
  STRING(REGEX REPLACE "/$" "" PREFERENCE_JYTHON_LIB "${PREFERENCE_JYTHON_LIB}")
  set(PREFERENCE_JYTHON_LIB "${PREFERENCE_JYTHON_LIB}/Lib")
else()
  set(PREFERENCE_JYTHON_LIB "")
endif()
set(CONFIGURE_COMMENT "${FIXED_CONFIGURE_COMMENT} PreferenceInitializer.java.input.")
configure_file(${GrxUI_ON_ECLIPSE_DIR}/src/com/generalrobotix/ui/grxui/PreferenceInitializer.java.input ${GrxUI_ON_ECLIPSE_DIR}/src/com/generalrobotix/ui/grxui/PreferenceInitializer.java @ONLY)


# Copy jython.jar
if(JYTHON_JAR)
  configure_file(${JYTHON_JAR} ${GrxUI_ON_ECLIPSE_DIR}/jython.jar COPYONLY)
endif()

macro(configure_grxui_on_eclipse)
  set(depends_rtm_path "src/com/generalrobotix/ui/depends/rtm")
  set(CONFIGURE_COMMENT "${FIXED_CONFIGURE_COMMENT} ClockGeneratorRtm_impl.java.in.")
  CONFIGURE_FILE( ${GrxUI_ON_ECLIPSE_DIR}/${depends_rtm_path}/ClockGeneratorRtm_impl.java.in ${GrxUI_ON_ECLIPSE_DIR}/${depends_rtm_path}/ClockGeneratorRtm_impl.java )
  CONFIGURE_FILE( ${GrxUI_ON_ECLIPSE_DIR}/META-INF/MANIFEST.MF.in ${GrxUI_ON_ECLIPSE_DIR}/META-INF/MANIFEST.MF)
  CONFIGURE_FILE( ${GrxUI_ON_ECLIPSE_DIR}/classpath.in ${GrxUI_ON_ECLIPSE_DIR}/.classpath)
  CONFIGURE_FILE( ${GrxUI_ON_ECLIPSE_DIR}/plugin.xml.in ${GrxUI_ON_ECLIPSE_DIR}/plugin.xml)
  CONFIGURE_FILE( ${GrxUI_ON_ECLIPSE_DIR}/build.properties.in ${GrxUI_ON_ECLIPSE_DIR}/build.properties)
endmacro()


# Specific Eclipse version
set( ORG_ECLIPSE_UI_VERSION "")
set( ORG_ECLIPSE_CORE_RUNTIME_VERSION "")
set( ORG_ECLIPSE_CORE_RESOURCES_VERSION "")

if( ECLIPSE_VERISON STREQUAL "3.4")
  set( ORG_ECLIPSE_UI_VERSION ";bundle-version=\"3.4.2\"")
  set( ORG_ECLIPSE_CORE_RUNTIME_VERSION ";bundle-version=\"3.4.0\"")
  set( ORG_ECLIPSE_CORE_RESOURCES_VERSION ";bundle-version=\"3.4.2\"")
endif()

# Set OS_NAME
if(UNIX)
  set(OS_NAME linux)
endif(UNIX)
if(WIN32)
  set(OS_NAME windows)
endif(WIN32)

# Specific OpenRTM version

if( ${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION042} )
  set(rtm_stub_jar OpenRTM-aist-0.4.1.jar)
  set(ADDITIONAL_EXCLUDING "")
  set(EXT_TRIG_EXECUTION_CONTEXT_SERVICE "RTC.ExtTrigExecutionContextService")
  set(GRX_PATH_PLANNING_ALGORITHM_ITEM "<item class=\"com.generalrobotix.ui.item.GrxPathPlanningAlgorithmItem\"/>" )


  set(GRX_PATH_PLANNING_VIEW_PART "
      <view
            class=\"com.generalrobotix.ui.view.GrxPathPlanningViewPart\"
            id=\"com.generalrobotix.ui.view.GrxPathPlanningViewPart\"
            category=\"com.generalrobotix.ui.view\"
            name=\"%PathPlanningView.name\">
      </view>" )

  set(OPEN_EXPORT_PACKAGE " jp.go.aist.hrp.simulator.ModelLoaderPackage,
 jp.go.aist.rtm,
 jp.go.aist.rtm.RTC,
 jp.go.aist.rtm.RTC.SDOPackage,
 jp.go.aist.rtm.RTC.buffer,
 jp.go.aist.rtm.RTC.executionContext,
 jp.go.aist.rtm.RTC.log,
 jp.go.aist.rtm.RTC.port,
 jp.go.aist.rtm.RTC.port.publisher,
 jp.go.aist.rtm.RTC.util" )

 configure_grxui_on_eclipse()
elseif(${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION100} OR ${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION101} OR ${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION102} OR ${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION110})
  if(${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION100} OR ${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION101} OR ${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION102} )
    set(rtm_stub_jar OpenRTM-aist-1.0.0.jar)
  elseif(${OPENRTM_VERSION} STREQUAL ${OPENRTM_VERSION110})
    set(rtm_stub_jar OpenRTM-aist-1.1.0.jar)
  endif()
  set(ADDITIONAL_EXCLUDING "")
  set(EXT_TRIG_EXECUTION_CONTEXT_SERVICE "OpenRTM.ExtTrigExecutionContextService")
  set(GRX_PATH_PLANNING_ALGORITHM_ITEM "<item class=\"com.generalrobotix.ui.item.GrxPathPlanningAlgorithmItem\"/>" )
  set(GRX_PATH_PLANNING_VIEW_PART "
      <view
            class=\"com.generalrobotix.ui.view.GrxPathPlanningViewPart\"
            id=\"com.generalrobotix.ui.view.GrxPathPlanningViewPart\"
            category=\"com.generalrobotix.ui.view\"
            name=\"%PathPlanningView.name\">
      </view>" )
  set(OPEN_EXPORT_PACKAGE " jp.go.aist.hrp.simulator.ModelLoaderPackage")

  configure_grxui_on_eclipse()

else()
# Unsupported OPENRTM_VERSION configure
  set(rtm_stub_jar openrtmstubskel.jar)

# To set supported latest OPENRTM_VERSION
  set(ADDITIONAL_EXCLUDING "|com/generalrobotix/ui/view/GrxPathPlanning*.java|jp/**/*.java")
  set(EXT_TRIG_EXECUTION_CONTEXT_SERVICE "OpenRTM.ExtTrigExecutionContextService")
  set(GRX_PATH_PLANNING_ALGORITHM_ITEM "" )
  set(GRX_PATH_PLANNING_VIEW_PART "" )
  set(OPEN_EXPORT_PACKAGE " jp.go.aist.hrp.simulator.ModelLoaderPackage,
 RTM,
 jp.go.aist.openrtm.OpenRTM,
 jp.go.aist.openrtm.RTC" )
  add_subdirectory(rtmStubCorba)
  message(STATUS "OpenRTM version is ${OPENRTM_VERSION}. Generate Makefile compiles openrtmstubskel.jar.")

  configure_grxui_on_eclipse()
endif()

ADD_SUBDIRECTORY(corba)

# install(FILES vrml97.jar DESTINATION ${RELATIVE_JAVA_INSTALL_PATH})
