###############################################################################
# 
#  Copyright (2008) Alexander Stukowski
#
#  This file is part of OVITO (Open Visualization Tool).
#
#  OVITO is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  OVITO is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

# Enable precompiled headers when using the GCC compiler.
IF(OVITO_USE_PRECOMPILED_HEADERS AND CMAKE_COMPILER_IS_GNUCXX)
	INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ENDIF(OVITO_USE_PRECOMPILED_HEADERS AND CMAKE_COMPILER_IS_GNUCXX)

# This is needed to export the symbols in this shared library.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAKING_MODULE_CORE")

# The header files that need to be processed by the QT meta-object compiler.
SET(Core_MOC_HDRS
	actions/Action.h
	actions/ActionProxy.h
	actions/ActionManager.h
	actions/ApplyModifierAction.h
	actions/ViewportModeAction.h
	actions/stdactions/StdActions.h
	actions/stdactions/XFormSystemChooser.h

	data/CurrentSelectionProxy.h
	data/DataSet.h
	data/DataSetManager.h
	data/ObjectLoadStream.h
	data/ObjectSaveStream.h

	data/importexport/ImporterExporter.h
	data/importexport/ImportExportManager.h

	data/units/ParameterUnit.h
 
	gui/ApplicationManager.h
	gui/ColorPickerWidget.h
	gui/SpinnerWidget.h
	gui/RolloutContainer.h
	gui/ElidedTextLabel.h

	gui/mainwnd/MainFrame.h
	gui/mainwnd/MainMenu.h

	gui/dialogs/SettingsDialog.h
	gui/dialogs/HistoryFileDialog.h
	gui/dialogs/ImportFileDialog.h
	gui/dialogs/SaveImageFileDialog.h
	
	gui/panels/CommandPanel.h
	gui/panels/CreationCommandPage.h	
	gui/panels/UtilityCommandPage.h		
	gui/panels/modify/ModifyCommandPage.h	
	gui/panels/modify/ModifierStack.h	
	gui/panels/animation/AnimationSettingsDialog.h	
	gui/panels/animation/AnimationTimeSlider.h
	gui/panels/render/RenderCommandPage.h

	gui/properties/AffineTransformationPropertyUI.h
	gui/properties/BooleanControllerUI.h
	gui/properties/BooleanGroupBoxControllerUI.h	
	gui/properties/BooleanGroupBoxPropertyUI.h	
	gui/properties/BooleanPropertyUI.h
	gui/properties/BooleanActionPropertyUI.h
	gui/properties/BooleanRadioButtonPropertyUI.h
	gui/properties/ColorControllerUI.h
	gui/properties/ColorPropertyUI.h
	gui/properties/FilenamePropertyUI.h	
	gui/properties/FloatControllerUI.h
	gui/properties/FloatPropertyUI.h
	gui/properties/IntegerControllerUI.h
	gui/properties/IntegerPropertyUI.h	
	gui/properties/IntegerRadioButtonPropertyUI.h
	gui/properties/NumericalControllerUI.h
	gui/properties/NumericalPropertyUI.h
	gui/properties/ParameterUI.h
	gui/properties/PropertiesEditor.h
	gui/properties/PropertiesPanel.h
	gui/properties/RefTargetListParameterUI.h
	gui/properties/StringPropertyUI.h
	gui/properties/VariantComboBoxPropertyUI.h	
	gui/properties/SubObjectParameterUI.h
	gui/properties/VectorControllerUI.h
	gui/properties/Vector3PropertyUI.h

	plugins/Plugin.h
	plugins/NativePlugin.h
	plugins/PluginClass.h
	plugins/PluginManager.h

	plugins/autostart/AutoStart.h	

	plugins/branding/Branding.h
	plugins/branding/UIEventFilter.h	

	plugins/utility/UtilityPlugin.h

	reference/CloneHelper.h
	reference/CustomAttributesContainer.h
	reference/RefMaker.h
	reference/RefTarget.h
	reference/RefTargetListener.h

	rendering/RenderSettings.h
	rendering/RenderSettingsEditor.h
	rendering/FrameBuffer.h
	rendering/FrameBufferWidget.h	
	rendering/FrameBufferWindow.h		
	rendering/PluginRenderer.h
	
	rendering/previewrenderer/PreviewRenderer.h
	rendering/previewrenderer/PreviewRendererEditor.h

	scene/GroupNode.h
	scene/ObjectNode.h
	scene/SceneNode.h
	scene/SceneRoot.h
	scene/SelectionSet.h		
	
	scene/animation/AnimationSettings.h		
	scene/animation/AnimManager.h	
	scene/animation/AnimationTimeSpinner.h
	
	scene/animation/controller/Controller.h	
	scene/animation/controller/LookAtController.h	
	scene/animation/controller/StandardConstControllers.h	
	scene/animation/controller/StandardLinearControllers.h
	scene/animation/controller/StandardSplineControllers.h
	scene/animation/controller/TransformationController.h	

	scene/material/Material.h

	scene/objects/CreationMode.h
	scene/objects/ModifiedObject.h
	scene/objects/Modifier.h
	scene/objects/ModifierApplication.h
	scene/objects/PipelineFlowState.h
	scene/objects/SceneObject.h
	scene/objects/AbstractCameraObject.h
	
	scene/objects/geometry/MeshObject.h
	scene/objects/geometry/SimpleGeometryObject.h 

	scene/objects/shapes/ShapeObject.h
	scene/objects/shapes/SimpleShapeObject.h 

	undo/UndoManager.h

	utilities/PathManager.h	
	utilities/ProgressIndicator.h	

	viewport/DefaultSceneRenderer.h
	viewport/ViewportMenu.h
	viewport/ViewportConfiguration.h
	viewport/OpenGLShader.h		
	viewport/SceneRenderer.h
	viewport/Viewport.h
	viewport/ViewportGrid.h
	viewport/ViewportManager.h
	viewport/ViewportPanel.h
	viewport/Window3D.h
	viewport/Window3DContainer.h		
	
	viewport/input/MoveMode.h
	viewport/input/NavigationModes.h
	viewport/input/RotationMode.h
	viewport/input/ScalingMode.h
	viewport/input/SelectionMode.h
	viewport/input/ViewportInputHandler.h
	viewport/input/ViewportInputManager.h
	viewport/input/XFormManager.h
	viewport/input/XFormMode.h		

	viewport/snapping/GridSnappingProvider.h
	viewport/snapping/SnappingManager.h
	viewport/snapping/SnappingProvider.h
)

