# CMakeLists.txt for Irrlicht in STK
find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/"
                    "${JPEG_INCLUDE_DIR}"
                    "${PNG_INCLUDE_DIRS}"
                    "${ZLIB_INCLUDE_DIR}"
                    "${CMAKE_CURRENT_BINARY_DIR}/../zlib/") # For zconf.h on WIN32

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})

if(APPLE)
    include_directories("${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/MacOSX" "${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386 -F/Library/Frameworks")
endif()

add_definitions(-DNDEBUG=1 -DIRRLICHT_EXPORTS=1 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES)
if(MSVC)
  add_definitions(/D_IRR_STATIC_LIB_)
  add_definitions(/D_CRT_SECURE_NO_WARNINGS) # Shut up about unsafe stuff
elseif(MINGW)
  add_definitions(-D_IRR_STATIC_LIB_)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Shut up about unsafe stuff
else()
  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -pipe -O3  -fno-exceptions  -fstrict-aliasing -fexpensive-optimizations -I/usr/X11R6/include")
  set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Wall -pipe -O3  -fno-exceptions  -fstrict-aliasing -fexpensive-optimizations -I/usr/X11R6/include")
endif()

# Xrandr
if(UNIX AND USE_XRANDR)
    add_definitions(-DNO_IRR_LINUX_X11_VIDMODE_)
    add_definitions(-D_IRR_LINUX_X11_RANDR_)
endif()

