cmake_minimum_required (VERSION 3.5)

SET (CMAKE_OSX_ARCHITECTURES "x86_64")
set (CMAKE_CXX_STANDARD 11)

project (Lgi)
set (LGI_VERSION_MAJOR 1)
set (LGI_VERSION_MINOR 0)

if (UNIX AND NOT APPLE)
	set(LINUX TRUE)
endif()

if (APPLE)

	add_definitions("-DMAC -DLGI_LIBRARY -D_DEBUG -DLGI_RES -DLGI_COCOA")
	# SET(GUI_TYPE MACOSX_BUNDLE)
	find_library(COCOA_LIBRARY Cocoa)
	mark_as_advanced (COCOA_LIBRARY)
	set(EXTRA_LIBS ${COCOA_LIBRARY})

elseif (LINUX)

	add_definitions("-DLINUX -DLGI_LIBRARY -D_DEBUG -DLGI_RES -fPIC -w -fno-inline -fpermissive")
	find_package(GTK2 COMPONENTS gtk)
	find_package(PkgConfig)
	pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4)
	                               
elseif (MSVC)

	add_definitions("/W2 -DWINDOWS -DWIN32 -DLGI_LIBRARY -D_DEBUG -DLGI_RES -D_WINDLL -D_UNICODE -DUNICODE")

endif ()

set (CommonSource
	src/common/Gdc2/15Bit.cpp
	src/common/Gdc2/16Bit.cpp
	src/common/Gdc2/24Bit.cpp
	src/common/Gdc2/32Bit.cpp
	src/common/Gdc2/64Bit.cpp
	src/common/Gdc2/8Bit.cpp
	src/common/Gdc2/Alpha.cpp
	src/common/Gdc2/Filters/GFilter.cpp
	src/common/Gdc2/Font/GDisplayString.cpp
	src/common/Gdc2/Font/LStringLayout.cpp
	src/common/Gdc2/Font/GFont.cpp
	src/common/Gdc2/Font/GFont_A.cpp
	src/common/Gdc2/Font/GFont_W.cpp
	src/common/Gdc2/Font/GFontCodePages.cpp
	src/common/Gdc2/Font/GFontSystem.cpp
	src/common/Gdc2/GColour.cpp
	src/common/Gdc2/GdcCommon.cpp
	src/common/Gdc2/GRect.cpp
	src/common/Gdc2/GSurface.cpp
	src/common/Gdc2/Path/GPath.cpp
	src/common/Gdc2/Tools/GColourReduce.cpp
	src/common/General/GContainers.cpp
	src/common/General/LDateTime.cpp
	src/common/General/GExeCheck.cpp
	src/common/General/GFileCommon.cpp
	src/common/General/GGrowl.cpp
	src/common/General/GPassword.cpp
	src/common/Hash/md5/md5.c
	src/common/Hash/sha1/sha1.c
	src/common/INet/Base64.cpp
	src/common/INet/GUri.cpp
	src/common/INet/INet.cpp
	src/common/INet/INetTools.cpp
	src/common/INet/MDStringToDigest.cpp
	src/common/Lgi/GAlert.cpp
	src/common/Lgi/GCss.cpp
	src/common/Lgi/GCssTools.cpp
	src/common/Lgi/GFindReplace.cpp
	src/common/Lgi/GFontSelect.cpp
	src/common/Lgi/GGuiUtils.cpp
	src/common/Lgi/GInput.cpp
	src/common/Lgi/GLibrary.cpp
	src/common/Lgi/GMemStream.cpp
	src/common/Lgi/GMru.cpp
	src/common/Lgi/LMutex.cpp
	src/common/Lgi/GObject.cpp
	src/common/Lgi/GOptionsFile.cpp
	src/common/Lgi/GProcess.cpp
	src/common/Lgi/GStream.cpp
	src/common/Lgi/LThreadCommon.cpp
	src/common/Lgi/LThreadEvent.cpp
	src/common/Lgi/GToolTip.cpp
	src/common/Lgi/GTrayIcon.cpp
	src/common/Lgi/GVariant.cpp
	src/common/Lgi/GViewCommon.cpp
	src/common/Lgi/GWindowCommon.cpp
	src/common/Lgi/LgiCommon.cpp
	src/common/Lgi/LgiMsg.cpp
	src/common/Lgi/LgiRand.cpp
	src/common/Lgi/LMenuCommon.cpp
	src/common/Resource/LgiRes.cpp
	src/common/Resource/Res.cpp
	src/common/Skins/Gel/Gel.cpp
	src/common/Text/GDocView.cpp
	src/common/Text/GString.cpp
	src/common/Text/GTextView3.cpp
	src/common/Text/GToken.cpp
	src/common/Text/GUnicode.cpp
	src/common/Text/GUtf8.cpp
	src/common/Text/GXmlTree.cpp
	src/common/Widgets/GBitmap.cpp
	src/common/Widgets/GBox.cpp
	src/common/Widgets/GItemContainer.cpp
	src/common/Widgets/LList.cpp
	src/common/Widgets/GPanel.cpp
	src/common/Widgets/GPopup.cpp
	src/common/Widgets/GProgressDlg.cpp
	src/common/Widgets/GSplitter.cpp
	src/common/Widgets/GStatusBar.cpp
	src/common/Widgets/GTableLayout.cpp
	src/common/Widgets/GTabView.cpp
	src/common/Widgets/GTextLabel.cpp
	src/common/Widgets/GToolBar.cpp	
	src/common/Widgets/GTree.cpp
	)

