cmake_minimum_required(VERSION 2.6)
project(spcore)

set (SPCORE_MAJOR_VERSION 1)
set (SPCORE_RELEASE_VERSION 0)
set (SPCORE_EPOCH_VERSION 0)

set(spcore_SRCS
	${CUSTOM_INCLUDE_PATH}/spcore/baseobj.h
	${CUSTOM_INCLUDE_PATH}/spcore/component.h
	${CUSTOM_INCLUDE_PATH}/spcore/iterator.h
	${CUSTOM_INCLUDE_PATH}/spcore/pinimpl.h
	${CUSTOM_INCLUDE_PATH}/spcore/basetype.h
	${CUSTOM_INCLUDE_PATH}/spcore/basetypeimpl.h
	${CUSTOM_INCLUDE_PATH}/spcore/basictypes.h
	${CUSTOM_INCLUDE_PATH}/spcore/coreruntime.h
	${CUSTOM_INCLUDE_PATH}/spcore/pin.h
	${CUSTOM_INCLUDE_PATH}/spcore/module.h
	${CUSTOM_INCLUDE_PATH}/spcore/coreversion.h
	${CUSTOM_INCLUDE_PATH}/spcore/libimpexp.h
	${CUSTOM_INCLUDE_PATH}/spcore/conversion.h
	basictypesimpl.cpp
	coreruntimeimpl.cpp
	conversion.cpp
	commoncomponents.h
	timecomponents.h
	${CUSTOM_INCLUDE_PATH}/spcore/language.h
	language.cpp
	${CUSTOM_INCLUDE_PATH}/spcore/configuration.h
	configurationimpl.h
	${CUSTOM_INCLUDE_PATH}/spcore/paths.h
	pathsimpl.h
)

if (WIN32)
	set(spcore_SRCS ${spcore_SRCS} win32env.cpp)
endif(WIN32)

include_directories (${POCO_INCLUDE_DIRS})

#
# This library should always be shared because several
# plugings might use it.
#

add_library (spcore SHARED ${spcore_SRCS})

target_link_libraries(spcore ${POCO_LIBRARIES})

# libconfig
if(WIN32)
	include_directories("${CMAKE_SOURCE_DIR}/3rdparty/libconfig/")
	target_link_libraries(spcore libconfig)
else(WIN32)
	find_package(LibConfig REQUIRED)
	target_link_libraries(spcore ${LibConfig_LIBRARIES})
	include_directories(${LibConfig_INCLUDE_DIR})
endif(WIN32)


target_link_libraries(spcore ${Boost_THREAD_LIBRARY})
if (ENABLE_NLS)
	target_link_libraries(spcore ${LIBINTL_LIBRARIES})
endif(ENABLE_NLS)
target_link_libraries(spcore ${wxWidgets_LIBRARIES})

add_definitions(-DSPMAKING_DLL_SPCORE)
set_target_properties(spcore PROPERTIES 
	VERSION "${SPCORE_MAJOR_VERSION}.${SPCORE_RELEASE_VERSION}.${SPCORE_EPOCH_VERSION}"
	SOVERSION ${SPCORE_MAJOR_VERSION}
	)
INSTALL (TARGETS spcore RUNTIME DESTINATION ${LIBRUNTIMEDIR} LIBRARY DESTINATION ${LIBDIR})

IF(BUILD_TESTS)
	ADD_SUBDIRECTORY(tests)
ENDIF(BUILD_TESTS)

#####################################################################
# Doxygen
#####################################################################
IF(GENERATE_DOXYGEN)
	#get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
	#message("inc_dirs = ${inc_dirs}")

	# check if doxygen is even installed
	find_package(Doxygen)
	if (DOXYGEN_FOUND STREQUAL "NO")
		message(SEND_ERROR "Doxygen not found. Please get a copy http://www.doxygen.org")
	endif (DOXYGEN_FOUND STREQUAL "NO")

	# prepare doxygen configuration file
	configure_file(Doxyfile.in Doxyfile)

	# add doxygen as target
	add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

	# cleanup $build/api-doc on "make clean"
	set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES api-doc)

	# add doxygen as dependency to doc-target
	get_target_property(DOC_TARGET doc TYPE)
	if(NOT DOC_TARGET)
		add_custom_target(doc)
	endif()
	add_dependencies(doc doxygen)
ENDIF(GENERATE_DOXYGEN)