if(CYGWIN)
    add_definitions(-DNO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
endif()

set(IRRLICHT_SOURCES
source/Irrlicht/CGUIListBox.cpp
source/Irrlicht/CZBuffer.cpp
source/Irrlicht/CGUIModalScreen.cpp
source/Irrlicht/CParticleCylinderEmitter.cpp
source/Irrlicht/CLimitReadFile.cpp
source/Irrlicht/CVideoModeList.cpp
source/Irrlicht/CDefaultGUIElementFactory.cpp
source/Irrlicht/CCubeSceneNode.cpp
source/Irrlicht/CGUIMeshViewer.cpp
source/Irrlicht/CParticleSphereEmitter.cpp
source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp
source/Irrlicht/CGUITabControl.cpp
source/Irrlicht/CGUIToolBar.cpp
source/Irrlicht/CTerrainTriangleSelector.cpp
source/Irrlicht/CFileSystem.cpp
source/Irrlicht/CTerrainSceneNode.cpp
source/Irrlicht/os.cpp
source/Irrlicht/CFPSCounter.cpp
source/Irrlicht/CGUIContextMenu.cpp
source/Irrlicht/CImageWriterJPG.cpp
source/Irrlicht/CZipReader.cpp
source/Irrlicht/CImageLoaderPNG.cpp
source/Irrlicht/CImageLoaderBMP.cpp
source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp
source/Irrlicht/CSkyDomeSceneNode.cpp
source/Irrlicht/CGUIFileOpenDialog.cpp
source/Irrlicht/CGUISpriteBank.cpp
source/Irrlicht/CParticleFadeOutAffector.cpp
source/Irrlicht/CGUIMenu.cpp
source/Irrlicht/CSphereSceneNode.cpp
source/Irrlicht/CImageWriterPNG.cpp
source/Irrlicht/CSceneNodeAnimatorFollowSpline.cpp
source/Irrlicht/CGUIMessageBox.cpp
source/Irrlicht/CParticleGravityAffector.cpp
source/Irrlicht/CGUISkin.cpp
source/Irrlicht/CBoneSceneNode.cpp
source/Irrlicht/COpenGLSLMaterialRenderer.cpp
source/Irrlicht/CParticleRotationAffector.cpp
source/Irrlicht/CTriangleBBSelector.cpp
source/Irrlicht/CGUIComboBox.cpp
source/Irrlicht/CSceneNodeAnimatorTexture.cpp
source/Irrlicht/COpenGLTexture.cpp
source/Irrlicht/COctreeSceneNode.cpp
source/Irrlicht/CWaterSurfaceSceneNode.cpp
source/Irrlicht/CParticleAttractionAffector.cpp
source/Irrlicht/CMeshSceneNode.cpp
source/Irrlicht/CGUIScrollBar.cpp
source/Irrlicht/CAttributes.cpp
source/Irrlicht/CGUIStaticText.cpp
source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp
source/Irrlicht/CGUIFont.cpp
source/Irrlicht/CTriangleSelector.cpp
source/Irrlicht/CParticlePointEmitter.cpp
source/Irrlicht/CTextSceneNode.cpp
source/Irrlicht/CIrrDeviceLinux.cpp
source/Irrlicht/CIrrDeviceStub.cpp
source/Irrlicht/CGUIInOutFader.cpp
source/Irrlicht/CGUITreeView.cpp
source/Irrlicht/CAnimatedMeshSceneNode.cpp
source/Irrlicht/CGUICheckBox.cpp
source/Irrlicht/CGUIWindow.cpp
source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp
source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp
source/Irrlicht/CColorConverter.cpp
source/Irrlicht/CMeshCache.cpp
source/Irrlicht/CIrrDeviceFB.cpp
source/Irrlicht/CMemoryFile.cpp
source/Irrlicht/CMountPointReader.cpp
source/Irrlicht/CBillboardSceneNode.cpp
source/Irrlicht/CGUIImageList.cpp
source/Irrlicht/CSceneCollisionManager.cpp
source/Irrlicht/CIrrDeviceWin32.cpp
source/Irrlicht/CEmptySceneNode.cpp
source/Irrlicht/CParticleBoxEmitter.cpp
source/Irrlicht/CParticleSystemSceneNode.cpp
source/Irrlicht/CIrrDeviceConsole.cpp
source/Irrlicht/CImage.cpp
source/Irrlicht/CTarReader.cpp
source/Irrlicht/CGUIButton.cpp
source/Irrlicht/COpenGLParallaxMapRenderer.cpp
source/Irrlicht/CGUIEditBox.cpp
source/Irrlicht/CLogger.cpp
source/Irrlicht/CMeshManipulator.cpp
source/Irrlicht/CLightSceneNode.cpp
source/Irrlicht/CSkyBoxSceneNode.cpp
source/Irrlicht/CWriteFile.cpp
source/Irrlicht/COctreeTriangleSelector.cpp
source/Irrlicht/CFileList.cpp
source/Irrlicht/CIrrDeviceSDL.cpp
source/Irrlicht/COSOperator.cpp
source/Irrlicht/CImageLoaderJPG.cpp
source/Irrlicht/COpenGLExtensionHandler.cpp
source/Irrlicht/CXMLWriter.cpp
source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp
source/Irrlicht/CGUIColorSelectDialog.cpp
source/Irrlicht/CSceneManager.cpp
source/Irrlicht/Irrlicht.cpp
source/Irrlicht/COpenGLShaderMaterialRenderer.cpp
source/Irrlicht/COpenGLDriver.cpp
source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp
source/Irrlicht/irrXML.cpp
source/Irrlicht/CSkinnedMesh.cpp
source/Irrlicht/CXMLReader.cpp
source/Irrlicht/CDummyTransformationSceneNode.cpp
source/Irrlicht/CGUITable.cpp
source/Irrlicht/CB3DMeshFileLoader.cpp
source/Irrlicht/CGeometryCreator.cpp
source/Irrlicht/CNullDriver.cpp
source/Irrlicht/CCameraSceneNode.cpp
source/Irrlicht/CGUISpinBox.cpp
source/Irrlicht/CReadFile.cpp
source/Irrlicht/CParticleRingEmitter.cpp
source/Irrlicht/CMetaTriangleSelector.cpp
source/Irrlicht/CDefaultSceneNodeFactory.cpp
source/Irrlicht/CGUIImage.cpp
source/Irrlicht/CGUIEnvironment.cpp
source/Irrlicht/CParticleScaleAffector.cpp
source/Irrlicht/CSceneNodeAnimatorDelete.cpp
source/Irrlicht/CImageWriterBMP.cpp
source/Irrlicht/CParticleMeshEmitter.cpp
source/Irrlicht/CSceneNodeAnimatorRotation.cpp
source/Irrlicht/glext.h
source/Irrlicht/CB3DMeshFileLoader.h
source/Irrlicht/CIrrDeviceLinux.h
source/Irrlicht/CMeshCache.h
source/Irrlicht/CAttributes.h
source/Irrlicht/CParticleMeshEmitter.h
source/Irrlicht/CParticlePointEmitter.h
source/Irrlicht/CParticleRotationAffector.h
source/Irrlicht/CMountPointReader.h
source/Irrlicht/CIrrDeviceConsole.h
source/Irrlicht/CTerrainSceneNode.h
source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h
source/Irrlicht/CImageLoaderBMP.h
source/Irrlicht/CSkinnedMesh.h
source/Irrlicht/COpenGLParallaxMapRenderer.h
source/Irrlicht/CParticleRingEmitter.h
source/Irrlicht/COpenGLShaderMaterialRenderer.h
source/Irrlicht/CImageLoaderPNG.h
source/Irrlicht/COctreeTriangleSelector.h
source/Irrlicht/COpenGLTexture.h
source/Irrlicht/Octree.h
source/Irrlicht/os.h
source/Irrlicht/CDefaultGUIElementFactory.h
source/Irrlicht/CSceneNodeAnimatorFlyCircle.h
source/Irrlicht/CTriangleBBSelector.h
source/Irrlicht/S2DVertex.h
source/Irrlicht/CDefaultSceneNodeAnimatorFactory.h
source/Irrlicht/CGUIMessageBox.h
source/Irrlicht/CBoneSceneNode.h
source/Irrlicht/CGUITable.h
source/Irrlicht/CGUIColorSelectDialog.h
source/Irrlicht/CCubeSceneNode.h
source/Irrlicht/resource.h
source/Irrlicht/CSceneNodeAnimatorCameraMaya.h
source/Irrlicht/SoftwareDriver2_helper.h
source/Irrlicht/CGUIWindow.h
source/Irrlicht/dmfsupport.h
source/Irrlicht/CGUICheckBox.h
source/Irrlicht/CMeshManipulator.h
source/Irrlicht/IImagePresenter.h
source/Irrlicht/CGUIMeshViewer.h
source/Irrlicht/CMeshSceneNode.h
source/Irrlicht/CGUIImage.h
source/Irrlicht/CCameraSceneNode.h
source/Irrlicht/IZBuffer.h
source/Irrlicht/CAnimatedMeshSceneNode.h
source/Irrlicht/CGUIStaticText.h
source/Irrlicht/wglext.h
source/Irrlicht/CTimer.h
source/Irrlicht/CSceneNodeAnimatorCameraFPS.h
source/Irrlicht/CParticleFadeOutAffector.h
source/Irrlicht/COpenGLSLMaterialRenderer.h
source/Irrlicht/CParticleAttractionAffector.h
source/Irrlicht/MacOSX/AppDelegate.h
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
source/Irrlicht/MacOSX/OSXClipboard.h
source/Irrlicht/CSceneManager.h
source/Irrlicht/COpenGLDriver.h
source/Irrlicht/CGUIComboBox.h
source/Irrlicht/CSceneCollisionManager.h
source/Irrlicht/ISceneNodeAnimatorFinishing.h
source/Irrlicht/CGUITabControl.h
source/Irrlicht/CSphereSceneNode.h
source/Irrlicht/CIrrDeviceStub.h
source/Irrlicht/CDummyTransformationSceneNode.h
source/Irrlicht/CParticleBoxEmitter.h
source/Irrlicht/COctreeSceneNode.h
source/Irrlicht/CReadFile.h
source/Irrlicht/COSOperator.h
source/Irrlicht/CLightSceneNode.h
source/Irrlicht/CParticleSphereEmitter.h
source/Irrlicht/CZBuffer.h
source/Irrlicht/CImage.h
source/Irrlicht/CIrrDeviceWin32.h
source/Irrlicht/CGUIEditBox.h
source/Irrlicht/CGUISpriteBank.h
source/Irrlicht/CSceneNodeAnimatorFlyStraight.h
source/Irrlicht/COpenGLExtensionHandler.h
source/Irrlicht/CGUIScrollBar.h
source/Irrlicht/CTriangleSelector.h
source/Irrlicht/CParticleGravityAffector.h
source/Irrlicht/CGUIModalScreen.h
source/Irrlicht/CDefaultSceneNodeFactory.h
source/Irrlicht/CXMLReaderImpl.h
source/Irrlicht/COpenGLMaterialRenderer.h
source/Irrlicht/CVideoModeList.h
source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h
source/Irrlicht/CColorConverter.h
source/Irrlicht/CWaterSurfaceSceneNode.h
source/Irrlicht/SoftwareDriver2_compile_config.h
source/Irrlicht/CSceneNodeAnimatorTexture.h
source/Irrlicht/CXMLReader.h
source/Irrlicht/CEmptySceneNode.h
source/Irrlicht/CParticleSystemSceneNode.h
source/Irrlicht/CImageWriterPNG.h
source/Irrlicht/CParticleScaleAffector.h
source/Irrlicht/CImageLoaderJPG.h
source/Irrlicht/CBillboardSceneNode.h
source/Irrlicht/CIrrDeviceSDL.h
source/Irrlicht/CSkyDomeSceneNode.h
source/Irrlicht/CGUIInOutFader.h
source/Irrlicht/CGUIFont.h
source/Irrlicht/CGUIImageList.h
source/Irrlicht/CFileSystem.h
source/Irrlicht/CSceneNodeAnimatorRotation.h
source/Irrlicht/CGUISkin.h
source/Irrlicht/S4DVertex.h
source/Irrlicht/CGUIMenu.h
source/Irrlicht/CBlit.h
source/Irrlicht/CZipReader.h
source/Irrlicht/CGUIToolBar.h
source/Irrlicht/CImageWriterJPG.h
source/Irrlicht/IAttribute.h
source/Irrlicht/CNullDriver.h
source/Irrlicht/CWriteFile.h
source/Irrlicht/CSceneNodeAnimatorFollowSpline.h
source/Irrlicht/glxext.h
source/Irrlicht/CMetaTriangleSelector.h
source/Irrlicht/CTarReader.h
source/Irrlicht/CXMLWriter.h
source/Irrlicht/CParticleCylinderEmitter.h
source/Irrlicht/ITriangleRenderer.h
source/Irrlicht/CSceneNodeAnimatorDelete.h
source/Irrlicht/CIrrDeviceFB.h
source/Irrlicht/CGUIEnvironment.h
source/Irrlicht/CTerrainTriangleSelector.h
source/Irrlicht/CAttributeImpl.h
source/Irrlicht/CGeometryCreator.h
source/Irrlicht/CSkyBoxSceneNode.h
source/Irrlicht/CImageWriterBMP.h
source/Irrlicht/BuiltInFont.h
source/Irrlicht/CMemoryFile.h
source/Irrlicht/CFPSCounter.h
source/Irrlicht/CGUITreeView.h
source/Irrlicht/CGUIContextMenu.h
source/Irrlicht/CFileList.h
source/Irrlicht/CLimitReadFile.h
source/Irrlicht/CGUISpinBox.h
source/Irrlicht/CGUIButton.h
source/Irrlicht/CGUIListBox.h
source/Irrlicht/CGUIFileOpenDialog.h
source/Irrlicht/CTextSceneNode.h

include/ESceneNodeAnimatorTypes.h
include/IParticleGravityAffector.h
include/IGUIFontBitmap.h
include/IEventReceiver.h
include/EMessageBoxFlags.h
include/IParticleSphereEmitter.h
include/IParticleFadeOutAffector.h
include/IGeometryCreator.h
include/IGUIEnvironment.h
include/irrunpack.h
include/IParticleRingEmitter.h
include/IGUIElement.h
include/IMaterialRenderer.h
include/SVertexIndex.h
include/SMaterialLayer.h
include/irrMap.h
include/EMaterialTypes.h
include/IAnimatedMeshSceneNode.h
include/IParticleCylinderEmitter.h
include/IAttributeExchangingObject.h
include/IVertexBuffer.h
include/ISkinnedMesh.h
include/irrList.h
include/SAnimatedMesh.h
include/IGUITreeView.h
include/IGUIFont.h
include/IGUIElementFactory.h
include/IParticleSystemSceneNode.h
include/ITerrainSceneNode.h
include/SMeshBuffer.h
include/IGUIEditBox.h
include/ILogger.h
include/ILightManager.h
include/IMeshBuffer.h
include/irrlicht.h
include/ITimer.h
include/IImage.h
include/position2d.h
include/IGUIToolbar.h
include/IGUISpinBox.h
include/IGUITabControl.h
include/IBillboardTextSceneNode.h
include/IGUIInOutFader.h
include/path.h
include/IMetaTriangleSelector.h
include/ISceneUserDataSerializer.h
include/irrArray.h
include/irrString.h
include/IMesh.h
include/line3d.h
include/IMeshLoader.h
include/aabbox3d.h
include/CMeshBuffer.h
include/ETerrainElements.h
include/EDebugSceneTypes.h
include/driverChoice.h
include/IParticleAttractionAffector.h
include/IGUISpriteBank.h
include/IGUISkin.h
include/irrAllocator.h
include/IDummyTransformationSceneNode.h
include/SSkinMeshBuffer.h
include/ISceneLoader.h
include/IrrlichtDevice.h
include/IMaterialRendererServices.h
include/SColor.h
include/IXMLWriter.h
include/CDynamicMeshBuffer.h
include/IFileArchive.h
include/IGUIContextMenu.h
include/IVideoDriver.h
include/irrMath.h
include/ISceneNode.h
include/line2d.h
include/irrpack.h
include/plane3d.h
include/ISceneManager.h
include/IImageWriter.h
include/EGUIElementTypes.h
include/IParticleMeshEmitter.h
include/IGUIColorSelectDialog.h
include/IGUIImage.h
include/IGUIListBox.h
include/vector2d.h
include/CIndexBuffer.h
include/IAnimatedMesh.h
include/SMaterial.h
include/rect.h
include/EDriverFeatures.h
include/IVideoModeList.h
include/fast_atof.h
include/IGUICheckBox.h
include/ISceneNodeAnimatorFactory.h
include/SVertexManipulator.h
include/ITextSceneNode.h
include/IDynamicMeshBuffer.h
include/SExposedVideoData.h
include/IReferenceCounted.h
include/irrXML.h
include/SKeyMap.h
include/ECullingTypes.h
include/IBillboardSceneNode.h
include/ITriangleSelector.h
include/coreutil.h
include/SMeshBufferTangents.h
include/ILightSceneNode.h
include/dimension2d.h
include/ISceneCollisionManager.h
include/heapsort.h
include/IGUIComboBox.h
include/Keycodes.h
include/SParticle.h
include/EDriverTypes.h
include/IFileSystem.h
include/SMesh.h
include/IParticleAffector.h
include/IGUIImageList.h
include/EShaderTypes.h
include/SceneParameters.h
include/IGUIScrollBar.h
include/IImageLoader.h
include/IParticleBoxEmitter.h
include/ICursorControl.h
include/ICameraSceneNode.h
include/ISceneNodeAnimatorCameraMaya.h
include/IMeshManipulator.h
include/CVertexBuffer.h
include/SSharedMeshBuffer.h
include/vector3d.h
include/ISceneNodeAnimatorCameraFPS.h
include/IGUIMeshViewer.h
include/triangle3d.h
include/matrix4.h
include/IGUIStaticText.h
include/IMeshWriter.h
include/IMeshSceneNode.h
include/IParticleAnimatedMeshSceneNodeEmitter.h
include/IMeshCache.h
include/EMeshWriterEnums.h
include/EPrimitiveTypes.h
include/SViewFrustum.h
include/IXMLReader.h
include/EHardwareBufferFlags.h
include/IOSOperator.h
include/IGPUProgrammingServices.h
include/IrrCompileConfig.h
include/ISceneNodeFactory.h
include/IGUITable.h
include/IGUIButton.h
include/EMaterialFlags.h
include/EDeviceTypes.h
include/IGUIWindow.h
include/EAttributes.h
include/S3DVertex.h
include/ISceneNodeAnimatorCollisionResponse.h
include/IWriteFile.h
include/irrTypes.h
include/IParticleEmitter.h
include/quaternion.h
include/SLight.h
include/IReadFile.h
include/ESceneNodeTypes.h
include/IIndexBuffer.h
include/EGUIAlignment.h
include/SIrrCreationParameters.h
include/IFileList.h
include/SMeshBufferLightMap.h
include/IRandomizer.h
include/ISceneNodeAnimator.h
include/IAttributes.h
include/IParticleRotationAffector.h
include/IGUIFileOpenDialog.h
include/IBoneSceneNode.h
include/IShaderConstantSetCallBack.h
include/ITexture.h
)

if(APPLE)
    set(IRRLICHT_SOURCES
        ${IRRLICHT_SOURCES}
        source/Irrlicht/MacOSX/AppDelegate.mm
        source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
        source/Irrlicht/MacOSX/OSXClipboard.mm)

    #list(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS mm)
    #set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS cpp)

    set_source_files_properties(source/Irrlicht/MacOSX/AppDelegate.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3  -fno-rtti")
    set_source_files_properties(source/Irrlicht/MacOSX/AppDelegate.mm PROPERTIES LANGUAGE C)

    set_source_files_properties(source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3  -fno-rtti")
    set_source_files_properties(source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm PROPERTIES LANGUAGE C)

    set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
    set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES LANGUAGE C)
endif()

add_library(stkirrlicht ${IRRLICHT_SOURCES})
target_link_libraries(stkirrlicht ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARY})