set (WindowsSource
	src/win32/Gdc2/Gdc2.cpp
	src/win32/Gdc2/GdiLeak.cpp
	src/win32/Gdc2/GMemDC.cpp
	src/win32/Gdc2/GPrintDC.cpp
	src/win32/Gdc2/GScreenDC.cpp
	src/win32/General/GFile.cpp
	src/win32/General/GMem.cpp
	src/win32/General/ShowFileProp_Win.cpp
	src/win32/INet/MibAccess.cpp
	src/win32/Lgi/GApp.cpp
	src/win32/Lgi/GClipBoard.cpp
	src/win32/Lgi/GDragAndDrop.cpp
	src/win32/Lgi/GFileSelect.cpp
	src/win32/Lgi/GGeneral.cpp
	src/win32/Lgi/GLayout.cpp
	src/win32/Lgi/LMenu.cpp
	src/win32/Lgi/GPrinter.cpp
	src/win32/Lgi/GScrollBar.cpp
	src/win32/Lgi/LThread.cpp
	src/win32/Lgi/GView.cpp
	src/win32/Lgi/GWindow.cpp
	src/win32/Lgi/LgiException.cpp
	src/win32/Widgets/GButton_Win.cpp
	src/win32/Widgets/GCheckBox_Win.cpp
	src/win32/Widgets/GCombo_Win.cpp
	src/win32/Widgets/GDialog.cpp
	src/win32/Widgets/GEdit_Win.cpp
	src/win32/Widgets/GRadioGroup_Win.cpp
	src/win32/Widgets/GSlider.cpp
	src/win32/Widgets/GProgress.cpp
	)


set (LinuxSource
	src/linux/Gtk/Gdc2.cpp
	src/linux/Gtk/GMemDC.cpp
	src/linux/Gtk/GPrintDC.cpp
	src/linux/Gtk/GScreenDC.cpp
	src/linux/Gtk/LgiWidget.cpp
	src/linux/General/GFile.cpp
	src/linux/General/GMem.cpp
	src/linux/General/ShowFileProp_Linux.cpp
	src/linux/Lgi/GApp.cpp
	src/linux/Lgi/GClipBoard.cpp
	src/linux/Lgi/GDragAndDrop.cpp
	src/linux/Lgi/GGeneral.cpp
	src/linux/Lgi/GLayout.cpp
	src/linux/Lgi/LMenu.cpp
	src/linux/Lgi/GPrinter.cpp
	src/linux/Lgi/LThread.cpp
	src/linux/Lgi/GView.cpp
	src/linux/Lgi/GWidgets.cpp
	src/linux/Lgi/GWindow.cpp
	src/common/Lgi/GFileSelect.cpp
	src/common/Widgets/GCheckBox.cpp
	src/common/Widgets/GEdit.cpp
	src/common/Widgets/GScrollBar.cpp
	src/common/Widgets/GCombo.cpp
	src/common/Widgets/GButton.cpp
	src/common/Widgets/GRadioGroup.cpp
	src/common/Widgets/GProgress.cpp
	)

