Commit 821fad04 authored by Julien Michel's avatar Julien Michel

ENH: Turn Ice into an OTB module

parent 62e91c3e
# Courtesy of: https://raw.github.com/progschj/OpenGL-Examples/
#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_PATH
# GLEW_LIBRARY
#
IF (WIN32)
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
$ENV{PROGRAMFILES}/GLEW/include
${GLEW_ROOT_DIR}/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARY
NAMES glew GLEW glew32 glew32s
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${GLEW_ROOT_DIR}/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEW library")
ELSE (WIN32)
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
${GLEW_ROOT_DIR}/include
DOC "The directory where GL/glew.h resides")
# Prefer the static library.
FIND_LIBRARY( GLEW_LIBRARY
NAMES libGLEW.so GLEW
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
${GLEW_ROOT_DIR}/lib
DOC "The GLEW library")
ENDIF (WIN32)
SET(GLEW_FOUND "NO")
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
SET(GLEW_FOUND "YES")
ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG GLEW_LIBRARY)
# Locate the glfw library
# This module defines the following variables:
# GLFW_LIBRARY, the name of the library;
# GLFW_INCLUDE_DIR, where to find glfw include files.
# GLFW_FOUND, true if both the GLFW_LIBRARY and GLFW_INCLUDE_DIR have been found.
#
# To help locate the library and include file, you could define an environment variable called
# GLFW_ROOT which points to the root of the glfw library installation. This is pretty useful
# on a Windows platform.
#
#
# Usage example to compile an "executable" target to the glfw library:
#
# FIND_PACKAGE (glfw REQUIRED)
# INCLUDE_DIRECTORIES (${GLFW_INCLUDE_DIR})
# ADD_EXECUTABLE (executable ${EXECUTABLE_SRCS})
# TARGET_LINK_LIBRARIES (executable ${GLFW_LIBRARY})
#
# TODO:
# Allow the user to select to link to a shared library or to a static library.
#Search for the include file...
FIND_PATH(GLFW_INCLUDE_DIR GLFW/glfw3.h DOC "Path to GLFW include directory."
HINTS
$ENV{GLFW_ROOT}
PATH_SUFFIX
include # For finding the include file under the root of the glfw expanded archive, typically on Windows.
)
FIND_LIBRARY(GLFW_LIBRARY DOC "Absolute path to GLFW library."
NAMES glfw glfw3dll glfw3
HINTS
$ENV{GLFW_ROOT}
PATH_SUFFIXES
lib # For finding the library file under the root of the glfw expanded archive, typically on Windows.
)
IF(GLFW_INCLUDE_DIR AND EXISTS "${GLFW_INCLUDE_DIR}/GLFW/glfw3.h")
FILE(STRINGS "${GLFW_INCLUDE_DIR}/GLFW/glfw3.h" glfw_version_str
REGEX "^#[\t ]*define[\t ]+GLFW_VERSION_(MAJOR|MINOR|REVISION)[\t ]+[0-9]+$")
UNSET(GLFW_VERSION_STRING)
FOREACH(VPART MAJOR MINOR REVISION)
FOREACH(VLINE ${glfw_version_str})
IF(VLINE MATCHES "^#[\t ]*define[\t ]+GLFW_VERSION_${VPART}")
STRING(REGEX REPLACE "^#[\t ]*define[\t ]+GLFW_VERSION_${VPART}[\t ]+([0-9]+)$" "\\1"
GLFW_VERSION_PART "${VLINE}")
IF(GLFW_VERSION_STRING)
SET(GLFW_VERSION_STRING "${GLFW_VERSION_STRING}.${GLFW_VERSION_PART}")
ELSE()
SET(GLFW_VERSION_STRING "${GLFW_VERSION_PART}")
ENDIF()
UNSET(GLFW_VERSION_PART)
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF()
INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW
REQUIRED_VARS GLFW_LIBRARY GLFW_INCLUDE_DIR
VERSION_VAR GLFW_VERSION_STRING)
\ No newline at end of file
PROJECT(Ice)
PROJECT(OTBIce)
cmake_minimum_required(VERSION 2.6)
set(OTBIce_LIBRARIES OTBIce)
set(Ice_VERSION_MAJOR "0")
set(Ice_VERSION_MINOR "4")
set(Ice_VERSION_PATCH "0")
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMake
${CMAKE_MODULE_PATH})
include(CTest)
#----------------------------------------------------------------------------
# ensure WIN32 definition
if(WIN32)
add_definitions(-DWIN32)
endif(WIN32)
#----------------------------------------------------------------------------
#Prevents conflicts with visual min/max function
if(WIN32)
add_definitions(-DNOMINMAX)
add_definitions(
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-D_CRT_IS_WCTYPE_NO_DEPRECATE
-D_CRT_MANAGED_FP_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-D_CRT_VCCLRIT_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNING)
endif()
endif(WIN32)
OPTION(BUILD_ICE_APPLICATION "Build the Ice application (requires glfw and glut)" ON)
# include before OTB includes in case ice is already installed in the system (at otb install location)
include_directories(Code)
#----------------------------------------------------------------------------
# ITK
# find_package(ITK REQUIRED)
# if(ITK_FOUND)
# MESSAGE(STATUS "ITK found")
# include(${ITK_USE_FILE})
# else(ITK_FOUND)
# message(FATAL_ERROR "ITK not found. Please set ITK_DIR")
# endif(ITK_FOUND)
#----------------------------------------------------------------------------
# Orfeo ToolBox
find_package(OTB REQUIRED
COMPONENTS OTBImageIO OTBVectorDataIO OTBProjection OTBStatistics)
if(OTB_FOUND)
MESSAGE(STATUS "OTB found")
include(${OTB_USE_FILE})
else(OTB_FOUND)
message(FATAL_ERROR "OTB not found. Please set OTB_DIR")
endif(OTB_FOUND)
#----------------------------------------------------------------------------
# OpenGL (needed by Qt4)
find_package( OpenGL REQUIRED )
if (OPENGL_FOUND)
MESSAGE(STATUS "OpenGL found")
include_directories(${OPENGL_INCLUDE_DIR})
else (OPENGL_FOUND)
MESSAGE(FATAL_ERROR "OpenGL missing")
endif (OPENGL_FOUND)
find_package(GLEW REQUIRED)
if(GLEW_FOUND)
MESSAGE(STATUS "Glew found")
include_directories(${GLEW_INCLUDE_PATH})
else(GLEW_FOUND)
MESSAGE(FATAL_ERROR "Glew missing. Please set glew directories.")
endif(GLEW_FOUND)
if(BUILD_ICE_APPLICATION)
find_package(GLFW REQUIRED)
if(GLFW_FOUND)
MESSAGE(STATUS "GLFW found")
include_directories(${GLFW_INCLUDE_DIR})
else(GLFW_FOUND)
MESSAGE(FATAL_ERROR "GLFW missing. Please set glfw directories or deactivate the BUILD_ICE_APPLICATION option.")
endif(GLFW_FOUND)
find_package(GLUT REQUIRED)
if(GLUT_FOUND)
MESSAGE(STATUS "Glut found")
include_directories(${GLUT_INCLUDE_DIR})
else(GLUT_FOUND)
MESSAGE(FATAL_ERROR "Glut missing. Please set glut directories or deactivate the BUILD_ICE_APPLICATION option.")
endif(GLUT_FOUND)
endif(BUILD_ICE_APPLICATION)
SET(BUILD_SHARED_LIBS ${OTB_BUILD_SHARED})
set(Ice_LIBRARY_PROPERTIES
VERSION "${Ice_VERSION_MAJOR}.${Ice_VERSION_MINOR}.${Ice_VERSION_PATCH}"
SOVERSION "${Ice_VERSION_MAJOR}.${Ice_VERSION_MINOR}"
)
# Output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Ice_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for all ARCHIVE products (static libs, import libs)")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Ice_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for all LIBRARY products (so, modules)")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Ice_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for all RUNTIME products (executables, dlls)")
# Install dirs
if(NOT Ice_INSTALL_BIN_DIR)
set(Ice_INSTALL_BIN_DIR "bin")
endif(NOT Ice_INSTALL_BIN_DIR)
if(NOT Ice_INSTALL_LIB_DIR)
set(Ice_INSTALL_LIB_DIR "lib/")
endif(NOT Ice_INSTALL_LIB_DIR)
if(NOT Ice_INSTALL_INCLUDE_DIR)
set(Ice_INSTALL_INCLUDE_DIR "include/")
endif(NOT Ice_INSTALL_INCLUDE_DIR)
add_subdirectory(Code)
if(BUILD_ICE_APPLICATION)
add_subdirectory(Application)
endif(BUILD_ICE_APPLICATION)
otb_module_impl()
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
## # The following are required to uses Dart and the Cdash dashboard
## ENABLE_TESTING()
## INCLUDE(Dart)
set(CTEST_PROJECT_NAME "Ice")
set(CTEST_NIGHTLY_START_TIME "20:00:00 CEST")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "dash.orfeo-toolbox.org")
set(CTEST_DROP_LOCATION "/submit.php?project=OTB-Ice")
set(CTEST_DROP_SITE_CDASH TRUE)
file(GLOB srcs "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx")
file(GLOB hdrs "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
ADD_LIBRARY(OTBIce ${srcs})
TARGET_LINK_LIBRARIES(OTBIce ${OTB_LIBRARIES} ${OPENGL_LIBRARY} ${GLEW_LIBRARY})
set_target_properties(OTBIce
PROPERTIES ${Ice_LIBRARY_PROPERTIES}
)
# Install library
install(
TARGETS OTBIce
RUNTIME DESTINATION ${Ice_INSTALL_BIN_DIR} COMPONENT Runtime
LIBRARY DESTINATION ${Ice_INSTALL_LIB_DIR} COMPONENT Runtime
ARCHIVE DESTINATION ${Ice_INSTALL_LIB_DIR} COMPONENT Development
)
# Install headers
install(FILES ${hdrs}
DESTINATION ${Ice_INSTALL_INCLUDE_DIR}/
COMPONENT Development)
This code is covered by the OTB copyright and licence.
The ORFEO Toolbox (OTB) is developed by the French Centre
National d'Etudes Spatiales, CNES. OTB is partially derived from ITK,
GDAL, VTK, VXL and LibSVM, hence some code is copyrighted accordingly (see
ITKCopyright.txt, GDALCopyright.txt, VTKCopyright.txt, VXLCopyright.txt
and LibSVMCopyright.txt).
The OTB copyright is as follows:
Copyright (c) Centre National d'Etudes Spatiales
All rights reserved.
The OTB is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
file(GLOB srcs "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx")
ADD_LIBRARY(OTBIce ${srcs})
TARGET_LINK_LIBRARIES(OTBIce ${OTBCommon_LIBRARIES} ${OTBOpenGL_LIBRARIES} ${OTBGlew_LIBRARIES})
otb_module_target(OTBIce)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment