#################################################
#
#  (C) 2010-2011 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 2.6 )


##### general package setup #####################

project( tdevelop )
set( VERSION "3.5.4")


##### include essential cmake modules ###########

include( CheckCSourceCompiles )
include( CheckCXXSourceCompiles )
include( CheckFunctionExists )
include( CheckIncludeFile )
include( CheckIncludeFileCXX )
include( CheckLibraryExists )
include( FindPkgConfig )


##### include our cmake modules #################

set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( TDEMacros )


##### setup install paths #######################

include( TDESetupPaths )
tde_setup_paths( )


##### build tools ###############################

option( WITH_BUILDTOOL_ALL "Enable all build tools" OFF )
option( WITH_BUILDTOOL_ADA "Enable ada build tool" ${WITH_BUILDTOOL_ALL} )
option( WITH_BUILDTOOL_ANT "Enable ant build tool" ${WITH_BUILDTOOL_ALL} )
option( WITH_BUILDTOOL_AUTOTOOLS "Enable autotools build tool" ${WITH_BUILDTOOL_ALL} )
option( WITH_BUILDTOOL_CUSTOMMAKEFILES "Enable custommakefiles build tool" ${WITH_BUILDTOOL_ALL} )
option( WITH_BUILDTOOL_PASCAL "Enable pascal build tool" ${WITH_BUILDTOOL_ALL} )
option( WITH_BUILDTOOL_QMAKE "Enable qmake build tool" ${WITH_BUILDTOOL_ALL} )
option( WITH_BUILDTOOL_SCRIPT "Enable script build tool" ${WITH_BUILDTOOL_ALL} )


##### languages #################################

option( WITH_LANGUAGE_ALL "Enable all languages" OFF )
option( WITH_LANGUAGE_ADA "Enable ada language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_BASH "Enable bash language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_CPP "Enable cpp language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_FORTRAN "Enable fortran language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_JAVA "Enable java language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_CSHARP "Enable csharp language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_PASCAL "Enable pascal language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_PERL "Enable perl language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_PHP "Enable php language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_PYTHON "Enable python language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_RUBY "Enable ruby language" ${WITH_LANGUAGE_ALL} )
option( WITH_LANGUAGE_SQL "Enable sql language" ${WITH_LANGUAGE_ALL} )


##### version control systems ###################

option( WITH_VCS_ALL "Enable all version control systems"  OFF )
option( WITH_VCS_CLEARCASE "Enable clearcase support" ${WITH_VCS_ALL} )
option( WITH_VCS_CVSSERVICE "Enable cvsservice support" ${WITH_VCS_ALL} )
option( WITH_VCS_PERFORCE "Enable perforce support" ${WITH_VCS_ALL} )
option( WITH_VCS_SUBVERSION "Enable subversion support" ${WITH_VCS_ALL} )


##### components ################################

option( BUILD_ALL "Build all components" OFF )
option( BUILD_KDEVDESIGNER "Build kdevdesigner" ${BUILD_ALL} )
option( BUILD_VISUALBOYADVANCE "Build embedded/visualboyadvance" ${BUILD_ALL} )
option( BUILD_DOC "Build doc" ${BUILD_ALL} )


##### optional stuff ############################

option( WITH_DEPRECATION "Enable deprecation warnings" OFF )


##### configure checks ##########################

include( ConfigureChecks.cmake )


##### various definitions #######################

if( NOT DEFINED QT_DOCDIR )
  find_path( QT_DOCDIR index.html
    ${QTDIR}/doc/html
    $ENV{QTDIR}/doc/html )
  if( NOT QT_DOCDIR )
    set( QT_DOCDIR "QT_DOCDIR is not set" )
  endif( )
endif( )

if( NOT DEFINED KDELIBS_DOXYDIR )
  set( KDELIBS_DOXYDIR "${TDE_HTML_DIR}/en/tdelibs-apidocs" )
endif( )

if( NOT DEFINED MAKE_COMMAND )
  set( MAKE_COMMAND "gmake" )
endif( )


###### global compiler settings #################

add_definitions(
  -DHAVE_CONFIG_H
  ${TQT_CFLAGS_OTHER}
)

if( NOT WITH_DEPRECATION )
  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated" )
endif( )

set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include tqt.h" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined" )


##### install data ##############################

install( FILES
    tdevelop.desktop kdevassistant.desktop tdevelop_ruby.desktop
    tdevelop_c_cpp.desktop tdevelop_kde_cpp.desktop
    tdevelop_scripting.desktop
  DESTINATION ${XDG_APPS_INSTALL_DIR} )

install( FILES
    tde-development-tdevelop.directory
  DESTINATION ${XDG_DIRECTORY_INSTALL_DIR} )

install( FILES
    x-tdevelop.desktop
  DESTINATION ${MIME_INSTALL_DIR}/application )

install( PROGRAMS
    kdevprj2tdevelop
  DESTINATION ${BIN_INSTALL_DIR} )


##### source directories ########################

add_subdirectory( lib )
add_subdirectory( src )
add_subdirectory( parts )
add_subdirectory( buildtools )
add_subdirectory( editors )
add_subdirectory( languages )
add_subdirectory( mimetypes )
add_subdirectory( pics )
add_subdirectory( vcs )
add_subdirectory( embedded )
tde_conditional_add_subdirectory( BUILD_KDEVDESIGNER kdevdesigner )
tde_conditional_add_subdirectory( BUILD_DOC doc )


##### write configure files #####################

configure_file( config.h.cmake config.h @ONLY )