# The regular source files of this library.
SET(Core_SRCS
	actions/Action.cpp
	actions/ActionProxy.cpp
	actions/ActionManager.cpp
	actions/ViewportModeAction.cpp
	actions/ApplyModifierAction.cpp
	
	actions/stdactions/AnimationActions.cpp
	actions/stdactions/EditingActions.cpp
	actions/stdactions/FileActions.cpp
	actions/stdactions/ViewportActions.cpp
	actions/stdactions/XFormSystemChooser.cpp
	actions/stdactions/RenderingActions.cpp
	actions/stdactions/OptionsActions.cpp

	data/CurrentSelectionProxy.cpp
	data/DataSet.cpp
	data/DataSetManager.cpp	
	data/ObjectLoadStream.cpp
	data/ObjectSaveStream.cpp
	
	data/importexport/ImportExportManager.cpp		
	data/units/ParameterUnit.cpp		
	
	gui/ApplicationManager.cpp
	gui/ColorPickerWidget.cpp
	gui/SpinnerWidget.cpp
	gui/RolloutContainer.cpp

	gui/mainwnd/MainFrame.cpp
	gui/mainwnd/MainMenu.cpp
	 
	gui/dialogs/SettingsDialog.cpp
	gui/dialogs/HistoryFileDialog.cpp
	gui/dialogs/ImportFileDialog.cpp
	gui/dialogs/SaveImageFileDialog.cpp

	gui/panels/CommandPanel.cpp
	gui/panels/CreationCommandPage.cpp	
	gui/panels/UtilityCommandPage.cpp
	gui/panels/modify/ModifyCommandPage.cpp
	gui/panels/modify/ModifierStack.cpp
	gui/panels/animation/AnimationSettingsDialog.cpp	
	gui/panels/animation/AnimationTimeSlider.cpp
	gui/panels/render/RenderCommandPage.cpp

	gui/properties/AffineTransformationPropertyUI.cpp
	gui/properties/BooleanControllerUI.cpp
	gui/properties/BooleanGroupBoxControllerUI.cpp
	gui/properties/BooleanGroupBoxPropertyUI.cpp	
	gui/properties/BooleanPropertyUI.cpp
	gui/properties/BooleanActionPropertyUI.cpp	
	gui/properties/BooleanRadioButtonPropertyUI.cpp
	gui/properties/ColorControllerUI.cpp
	gui/properties/ColorPropertyUI.cpp
	gui/properties/FilenamePropertyUI.cpp
	gui/properties/FloatControllerUI.cpp
	gui/properties/FloatPropertyUI.cpp
	gui/properties/IntegerControllerUI.cpp
	gui/properties/IntegerPropertyUI.cpp
	gui/properties/IntegerRadioButtonPropertyUI.cpp
	gui/properties/NumericalControllerUI.cpp
	gui/properties/NumericalPropertyUI.cpp
	gui/properties/ParameterUI.cpp
	gui/properties/PropertiesEditor.cpp
	gui/properties/PropertiesPanel.cpp
	gui/properties/RefTargetListParameterUI.cpp
	gui/properties/StringPropertyUI.cpp
	gui/properties/VariantComboBoxPropertyUI.cpp
	gui/properties/SubObjectParameterUI.cpp
	gui/properties/VectorControllerUI.cpp
	gui/properties/Vector3PropertyUI.cpp

	plugins/Plugin.cpp
	plugins/NativePlugin.cpp
	plugins/PluginClass.cpp
	plugins/PluginClassDescriptor.cpp
	plugins/NativePluginClassDescriptor.cpp
	plugins/PluginManager.cpp
	
	plugins/autostart/AutoStart.cpp	
	plugins/branding/Branding.cpp	
	plugins/branding/AboutPanel.cpp
	plugins/utility/UtilityPlugin.cpp	
	
	reference/CloneHelper.cpp
	reference/CustomAttributesContainer.cpp
	reference/PropertyFieldDescriptor.cpp
	reference/RefMaker.cpp
	reference/RefTarget.cpp
	reference/RefTargetListener.cpp
	
	rendering/RenderSettings.cpp
	rendering/RenderSettingsEditor.cpp
	rendering/FrameBuffer.cpp
	rendering/FrameBufferWidget.cpp
	rendering/FrameBufferWindow.cpp
	rendering/PluginRenderer.cpp
	
	rendering/previewrenderer/PreviewRenderer.cpp
	rendering/previewrenderer/PreviewRendererEditor.cpp
	
	scene/GroupNode.cpp
	scene/ObjectNode.cpp
	scene/SceneNode.cpp
	scene/SceneRoot.cpp
	scene/SelectionSet.cpp		
	
	scene/animation/AnimationSettings.cpp		
	scene/animation/AnimManager.cpp	
	
	scene/animation/controller/Controller.cpp	
	scene/animation/controller/LookAtController.cpp	
	scene/animation/controller/StandardControllers.cpp	
	scene/animation/controller/TransformationController.cpp	

	scene/material/Material.cpp

	scene/objects/CreationMode.cpp
	scene/objects/ModifiedObject.cpp
	scene/objects/Modifier.cpp
	scene/objects/ModifierApplication.cpp
	scene/objects/PipelineFlowState.cpp
	scene/objects/SceneObject.cpp

	scene/objects/geometry/MeshObject.cpp
	scene/objects/geometry/SimpleGeometryObject.cpp 

	scene/objects/shapes/ShapeObject.cpp
	scene/objects/shapes/SimpleShapeObject.cpp 

	scene/bezier/BezierCurve.cpp
	scene/bezier/BezierPolygon.cpp
	scene/bezier/BezierShape.cpp

	undo/UndoManager.cpp

	utilities/PathManager.cpp	
	utilities/ProgressIndicator.cpp	

	viewport/DefaultSceneRenderer.cpp
	viewport/OpenGLInterface.cpp		
	viewport/OpenGLShader.cpp		
	viewport/SceneRenderer.cpp
	viewport/Viewport.cpp
	viewport/ViewportGrid.cpp
	viewport/ViewportManager.cpp
	viewport/ViewportMenu.cpp
	viewport/ViewportPanel.cpp
	viewport/ViewportConfiguration.cpp
	viewport/Window3D.cpp	
	viewport/Window3DContainer.cpp		
	viewport/Window3DHitTests.cpp	
	viewport/Window3DRender.cpp	
	
	viewport/input/MoveMode.cpp
	viewport/input/NavigationModes.cpp
	viewport/input/RotationMode.cpp
	viewport/input/ScalingMode.cpp
	viewport/input/SelectionMode.cpp
	viewport/input/ViewportInputHandler.cpp
	viewport/input/ViewportInputManager.cpp
	viewport/input/XFormManager.cpp
	viewport/input/XFormMode.cpp		

	viewport/snapping/GridSnappingProvider.cpp
	viewport/snapping/SnappingManager.cpp
	viewport/snapping/SnappingProvider.cpp
)

