#############################################################################
# The Falcon Programming language
#
# CMake configuration file for Core falcon
##############################################################################
#
##  Control Variables
#
# FALCON_BIN_DIR    - Prefix for binary installation. Defaults to "bin"
# FALCON_INC_DIR    - Prefix for installation of include files.
# FALCON_LIB_DIR    - Prefix for installation of archives and dynamic libraries
#                     on UNIXes. Defaults to "lib".
# FALCON_MOD_DIR    - Prefix for installation of modules. Defaults to
#                     $FALCON_LIB_DIR/falcon on UNICES, and bin/ on windows.
# FALCON_MAN_DIR    - Where manual pages are stored (below prefix)
# FALCON_SHARE_DIR  - Where to install falco share files
# FALCON_CMAKE_DIR  - Where to install FalconConfig.cmake & c
#
##  Options
#
# FALCON_SKIP_BISON         - Turn ON to avoid using bison.
# FALCON_WITH_MANPAGES      - Turn ON to build and install man pages.
# FALCON_BUILD_FEATHERS     - Turn OFF to skip building Feathers.
# FALCON_BUILD_MODULES      - Turn OFF to skip building Falcon modules.
# FALCON_BUILD_NATMODS      - Turn OFF to skip building other binary native modules.
# FALCON_BUILD_APPS         - Turn ON to install installing Falcon applications.
# FALCON_BUILD_FWKS         - Turn OFF to skip installing Falcon frameworks.
# FALCON_BUILD_DOCS         - Build automatic documentation
#
##  Options For Native Modules
#
# FALCON_BUILD_*MODULE_NAME*    - ON to build a given module
#
# List of available modules: CURL DBI DBUS DYNLIB GD2 GTK PDF SDL
#

cmake_minimum_required(VERSION 2.6.2)
project(Falcon)


##################################################################
# Falcon build environment setup

set(Falcon_IN_CORE_SOURCETREE on)

# Find the module for cmake that we generate before install
set( Falcon_DIR "${CMAKE_CURRENT_BINARY_DIR}/devtools" )
#set( faldoc_DIR "${CMAKE_CURRENT_BINARY_DIR}/apps/faldoc")

# Add source include files at those generated by the module
list(APPEND Falcon_INCLUDE_DIRS
   "${CMAKE_CURRENT_SOURCE_DIR}/include"
   "${CMAKE_CURRENT_SOURCE_DIR}/modules/native/feathers/include"
)

include(detail.cmake)


##################################################################
# CMAKE environment setup
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

#########################################################à
# List of files to be installed as docs
#

set( doc_files
      AUTHORS
      BUILDING
      ChangeLog
      copyright
      LICENSE
      README
      README.editline
      README.mersenne
      TODO
      LICENSE_GPLv2
      RELNOTES
   )

install(
   FILES ${doc_files}
   DESTINATION ${FALCON_SHARE_DIR} )

#########################################################à
# Subdirectories
#

#collect the include files in FALCON_HEADER
add_subdirectory(include)
#
add_subdirectory(engine)
add_subdirectory(clt)
#
add_subdirectory(devtools)

add_custom_target(falcon-core)

#########################################################################
# Feathers?
#
if( FALCON_BUILD_FEATHERS )
   message( STATUS "Adding FEATHERS to this build" )

   #override settings for the include dirs
   list( APPEND Falcon_INCLUDE_DIRS
      "${CMAKE_CURRENT_BINARY_DIR}/include" )

   add_subdirectory( modules/native/feathers )

else()
    message( STATUS "Not building feathers" )
endif()



#########################################################################
# Modules?
#
if( FALCON_BUILD_NATMODS )
    message( STATUS "Adding native binary modules to this build" )
    add_subdirectory( modules/native )
else()
    message( STATUS "Not building binary native modules" )
endif()

if( FALCON_BUILD_MODULES )
    message( STATUS "Adding Falcon modules to this build" )
    add_subdirectory( modules/falcon )
else()
    message( STATUS "Not building modules" )
endif()

if( FALCON_BUILD_FWKS )
    message( STATUS "Adding frameworks to this build" )
    add_subdirectory( frameworks )
else()
    message( STATUS "Not building frameworks" )
endif()

if( FALCON_BUILD_APPS )
    message( STATUS "Adding applications to this build" )
    add_subdirectory( apps )
else()
    message( STATUS "Not building applications" )
endif()

if( FALCON_BUILD_DOCS )
    message( STATUS "Adding documentation to this build" )
    add_subdirectory( docs )
else()
    message( STATUS "Not building documentation" )
endif()

#Generate make distro scripts
if( FALCON_BUILD_DIST )
	add_subdirectory( dist )
endif()

if( FALCON_INSTALL_TESTS )
    message( STATUS "Adding (source) tests, samples and demos to the distribution" )
    add_subdirectory( tests )
else()
    message( STATUS "Not installing tests" )
endif()

# CMake generated information.  Is used by our falcon-config.cmake
if (NOT FALCON_CMAKE_DIR)
   if(WIN32)
      set(FALCON_CMAKE_DIR cmake)
   else()
      set(FALCON_CMAKE_DIR ${FALCON_SHARE_DIR}/cmake)
   endif()
endif()

install(EXPORT falcon-core-targets
  DESTINATION ${FALCON_CMAKE_DIR}
)

