# The name of our project is "GRAY". CMakeLists files in this project can # refer to the root source directory of the project as ${GRAY_SOURCE_DIR} and # to the root binary directory of the project as ${GRAY_BINARY_DIR}. cmake_minimum_required (VERSION 2.6 FATAL_ERROR) if(DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type") else(DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type") endif(DEFINED CMAKE_BUILD_TYPE) project (GRAY) option(GRAY_ENABLE_GNURBS "Enable gnurbs integration" OFF) option(GRAY_ENABLE_OPENGL "Enable OpenGL integration" ON) option(GRAY_ENABLE_OPENMP "Enable OpenMP integration" ON) option(GRAY_ENABLE_FLTK "Enable Fltk integration" ON) option(GRAY_BUILD_SHARED "Build shared library" OFF) option(GRAY_BUILD_EXEC "Build test executable" ON) option(GRAY_ENABLE_PLY "Enable ply file format" ON) if(GRAY_ENABLE_OPENMP) find_package(OpenMP) if (OPENMP_FOUND) ADD_DEFINITIONS(-DGRAY_HAVE_OMP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif(OPENMP_FOUND) endif(GRAY_ENABLE_OPENMP) if(GRAY_ENABLE_OPENGL) find_package(OpenGL) if (OPENGL_FOUND) include_directories(${OpenGL_INCLUDE_DIR}) set(LIBS ${LIBS} ${OpenGL_LIBRARIES}) ADD_DEFINITIONS(-DGRAY_HAVE_OGL) if(GRAY_ENABLE_FLTK) set(FLTK_SKIP_FORMS TRUE) set(FLTK_SKIP_FLUID TRUE) find_package(FLTK) if (FLTK_FOUND) include_directories(${FLTK_INCLUDE_DIR}) set(LIBS ${LIBS} ${FLTK_LIBRARIES}) ADD_DEFINITIONS(-DGRAY_HAVE_FLTK) endif (FLTK_FOUND) endif (GRAY_ENABLE_FLTK) endif (OPENGL_FOUND) endif (GRAY_ENABLE_OPENGL) if(GRAY_ENABLE_GNURBS) include_directories(gnurbs/api) include_directories(util) add_subdirectory(gnurbs) add_subdirectory(util) set(LIBS ${LIBS} gnurbs-dynamic util-dynamic) include_directories(gnurbs-interface) set(GRAY_SOURCE ${GRAY_SOURCE} gnurbs-interface/gnurbs-interface.cc) ADD_DEFINITIONS(-DGRAY_HAVE_GNURBS) endif(GRAY_ENABLE_GNURBS) set(GRAY_SOURCE ${GRAY_SOURCE} framebuffer.cc models.cc meshmodel.cc ray.cc scene.cc materials.cc camera.cc QuasiMonteCarlo.cc BoundingBox.cc BVTree.cc) if (GRAY_ENABLE_OPENGL) set(GRAY_SOURCE ${GRAY_SOURCE} glu_gray.cc) if (GRAY_ENABLE_FLTK) set(GRAY_SOURCE ${GRAY_SOURCE} glframebuffer.cc glwindow.cc) endif (GRAY_ENABLE_FLTK) endif (GRAY_ENABLE_OPENGL) if (GRAY_ENABLE_PLY) set(GRAY_SOURCE ${GRAY_SOURCE} ply/plyfile.c) include_directories(ply) ADD_DEFINITIONS(-DGRAY_HAVE_PLY) endif (GRAY_ENABLE_PLY) if (GRAY_BUILD_SHARED) add_library(gray SHARED ${GRAY_SOURCE}) target_link_libraries (gray ${LIBS} ) endif (GRAY_BUILD_SHARED) if (GRAY_BUILD_EXEC) if (GRAY_ENABLE_OPENGL) if (GRAY_ENABLE_FLTK) if (GRAY_BUILD_SHARED) add_executable (glgray main.cc ) target_link_libraries (glgray ${LIBS} gray) else(GRAY_BUILD_SHARED) add_executable (glgray ${GRAY_SOURCE} main.cc ) target_link_libraries (glgray ${LIBS} ) endif (GRAY_BUILD_SHARED) endif (GRAY_ENABLE_FLTK) endif (GRAY_ENABLE_OPENGL) endif (GRAY_BUILD_EXEC)