cmake_minimum_required (VERSION 2.8)

set(APP_NAME "gdalmc")

project (${APP_NAME})

set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
set(CMAKE_COLOR_MAKEFILE ON)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

find_package(GDAL REQUIRED)
if(GDAL_FOUND)
    include_directories(${GDAL_INCLUDE_DIR})
    include_directories(${GDAL_INCLUDE_DIR}/ogr)
    include_directories(${GDAL_INCLUDE_DIR}/ogr/ogrsf_frmts)
    include_directories(${GDAL_INCLUDE_DIR}/port)
    include_directories(${GDAL_INCLUDE_DIR}/gcore)
    include_directories(${GDAL_INCLUDE_DIR}/alg)
    include_directories(${GDAL_INCLUDE_DIR}/frmts/vrt)
    include_directories(${GDAL_INCLUDE_DIR}/build/port) #assume that out of source build was in build dir
endif(GDAL_FOUND)

if(MSVC)
  set(CMAKE_DEBUG_POSTFIX "d")
  add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  add_definitions(-D_UNICODE -DUNICODE -D_USRDLL)
endif(MSVC)

if(WIN32)
  add_definitions(-DWIN32)
endif(WIN32)

if(UNIX)
     if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fno-strict-aliasing")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-strict-aliasing")
     endif()
endif()

set(PROJECT_HHEADERS ${PROJECT_HHEADERS}  
)

set(PROJECT_CSOURCES ${PROJECT_CSOURCES}
    ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)

add_executable(${APP_NAME} ${PROJECT_HHEADERS} ${PROJECT_CSOURCES})

if(GDAL_FOUND)
    target_link_libraries(${APP_NAME} ${GDAL_LIBRARIES})
endif(GDAL_FOUND) 