# Use the QT meta-object compiler to generate additional code.
QT4_WRAP_CPP(Core_MOC_SRCS ${Core_MOC_HDRS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)

# Include a resource file in the library.
QT4_ADD_RESOURCES(Core_RC_SRCS resources/core.qrc)

ADD_LIBRARY(Core
	PrecompiledHeader.cpp	 
	${Core_SRCS}
	${Core_MOC_SRCS}
	${Core_RC_SRCS}
)

# Generate precompiled header
IF(OVITO_USE_PRECOMPILED_HEADERS)
	IF(MSVC)
		SET_SOURCE_FILES_PROPERTIES(${Core_SRCS} PROPERTIES COMPILE_FLAGS "/Yucore/Core.h /Fpcore.pch")
		SET_SOURCE_FILES_PROPERTIES(PrecompiledHeader.cpp PROPERTIES COMPILE_FLAGS "/Yccore/Core.h /Fpcore.pch")
	ENDIF(MSVC)
	IF(CMAKE_COMPILER_IS_GNUCXX)
		ADD_PRECOMPILED_HEADER(Core ${CMAKE_SOURCE_DIR}/src/core/Core.h)  
	ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(OVITO_USE_PRECOMPILED_HEADERS)

TARGET_LINK_LIBRARIES(Core Base Mesh)

# Link the target against the Qt libraries. 
TARGET_LINK_LIBRARIES(Core ${QT_LIBRARIES})

# Link the target against the OpenGL library.
TARGET_LINK_LIBRARIES(Core ${OPENGL_gl_LIBRARY})

# Add Boost.Python libraries for scripting
IF(OVITO_BUILD_PLUGIN_SCRIPTING)
	TARGET_LINK_LIBRARIES(Core ${Boost_PYTHON_LIBRARY} ${PYTHON_UTIL_LIBRARY} ${PYTHON_LIBRARIES})
ENDIF(OVITO_BUILD_PLUGIN_SCRIPTING)

IF(NOT OVITO_MONOLITHIC_BUILD)
	# This library will be part of the installation package.
	INSTALL(TARGETS Core DESTINATION ${OVITO_RELATIVE_LIBRARY_DIRECTORY})
ENDIF(NOT OVITO_MONOLITHIC_BUILD)

# Copy the application icon into the application installation directory.
INSTALL(FILES "resources/main/window_icon.png" DESTINATION "${OVITO_RELATIVE_SHARE_DIRECTORY}" RENAME "ovito_icon.png")
