if(NOT CMAKELISTS_SHARED_INCLUDED)
set(CMAKELISTS_SHARED_INCLUDED TRUE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(OpenMP)
if (OPENMP_FOUND AND NOT WIN32)
  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

SET(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_COLOR_MAKEFILE ON)

############################
## SEPARATE BUILD OPTIONS ##
############################

find_package(OpenGL REQUIRED)
find_package(EIGEN REQUIRED)
find_package(LIBIGL REQUIRED)
find_package(ANTTWEAKBAR REQUIRED)
find_package(GLFW REQUIRED)

if(NOT APPLE)
	find_package(GLEW REQUIRED)
endif(NOT APPLE)

if(APPLE)
	set(CMAKE_CXX_LINK_FLAGS "-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo")
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
endif (APPLE) #APPLE

if(UNIX AND NOT APPLE)
  set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lGL -lGLU -lrt -lX11 -lXxf86vm -lXrandr -lpthread -lXi  -lXcursor -lXinerama ")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
endif(UNIX AND NOT APPLE)

include_directories( ${ANT_TWEAK_BAR_INCLUDE_DIR} )

# message(FATAL_ERROR ${ANT_TWEAK_BAR_INCLUDE_DIR})

if(NOT APPLE)
	include_directories( ${GLEW_INCLUDE_DIR} )
endif(NOT APPLE)

include_directories( ${EIGEN_INCLUDE_DIR})
include_directories( ${LIBIGL_INCLUDE_DIRS})
include_directories( ${GLFW_INCLUDE_DIR})
include_directories(
	/usr/local/include
	/opt/local/include
    ${PROJECT_SOURCE_DIR}
    ${OPENGL_INCLUDE_DIR}
)

link_directories(
	/usr/local/lib
	/opt/local/lib
	${ANT_TWEAK_BAR_DIRS}
	${EIGEN_DIRS}
)

#set(CMAKE_CXX_FLAGS -Wall -W -pedantic -std=c99)

# Disable deprecated opengl code from libigl
add_definitions(-DIGL_OPENGL_4)

IF(CMAKE_BUILD_TYPE MATCHES RELEASE)
    add_definitions(-DNDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES RELEASE)

#add_definitions(-DENABLE_XML_SERIALIZATION)



if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()

set(SHARED_SOURCES ${LIBIGL_SOURCES})

if(NOT APPLE)
	set(SHARED_SOURCES ${SHARED_SOURCES} ${GLEW_SOURCES})
endif(NOT APPLE)

# message(FATAL_ERROR ${LIBIGL_SOURCES})


set(SHARED_LIBRARIES
		${LIBIGL_LIBRARIES}
		${OPENGL_LIBRARIES}
		${ANT_TWEAK_BAR_LIBRARY}
		${EIGEN_LIBRARIES}
		${GLEW_LIBRARIES}
		${GLFW_LIBRARIES}
)

#message(FATAL_ERROR ${SHARED_LIBRARIES})
endif(NOT CMAKELISTS_SHARED_INCLUDED)
