###############################################################################
# 
#  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_BASE")

# The header files that need to be processed by the QT meta-object compiler.
SET(Base_MOC_HDRS
	io/LoadStream.h
	io/SaveStream.h
)

# The regular source files of this library.
SET(Base_SRCS
	io/LoadStream.cpp 
	io/SaveStream.cpp 
	
	linalg/AffineDecomposition.cpp 
	linalg/Box2.cpp 
	linalg/Box3.cpp 
	linalg/AffineTransformation.cpp 
	linalg/Matrix3.cpp 
	linalg/Matrix4.cpp 
	linalg/Plane.cpp 
	linalg/Point3.cpp 
	linalg/Quaternion.cpp 
	linalg/Ray.cpp 
	linalg/Rotation.cpp 
	linalg/Scaling.cpp 	
	linalg/Tensor.cpp 
	linalg/Vector3.cpp 	
	
	utilities/Exception.cpp
	utilities/Logger.cpp	
)

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

# Create shared library.
ADD_LIBRARY(Base 
	PrecompiledHeader.cpp	 
	${Base_SRCS}
	${Base_MOC_SRCS}
)

# Generate precompiled header
IF(OVITO_USE_PRECOMPILED_HEADERS)
	IF(MSVC)
		SET_SOURCE_FILES_PROPERTIES(${Base_SRCS} PROPERTIES COMPILE_FLAGS "/Yubase/Base.h /Fpbase.pch")
		SET_SOURCE_FILES_PROPERTIES(PrecompiledHeader.cpp PROPERTIES COMPILE_FLAGS "/Ycbase/Base.h /Fpbase.pch")
	ENDIF(MSVC)
	IF(CMAKE_COMPILER_IS_GNUCXX)
		ADD_PRECOMPILED_HEADER(Base ${CMAKE_SOURCE_DIR}/src/base/Base.h)  
	ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(OVITO_USE_PRECOMPILED_HEADERS)

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

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

