# Author: Noel du Toit
# Date: 8/11/10

# include the local directories for source and build objects
INCLUDE_DIRECTORIES(${navlite_SOURCE_DIR}/src/viewer)

# ********************************************************
# Executable: viewer
GENGETOPT_FILE(cmdline.ggo cmdline "--conf-parser")
ADD_EXECUTABLE(viewer 	ViewerMain.cc
						Viewer.cc
 		      		       		ViewerWindow.cc 
						ViewerUtils.cc 
						cmdline.h 
						cmdline.c)


# ********************************************************
# Use fltk-config to find the flags and libraries
# get the compiler flags
EXECUTE_PROCESS(	COMMAND	fltk-config --cxxflags
				OUTPUT_VARIABLE FLTK_CXXFLAGS)
#extract the include directory
STRING(REGEX MATCHALL "-I[^ ]*" FLTK_INCLUDE_DIR ${FLTK_CXXFLAGS})
INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR})
# get the libraries
EXECUTE_PROCESS(	COMMAND	fltk-config --ldflags --use-gl --use-glut
				OUTPUT_VARIABLE FLTK_LDFLAGS_GL)
# strip the leading and trailing white spaces
STRING(STRIP ${FLTK_LDFLAGS_GL} FLTK_LDFLAGS_GL)
# remove the architecture flag
STRING(REPLACE "-arch i386 " "" FLTK_LIBRARIES_GL ${FLTK_LDFLAGS_GL})
SET(LIBS ${LIBS} ${FLTK_LIBRARIES_GL})

# ********************************************************
# deal with openGL
FIND_PACKAGE(OpenGL)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})

# ********************************************************
# deal with GLUT 
FIND_PACKAGE(GLUT)
INCLUDE_DIRECTORIES(GLUT_INCLUDE_DIR)
SET(LIBS ${LIBS} ${GLUT_LIBRARIES})

# ********************************************************
# link
#MESSAGE(LIBS = ${LIBS})
TARGET_LINK_LIBRARIES(viewer	nav-utils ${LIBS})