set (MacSource
	src/common/Widgets/GCheckBox.cpp
	src/common/Widgets/GCombo.cpp
	src/common/Widgets/GScrollBar.cpp
	src/common/Widgets/GButton.cpp
	src/common/Widgets/GRadioGroup.cpp
	src/common/Widgets/GEdit.cpp
	src/common/Lgi/GLayout.cpp
	src/common/Widgets/GProgress.cpp
	src/mac/cocoa/General/ShowFileProp_Mac.mm
	src/mac/carbon/Gdc2/Gdc2.cpp
	src/mac/common/GMemDC.cpp
	src/mac/common/GPrintDC.cpp
	src/mac/common/GScreenDC.cpp
	src/mac/cocoa/General/GFile.mm
	src/mac/cocoa/General/GMem.mm
	src/mac/cocoa/Lgi/GApp.mm
	src/mac/cocoa/Lgi/GClipBoard.mm
	src/mac/cocoa/Lgi/GDragAndDrop.mm
	src/mac/cocoa/Lgi/GGeneral.mm
	src/mac/cocoa/Lgi/GFileSelect.mm
	src/mac/cocoa/Lgi/LMenu.mm
	src/mac/cocoa/Lgi/GPrinter.mm
	src/mac/cocoa/Lgi/LThread.mm
	src/mac/cocoa/Lgi/GView.mm
	src/mac/cocoa/Lgi/GWidgets.mm
	src/mac/cocoa/Lgi/GWindow.mm
	src/mac/cocoa/Lgi/LCocoaView.mm
	)

if (APPLE)
	set(Source ${CommonSource} ${MacSource})
elseif (LINUX)
	set(Source ${CommonSource} ${LinuxSource})
elseif (MSVC)
	set(Source ${CommonSource} ${WindowsSource})
endif ()

add_library(Lgi SHARED ${Source})

if (APPLE)
	target_include_directories(Lgi PUBLIC
		"include/mac/cocoa"
		"include/posix"
		"/opt/local/include"
		"${CMAKE_CURRENT_SOURCE_DIR}/../../../CodeLib/libpng"
		"${CMAKE_CURRENT_SOURCE_DIR}/../../../CodeLib/libpng/build"
		)
	target_link_libraries(Lgi ${EXTRA_LIBS})
	set(	OBJCPP_SOURCE
		src/common/Lgi/LgiCommon.cpp
		src/common/Lgi/GGuiUtils.cpp
		src/common/Gdc2/Font/GFontSystem.cpp
		src/common/Lgi/GProcess.cpp
		src/common/Lgi/GViewCommon.cpp
		src/common/Lgi/GTrayIcon.cpp
		src/common/Lgi/LgiMsg.cpp
		src/common/Widgets/GPopup.cpp
		src/mac/common/GMemDC.cpp
		src/mac/common/GScreenDC.cpp
		src/mac/cocoa/Lgi/GGeneral.cpp
		)
	set_source_files_properties(${OBJCPP_SOURCE} PROPERTIES 
                            COMPILE_FLAGS "-x objective-c++")
elseif (LINUX)
	target_include_directories(Lgi PUBLIC "include/linux/Gtk" "include/linux" ${GTK2_INCLUDE_DIRS} ${GST_INCLUDE_DIRS})
	target_link_libraries(Lgi ${GTK2_LIBRARIES} ${GST_LIBRARIES} magic)
elseif (MSVC)
	target_include_directories(Lgi PUBLIC "include/win32")
	target_link_libraries(	Lgi
							ComCtl32.lib
							Ws2_32.lib
							UxTheme.lib
							imm32.lib)
endif ()

target_include_directories (Lgi PUBLIC
							"include/common"
							${PNGLIB_INCLUDE_DIR}
							"${CMAKE_CURRENT_SOURCE_DIR}/../../../CodeLib/libiconv-1.14/include")



set_target_properties(Lgi PROPERTIES LINKER_LANGUAGE CXX)
