Fix:build/cmake:Remove some unneeded link dependencies
[profile/ivi/navit.git] / navit / CMakeLists.txt
index 4e7a108..5e88727 100644 (file)
@@ -3,68 +3,17 @@ project(navit)
 cmake_minimum_required(VERSION 2.6)
 cmake_policy(VERSION 2.6)
 
-set(PACKAGE_VERSION "0.2.0")
+set(PACKAGE_VERSION "0.5.0")
 set(PACKAGE_NAME "navit-svn")
+set(PACKAGE "navit")
+set(PACKAGE_STRING "${PACKAGE} ${PACKAGE_VERSION}")
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
 include("${PROJECT_SOURCE_DIR}/cmake/navit_macros.cmake")
 
-### set defaults
-# modules
-add_module(binding/dbus TRUE)
-add_module(graphics/android FALSE)
-add_module(graphics/gd FALSE)
-add_module(graphics/gtk_drawing_area FALSE)
-add_module(graphics/null FALSE)
-add_module(graphics/opengl TRUE)
-add_module(graphics/qt_qpainter FALSE)
-add_module(graphics/sdl TRUE)
-add_module(graphics/win32 FALSE)
-add_module(gui/gtk FALSE)
-add_module(gui/internal TRUE)
-add_module(gui/qml FALSE)
-add_module(gui/win32 FALSE)
-add_module(map/binfile TRUE)
-add_module(map/filter TRUE)
-add_module(map/mg TRUE)
-add_module(map/shapefile TRUE)
-add_module(map/textfile TRUE)
-add_module(osd/core TRUE)
-add_module(plugin/pedestrian FALSE)
-add_module(speech/android FALSE)
-add_module(speech/cmdline TRUE)
-add_module(speech/dbus FALSE)
-add_module(speech/espeak FALSE)
-add_module(speech/speech_dispatcher TRUE)
-add_plugin(support/espeak FALSE)
-add_plugin(support/ezxml FALSE)
-add_plugin(support/glib FALSE)
-add_plugin(support/libpng FALSE)
-add_plugin(support/win32 FALSE)
-add_plugin(support/wordexp FALSE)
-add_plugin(support/zlib FALSE)
-add_module(vehicle/android FALSE)
-add_module(vehicle/demo TRUE)
-add_module(vehicle/file TRUE)
-add_module(vehicle/gpsd TRUE)
-add_module(vehicle/gpsd_dbus FALSE)
-add_module(vehicle/gypsy TRUE)
-add_module(vehicle/iphone FALSE)
-add_module(vehicle/maemo FALSE)
-add_module(vehicle/null FALSE)
-add_module(vehicle/wince FALSE)
-
-# other features
-set(USE_PLUGINS TRUE)
-set(USE_ROUTING TRUE)
-set(USE_SVG TRUE)
-set(SVG2PNG TRUE)
-set(svg2png_scaling 32 48 96)
-set(svg2png_scaling_flag 32 48 96)
-set(svg2png_scaling_nav 32 48 96)
-   
-set(DBUS_USE_SYSTEM_BUS FALSE)
-set(BUILD_MAPTOOL TRUE)
+IF(NOT CMAKE_BUILD_TYPE)
+   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
+ENDIF(NOT CMAKE_BUILD_TYPE)
 
 # install path
 set(BIN_DIR bin)
@@ -73,240 +22,539 @@ set(LOCALE_DIR share)
 set(IMAGE_DIR share/navit/xpm)
 set(LIB_DIR lib)
 
-# set platform defaults
-if(WIN32)
-   set_with_reason(graphics/win32 "win32" TRUE)
-   set_with_reason(support/ezxml "win32" TRUE)
-   set_with_reason(support/libpng "win32" TRUE)
-   set_with_reason(support/win32 "win32" TRUE)
-   set_with_reason(speech/espeak "win32" TRUE)
-   set_with_reason(support/espeak "win32" TRUE)
-   set_with_reason(speech/speech_dispatcher "win32" FALSE)
-
-   # workaround for crosscompiling. need to get rid of pkg_config or
-   # change its search path
-   set_with_reason(binding/dbus "win32" FALSE)
-
-   # vehicle_file is broken for windows. use vehicle_wince instead
-   # whicle_wince isn't buildable on non-CE windows ssytems
-   #set_with_reason(vehicle/wince "win32: replace broken vehicle_file" TRUE)
-   set_with_reason(vehicle/file "win32: currently broken" FALSE)
-
-   # plugins currently not supported on windows
-   set_with_reason(USE_PLUGINS "win32: currently not supported" FALSE)
-
-   set(HAVE_API_WIN32_BASE 1)
-   set(HAVE_API_WIN32 1)
-   
-   # Image stuff
-   set_with_reason(USE_SVG "win32: SVGs currently not supported" FALSE)
-
-   set(BIN_DIR ./)
-   set(SHARE_DIR ./)
-   set(LOCALE_DIR ./)
-   set(IMAGE_DIR xpm)
-
-   list(APPEND NAVIT_LIBS winmm)
-
-endif()
-
-foreach(PLUMO ${ALL_PLUGINS} ${ALL_MODULES} USE_PLUGINS USE_ROUTING BUILD_MAPTOOL USE_SVG SVG2PNG DBUS_USE_SYSTEM_BUS)
-   set(OLDVALUE ${${PLUMO}})
-   OPTION(${PLUMO} "Enable/Disable module/plugin/support" ${${PLUMO}})
-   if ( NOT ${OLDVALUE} STREQUAL ${${PLUMO}} )
-      set(${PLUMO}_REASON "User defined")
-   endif()
+### Detect environment
+foreach(EXTRA_MODULE ${EXTRA_MODULES}) 
+   add_module(${EXTRA_MODULE} "extra module specified" TRUE)
 endforeach()
 
-## check for all nessessary progs and libs
+add_plugin(support/ezxml "native Glib found" FALSE)
+add_plugin(support/glib "native Glib found" FALSE)
+add_plugin(support/zlib "native zlib found" FALSE)
+add_plugin(support/libpng "native libpng found" FALSE)
+add_plugin(support/wordexp "native wordexp found" FALSE)
+add_module(font/freetype "freetype not found" FALSE)
+add_module(graphics/android "FreeType library not found" FALSE)
+add_module(graphics/gd "FreeType library not found" FALSE)
+add_module(graphics/gtk_drawing_area "FreeType library not found" FALSE)
+add_module(graphics/opengl "FreeType library not found" FALSE)
+add_module(graphics/sdl "FreeType library not found" FALSE)
+add_module(graphics/qt_qpainter "Qt libraries not found" FALSE)
+add_module(gui/qml "Qt Declarative not found" FALSE)
+add_module(gui/gtk "GTK libs not found" FALSE)
+add_module(vehicle/gpsd "gpsd lib not found" FALSE)
+add_module(vehicle/gypsy "gypsy lib not found" FALSE)
+add_module(vehicle/maemo "Default" FALSE)
+add_module(binding/dbus "dbus-glib-1 not found" FALSE)
+add_module(speech/dbus "dbus-glib-1 not found" FALSE)
+add_module(vehicle/gpsd_dbus "dbus-glib-1 not found" FALSE)
+add_module(speech/speech_dispatcher "speech_dispatcher lib not found" FALSE)
+add_module(autoload/osso "Default" FALSE)
+add_feature(ENABLE_NLS "default" TRUE)
+
+INCLUDE (CPack)
 INCLUDE (CheckIncludeFiles)
 INCLUDE (CheckLibraryExists)
-
-# SVG2PNG conversion
-set (IMAGE_CONVERTER_PROGS rsvg-convert ksvgtopng ksvgtopng4)
-find_program(IMAGE_CONVERTER NAMES ${IMAGE_CONVERTER_PROGS})
-if (SVG2PNG)
-   message(STATUS ${IMAGE_CONVERTER})
-   if (NOT IMAGE_CONVERTER)
-      message(WARNING "No SVG2PNG converter found. Please install one of the following tools: ${IMAGE_CONVERTER_PROGS}")
-      set_with_reason(SVG2PNG "no converter found" FALSE)
-   endif(NOT IMAGE_CONVERTER)
-endif(SVG2PNG)
-
-# Find glib
+INCLUDE (CheckFunctionExists)
+find_package(Glib)
+find_package(Gmodule)
+find_package(ZLIB)
+find_package(Freetype)
+find_package(SDL)
+find_package(SDL_ttf)
+find_package(SDL_image)
+find_package(OpenGL)
+find_package(GLUT)
 find_package(GTK2 2.6 COMPONENTS gtk)
-
-if(GTK2_GLIB_INCLUDE_DIR)
-    include_directories(${GTK2_GLIB_INCLUDE_DIR} ${GTK2_GLIBCONFIG_INCLUDE_DIR})
-    #   link_directories(${GTK2_GLIB_LIBRARY})
-    set(HAVE_GLIB 1)
-    list(APPEND NAVIT_LIBS ${GTK2_GLIB_LIBRARY})
-    if (GTK2_FOUND)
-       if (GTK2_GDKPIXBUF_INCLUDE_DIR)
-                   include_directories(${GTK2_INCLUDE_DIRS} ${GTK2_GDKPIXBUF_INCLUDE_DIR})
-            list(APPEND NAVIT_LIBS ${GTK2_LIBRARIES})
-            set(HAVE_GTK2 1)
-            set_with_reason(gui/gtk "GTK libs found" TRUE)
-            set_with_reason(graphics/gtk_drawing_area "GTK libs found" TRUE)
-       endif (GTK2_GDKPIXBUF_INCLUDE_DIR)
-    endif(GTK2_FOUND)
-else()
-    set_with_reason(support/glib "GTK libs not found" TRUE)
-endif()
-
-# QT stuff
+find_package(Gettext)
+find_package(PNG)
+find_package(DBusGLib)
+find_package(OpenSSL)
+find_package(Threads)
+libfind_pkg_check_modules(FONTCONFIG fontconfig)
+#Qt detection
 SET(QT_USE_QTSVG TRUE)
 SET(QT_USE_QTXML TRUE)
 SET(QT_USE_QTDECLARATIVE TRUE)
 find_package(Qt4 COMPONENTS QtCore QtGui QtXml QtDeclarative QtSvg OPTIONAL)
+#pkg-config based detection
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+   pkg_check_modules(QUESOGLC quesoglc)
+   pkg_check_modules(LIBGPSD libgpsd)
+   pkg_check_modules(LIBLOCATION liblocation)
+   pkg_check_modules(LIBOSSO libosso)
+endif(PKG_CONFIG_FOUND)
+#Simple checks
+CHECK_INCLUDE_FILES(wordexp.h HAVE_WORDEXP)
+CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
+CHECK_INCLUDE_FILES(byteswap.h HAVE_BYTESWAP_H)
+CHECK_LIBRARY_EXISTS(gypsy gypsy_control_get_default "" GYPSY_FOUND)
+CHECK_INCLUDE_FILES(libspeechd.h HAVE_LIBSPEECHD)
+CHECK_INCLUDE_FILES(sys/socket.h HAVE_SOCKET)
+CHECK_FUNCTION_EXISTS(snprintf   HAVE_SNPRINTF)
+CHECK_INCLUDE_FILES(locale.h HAVE_LC_MESSAGES)
+CHECK_INCLUDE_FILES(libintl.h HAVE_LIBINTL)
+CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
+CHECK_INCLUDE_FILES(getopt.h HAVE_GETOPT_H)
+CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
+CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
+
+### Configure build
+#Required libraries, supplied with navit
+if (NOT HAVE_LIBINTL)
+   add_plugin(intl_cmake "native libintl missing" TRUE)
+   set(USE_LIBGNUINTL TRUE)
+else()
+   CHECK_LIBRARY_EXISTS(intl libintl_fprintf "" NEEDS_LIBINTL)
+   if (NEEDS_LIBINTL)
+      list(APPEND NAVIT_LIBS intl)
+      set(INTL_LIBS intl)
+   endif(NEEDS_LIBINTL)
+endif(NOT HAVE_LIBINTL)
+
+
+if (CMAKE_USE_PTHREADS_INIT)
+   set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
+   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
+   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
+endif(CMAKE_USE_PTHREADS_INIT)
+if (Glib_FOUND)
+   set(HAVE_GLIB 1)
+   include_directories(${Glib_INCLUDE_DIRS})
+   list(APPEND NAVIT_LIBS ${Glib_LIBRARIES})
+else(Glib_FOUND)
+   set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS})
+endif(Glib_FOUND)
+if (Gmodule_FOUND)
+   set(HAVE_GMODULE 1)
+   include_directories(${Gmodule_INCLUDE_DIRS})
+   list(APPEND NAVIT_LIBS ${Gmodule_LIBRARIES})
+endif(Gmodule_FOUND)
+if(ZLIB_FOUND)
+   set(HAVE_ZLIB 1)
+   include_directories(${ZLIB_INCLUDE_DIRS})
+   list(APPEND NAVIT_LIBS ${ZLIB_LIBRARIES})
+else(ZLIB_FOUND)
+   message(STATUS "using internal zlib")
+   set_with_reason(support/zlib "native zlib missing" TRUE)
+endif(ZLIB_FOUND)
+if(OPENSSL_CRYPTO_LIBRARIES)
+   set(HAVE_LIBCRYPTO 1)
+   include_directories(${OPENSSL_INCLUDE_DIR})
+   list(APPEND NAVIT_LIBS ${OPENSSL_CRYPTO_LIBRARIES})
+endif()
+if(PNG_FOUND)
+   set(HAVE_PNG 1)
+else(PNG_FOUND)
+   message(STATUS "using internal libpng")
+   set_with_reason(support/libpng "native libpng missing" TRUE)
+endif(PNG_FOUND)
+if (NOT HAVE_WORDEXP)
+   message(STATUS "wordexp.h not found. use internal wordexp")
+   set_with_reason(support/wordexp "native wordexp missing" TRUE)
+endif()
+if (NOT Glib_FOUND)
+   set_with_reason(support/ezxml "Glib not found" TRUE)
+endif()
+
+if(FREETYPE_FOUND)
+   include_directories(${FREETYPE_INCLUDE_DIRS})
+   set_with_reason(font/freetype "freetype found" TRUE "${FREETYPE_LIBRARY};${FONTCONFIG_LIBRARIES}")
+   add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/navit/fonts")
+else(FREETYPE_FOUND)
+   MESSAGE("No freetype library found, graphics modules may not be available")
+   set_with_reason(graphics/android "FreeType library not found" FALSE)
+   set_with_reason(graphics/gd "FreeType library not found" FALSE)
+   set_with_reason(graphics/gtk_drawing_area "FreeType library not found" FALSE)
+   set_with_reason(graphics/opengl "FreeType library not found" FALSE)
+   set_with_reason(graphics/sdl "FreeType library not found" FALSE)
+endif(FREETYPE_FOUND)
+
+if(FONTCONFIG_FOUND)
+   set(HAVE_FONTCONFIG 1)
+endif(FONTCONFIG_FOUND)
+
 if (QT_FOUND)
-   if (QT_QTCORE_FOUND AND QT_QTGUI_FOUND)
-      set(graphics/qt_qpainter TRUE)
-       
+   if (QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND FREETYPE_FOUND)
+      include(${QT_USE_FILE})
+      set_with_reason(graphics/qt_qpainter "Qt libraries found" TRUE ${QT_LIBRARIES})
+
       if (QT_QTDECLARATIVE_FOUND AND QT_QTXML_FOUND)
-         set_with_reason(gui/qml "Qt libs found" TRUE)
+         set_with_reason(gui/qml "Qt Declarative found" TRUE ${QT_LIBRARIES})
       endif()
-      
+
       if (QT_QTSVG_FOUND)
          set(HAVE_QT_SVG 1)
       elseif( USE_SVG AND graphics/qt_qpainter)
          message( WARNING "QT compiled without SVG support")
       endif()
-      
-      include(${QT_USE_FILE})
-      list(APPEND NAVIT_LIBS ${QT_LIBRARIES})
    endif()
 endif(QT_FOUND)
 
-# zlib
-find_package(ZLIB)
-if(ZLIB_FOUND)
-   set(HAVE_ZLIB 1)
-   list(APPEND NAVIT_LIBS ${ZLIB_LIBRARIES})
-else()
-   message(STATUS "using internal zlib")
-   set_with_reason(support/zlib "native zlib missing" TRUE)
-endif(ZLIB_FOUND)
-
-# OpenGL
-if (graphics/opengl)
-   find_package(PkgConfig)
-   if(PKG_CONFIG_FOUND)
-      pkg_check_modules(QUESOGLC quesoglc)
-   endif(PKG_CONFIG_FOUND)
-   if (NOT QUESOGLC_FOUND)
-      set(graphics/opengl FALSE)
-      message (STATUS "no glc implementation found. Install Quesoglc for OpenGL support")
+if(GTK2_FOUND)
+   include_directories(${GTK2_INCLUDE_DIRS})
+   set(HAVE_GTK2 1)
+   set_with_reason(gui/gtk "GTK libs found" TRUE ${GTK2_LIBRARIES})
+   if(FREETYPE_FOUND)
+      set_with_reason(graphics/gtk_drawing_area "GTK libs found" TRUE ${GTK2_LIBRARIES})
+   endif(FREETYPE_FOUND)
+endif(GTK2_FOUND)
+
+CHECK_LIBRARY_EXISTS(freeimage FreeImage_Load "" FREEIMAGE_FOUND)
+if (QUESOGLC_FOUND AND FREETYPE_FOUND)
+   if (OPENGL_FOUND AND OPENGL_GLU_FOUND AND OPENGL_INCLUDE_DIR AND FREEIMAGE_FOUND)
+      message (STATUS "opengl found: ${OPENGL_gl_LIBRARY}")
+      include_directories(${OPENGL_INCLUDE_DIR})
+      set_with_reason(graphics/opengl "Found OpenGL and Quesoglc" TRUE ${OPENGL_gl_LIBRARY};${OPENGL_glu_LIBRARY};${GLUT_glut_LIBRARY};freeimage)
    else()
-      find_package(OpenGL)
-      if (OPENGL_FOUND AND OPENGL_GLU_FOUND AND OPENGL_INCLUDE_DIR)
-         message (STATUS "opengl found: ${OPENGL_gl_LIBRARY}")
-         include_directories(${OPENGL_INCLUDE_DIR})
-      else()
-         set(graphics/opengl FALSE)
-         message (STATUS "opengl not found")
-      endif()   
-   endif(NOT QUESOGLC_FOUND)
+      message (STATUS "opengl not found")
+   endif()
+else()
+   message (STATUS "no glc implementation found. Install Quesoglc for OpenGL support")
+endif(QUESOGLC_FOUND AND FREETYPE_FOUND)
+
+if(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND)
+   set(SDL_IMAGE 1)
+   if(SDLTTF_FOUND)
+      set(SDL_TTF 1)
+      list(APPEND SDL_LIBRARY ${SDLTTF_LIBRARY})
+   endif(SDLTTF_FOUND)
+   set_with_reason(graphics/sdl "SDL/SDL_image libs found" TRUE ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY})
+endif(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND)
+
+if (HAVE_LIBGPS)
+   set_with_reason(vehicle/gpsd "gpsd lib found" TRUE)
+endif(HAVE_LIBGPS)
+
+if (GYPSY_FOUND)
+   set_with_reason(vehicle/gypsy "gypsy lib found" TRUE)
+endif(GYPSY_FOUND)
+
+if(DBusGLib_FOUND)
+   include_directories(${DBusGLib_INCLUDE_DIRS})
+   set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBusGLib_LIBRARIES})
+   set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBusGLib_LIBRARIES})
+   set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBusGLib_LIBRARIES})
 endif()
 
-# SDL
-if (graphics/sdl)
-   find_package(SDL)
-   if (SDL_FOUND)
-      list(APPEND NAVIT_LIBS ${SDL_LIBRARY})
-      find_package(SDL_ttf)
-      if(SDLTTF_FOUND)
-         set(SDL_TTF 1)
-         list(APPEND NAVIT_LIBS ${SDLTTF_LIBRARY})
-      endif(SDLTTF_FOUND)
-   else()
-      set_with_reason(graphics/sdl "SDL libs missing" FALSE)
-   endif(SDL_FOUND)   
+if (HAVE_LIBSPEECHD)
+   set_with_reason(speech/speech_dispatcher "speech_dispatcher lib found" TRUE speechd)
+endif(HAVE_LIBSPEECHD)
 
-   find_package(SDL_image)
-   if (SDLIMAGE_FOUND)
-      list(APPEND NAVIT_LIBS ${SDLIMAGE_LIBRARY})
-      set(SDL_IMAGE 1)
+if (GETTEXT_FOUND)
+   execute_process(COMMAND echo "<test/>" COMMAND xgettext -L glade - RESULT_VARIABLE GETTEXT_RET)
+   if ("${GETTEXT_RET}" STREQUAL "0")
+      set(XGETTEXT_GLADE TRUE)
    else()
-      set_with_reason(graphics/sdl "SDL_image libs missing" FALSE)
-   endif(SDLIMAGE_FOUND)   
-endif()
+      set(XGETTEXT_GLADE FALSE)
+   endif()
+endif(GETTEXT_FOUND)
 
-# freetype
-find_package(Freetype)
-if (FREETYPE_FOUND)
-   include_directories(${FREETYPE_INCLUDE_DIRS})
-endif(FREETYPE_FOUND)
+if (LIBLOCATION_FOUND)
+    set_with_reason(vehicle/maemo "Maemo location library found" TRUE ${LIBLOCATION_LIBRARIES})
+endif(LIBLOCATION_FOUND)
+
+if (LIBOSSO_FOUND)
+    set_with_reason(autoload/osso "Maemo osso library found" TRUE ${LIBOSSO_LIBRARIES})
+endif(LIBOSSO_FOUND)
+
+#Independent modules
+add_module(graphics/null "Default" TRUE)
+add_module(osd/core "Default" TRUE)
+add_module(vehicle/demo "Default" TRUE)
+add_module(vehicle/file "Default" TRUE)
+add_module(vehicle/null "Default" FALSE)
+add_module(gui/internal "Default" TRUE)
+add_module(map/binfile "Default" TRUE)
+add_module(map/filter "Default" TRUE)
+if(NOT MSVC)
+add_module(map/mg "Default" TRUE)
+endif(NOT MSVC)
+add_module(map/shapefile "Default" TRUE)
+add_module(map/textfile "Default" TRUE)
+add_module(map/csv "Default" TRUE)
+add_module(speech/cmdline "Default" TRUE)
+
+#Modules without test yet
+add_module(plugin/pedestrian "Default" FALSE)
+add_module(speech/android "Default" FALSE)
+add_module(speech/espeak "Default" FALSE)
+add_plugin(support/espeak "Default" FALSE)
+add_module(vehicle/android "Default" FALSE)
+add_module(vehicle/iphone "Default" FALSE)
+add_module(vehicle/wince "Default" FALSE)
 
-CHECK_INCLUDE_FILES(wordexp.h HAVE_WORDEXP)
-if (NOT HAVE_WORDEXP)
-  set_with_reason(support/wordexp "native wordexp missing" TRUE)
-  message(STATUS "wordexp.h not found. use internal wordexp")
+# other features
+add_feature(USE_PLUGINS "default" TRUE)
+add_feature(SHARED_LIBNAVIT "default" FALSE)
+add_feature(USE_ROUTING "default" TRUE)
+add_feature(USE_SVG "default" TRUE)
+add_feature(SVG2PNG "default" TRUE)
+add_feature(SAMPLE_MAP "default" TRUE)
+
+IF(NOT svg2png_scaling)
+   set(svg2png_scaling 0 32 48 64)
+ENDIF()
+IF(NOT svg2png_scaling_flag)
+   set(svg2png_scaling_flag 32)
+ENDIF()
+IF(NOT svg2png_scaling_nav)
+   set(svg2png_scaling_nav 64)
+ENDIF()
+
+add_feature(DBUS_USE_SYSTEM_BUS "default" FALSE)
+add_feature(BUILD_MAPTOOL "default" TRUE)
+add_feature(XSL_PROCESSING "default" TRUE)
+
+find_program(SAXON NAMES saxon saxon8 saxon-xslt saxonb-xslt)
+if(NOT SAXON)
+   cfg_feature(XSL_PROCESSING "Saxon missing" FALSE)
 endif()
 
-# gpsd
-CHECK_INCLUDE_FILES(gps.h HAVE_LIBGPS)
-if ( NOT HAVE_LIBGPS)
-   set_with_reason(vehicle/gpsd "gpsd lib missing" FALSE)
-   set_with_reason(vehicle/gpsd_dbus "gpsd lib missing" FALSE)
+if (NOT XSL_PROCESSING)
+   message(WARNING "XSLT processing disabled. You have to configure navit.xml yourself, or enable XSLT processing.")
 endif()
 
-# gypsy
-CHECK_LIBRARY_EXISTS(gypsy gypsy_control_get_default "" GYPSY_FOUND)
-if (NOT GYPSY_FOUND)
-   set_with_reason(vehicle/gypsy "gypsy lib missing" FALSE)
-endif(NOT GYPSY_FOUND)   
+### Platform specific settings
+if(NOT CACHE_SIZE)
+   SET(CACHE_SIZE 1048576)
+endif(CACHE_SIZE)
 
-# gettext
-find_package(Gettext)
+if(WIN32 OR WINCE)
+   SET(CMAKE_EXECUTABLE_SUFFIX ".exe")
+   add_module(graphics/win32 "Windows detected" TRUE)
+   add_plugin(support/win32 "Windows detected" TRUE)
 
-# DBUS
-if(binding/dbus)
-   find_package(PkgConfig)
-   if(PKG_CONFIG_FOUND)
-      pkg_check_modules(DBUS_GLIB dbus-glib-1)
-      if(DBUS_GLIB_FOUND)
-         include_directories(${DBUS_GLIB_INCLUDE_DIRS})
-         list(APPEND NAVIT_LIBS ${DBUS_GLIB_LIBRARIES})
-         set_with_reason(speech/dbus "dbus-glib-1 found" TRUE)
-         set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE)
-      else()
-         set_with_reason(binding/dbus "dbus-glib-1 missing" FALSE)
+   SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+   set_with_reason(support/ezxml "Windows detected" TRUE)
+   set_with_reason(speech/espeak "Windows detected" TRUE)
+   set_with_reason(support/espeak "Windows detected" TRUE)
+
+   # vehicle_file is broken for windows. use vehicle_wince instead
+   # whicle_wince isn't buildable on non-CE windows ssytems
+
+   # plugins currently not supported on windows
+   set_with_reason(USE_PLUGINS "win32: currently not supported" FALSE)
+
+   set(HAVE_API_WIN32_BASE 1)
+   set(EZXML_NOMMAP 1)
+
+   # Image stuff
+   if(NOT graphics/qt_qpainter)
+      set_with_reason(USE_SVG "win32: SVGs currently not supported" FALSE)
+   else(NOT graphics/qt_qpainter)
+      MESSAGE(STATUS "win32: SVGs may not be supported by every available graphics")
+   endif(NOT graphics/qt_qpainter)
+
+   set(BIN_DIR ./)
+   set(SHARE_DIR ./)
+   set(LOCALE_DIR ./)
+   set(IMAGE_DIR xpm)
+
+   
+   if(HAVE_GTK2 AND NOT MSVC)
+      #GTK requires special compile flags
+      add_definitions("-mms-bitfields")
+   endif(HAVE_GTK2 AND NOT MSVC)
+   if(MSVC AND support/espeak)
+      add_definitions(-DPLATFORM_WINDOWS)
+   endif(MSVC AND support/espeak)
+   CHECK_LIBRARY_EXISTS(ws2_32 WSAStartup "" HAVE_WINSOCK)
+   if(HAVE_WINSOCK)
+      list(APPEND NAVIT_LIBS ws2_32)
+   else()
+      CHECK_LIBRARY_EXISTS(ws2 WSAStartup "" HAVE_WINSOCK_2)
+      if(HAVE_WINSOCK_2)
+         set(HAVE_WINSOCK 1)
+         list(APPEND NAVIT_LIBS ws2)
       endif()
-   endif()
-endif()
+   endif(HAVE_WINSOCK)
 
+   if(MSVC)
+       add_plugin(support/xgetopt "Windows detected" TRUE)
+       set(ENABLE_NLS FALSE)
+   else(MSVC)
+       set(ENABLE_NLS TRUE)
+   endif(MSVC)
+   enable_language(RC)
 
-# speech
-if(${speech/speech_dispatcher})
-   CHECK_INCLUDE_FILES(libspeechd.h HAVE_LIBSPEECHD)
-   if (NOT HAVE_LIBSPEECHD)
-      set_with_reason(speech/speech_dispatcher "speech_dispatcher lib missing" FALSE)
+   set(XSLTS "windows;${XSLTS}" CACHE STRING "define a semicolon seperated list of XSLTs to process")
+endif()
+if (WIN32)
+   set(HAVE_API_WIN32 1)
+   set(HAVE_STDINT_H 1)
+   #set(BUILD_MAPTOOL FALSE)
+   set(SAMPLE_MAP FALSE)
+   list(APPEND NAVIT_LIBS winmm)
+endif()
+if(WINCE)
+   add_plugin(support/libc "wince detected" TRUE)
+   set(HAVE_API_WIN32_CE 1)
+   set(BUILD_MAPTOOL FALSE)
+   set_with_reason(vehicle/file "wince: currently broken" FALSE)
+   set_with_reason(vehicle/wince "wince detected" TRUE)
+endif()
+
+set(LOCALEDIR "${LOCALE_DIR}/locale")
+
+find_program(BZCAT NAMES bzcat)
+if (SAMPLE_MAP)
+   if(CMAKE_CROSSCOMPILING)
+      cfg_feature(SAMPLE_MAP "downloading binary map because of cross compiling" TRUE)
+   elseif(NOT BZCAT)
+      cfg_feature(SAMPLE_MAP "downloading binary map because of missing bzcat" TRUE)
+   endif(CMAKE_CROSSCOMPILING)
+endif(SAMPLE_MAP)
+
+if(ANDROID)
+   find_program(ANDROID_LOCATION NAMES android android.bat)
+   find_program(ANT_LOCATION NAMES ant)
+   if (NOT ANT_LOCATION)
+      message_error("Could not find ant. Please install ant and add it to the search path.")
+   endif()
+   if (NOT ANDROID_LOCATION)
+      message_error( "Could not find 'Android SDK and AVD Manager'. Please install the android sdk and add the <android-sdk>/tools directory to the search path.")
    endif()
+   if (NOT XSL_PROCESSING)
+      message(WARNING "XSLT processing disabled. You have to configure navit.xml yourself, or enable XSLT processing.")
+   endif()
+   set(XSLTS "android;${XSLTS}" CACHE STRING "define a semicolon seperated list of XSLTs to process")
+   list(APPEND NAVIT_LIBS log)
+   set(HAVE_API_ANDROID 1)
+   set_with_reason(graphics/android "Android detected" TRUE)
+   set_with_reason(speech/android "Android detected" TRUE)
+   set_with_reason(vehicle/android "Android detected" TRUE)
+   set_with_reason(plugin/pedestrian "Android detected" TRUE)
+   cfg_feature(SHARED_LIBNAVIT "Android detected" TRUE)
+   
+   add_feature(XPM2PNG "Android detected" TRUE)
+   set(NAVIT_COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS} -fPIC")
+
+endif(ANDROID)
+
+# Image conversion
+find_program(IMAGE_CONVERTER NAMES convert)
+execute_process(COMMAND ${IMAGE_CONVERTER} -list format OUTPUT_VARIABLE CONVERT_FORMATS)
+if(CONVERT_FORMATS MATCHES ".*XPM[ *][ ]*XPM[ ]*r[w-].*")
+   set(IMAGE_CONVERTER_XPM ${IMAGE_CONVERTER})
 endif()
 
+if (SVG2PNG)
+   if (NOT IMAGE_CONVERTER_SVGZ)
+      set (SVG_CONVERTER_PROGS rsvg-convert ksvgtopng ksvgtopng4)
+      find_program(IMAGE_CONVERTER_SVGZ NAMES ${SVG_CONVERTER_PROGS})
+      if (NOT IMAGE_CONVERTER_SVGZ)
+         if(CONVERT_FORMATS MATCHES ".*[ ]*SVG[ ]*r[w-].*")
+            set(IMAGE_CONVERTER_SVGZ ${IMAGE_CONVERTER})
+         endif()
+      endif()
+   endif(NOT IMAGE_CONVERTER_SVGZ)
+   if (NOT IMAGE_CONVERTER_SVG)
+      set(IMAGE_CONVERTER_SVG ${IMAGE_CONVERTER_SVGZ})
+   endif(NOT IMAGE_CONVERTER_SVG)
+
+   message(STATUS "SVG2PNG-Converter: ${IMAGE_CONVERTER_SVGZ}")
+   if (NOT IMAGE_CONVERTER_SVGZ)
+      message(WARNING "No SVG2PNG converter found. Please install one of the following tools: ${SVG_CONVERTER_PROGS}, or imagemagick with svg support")
+      set_with_reason(SVG2PNG "no converter found" FALSE)
+   endif(NOT IMAGE_CONVERTER_SVGZ)
+endif(SVG2PNG)
+
+if (XPM2PNG)
+   message(STATUS "XPM2PNG-Converter: ${IMAGE_CONVERTER_XPM}")
+   if (NOT IMAGE_CONVERTER_XPM)
+      message(WARNING "No XPM2PNG converter found. Please install imagemagick with xpm support")
+      set_with_reason(XPM2PNG "no converter found" FALSE)
+   endif(NOT IMAGE_CONVERTER_XPM)
+endif(XPM2PNG)
+
+set(XSLTS ${XSLTS} CACHE STRING "define a semicolon seperated list of XSLTs to process")
 
 # Plugins
 if(USE_PLUGINS)
    set(MODULE_BUILD_TYPE "MODULE")
-   list(APPEND NAVIT_COMPILE_FLAGS -fPIC)
-   message(STATUS "Use plugins: ${MODULE_BUILD_TYPE}")
+   add_definitions("-fPIC")
+   list(APPEND NAVIT_LIBS dl)
 else()
    set(MODULE_BUILD_TYPE "STATIC")
 endif(USE_PLUGINS)
+message(STATUS "Use plugins: ${MODULE_BUILD_TYPE}")
+
+if (SHARED_LIBNAVIT)
+  set(NAVIT_CORE_BUILD_TYPE "STATIC")
+else(SHARED_LIBNAVIT)
+  set(NAVIT_CORE_BUILD_TYPE "SHARED")
+endif(SHARED_LIBNAVIT)
 
 CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
 CHECK_INCLUDE_FILES ("sys/param.h;sys/mount.h" HAVE_SYS_MOUNT_H)
-#CHECK_INCLUDE_FILES (windows.h HAVE_API_WIN32_BASE)
+CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
+CHECK_FUNCTION_EXISTS (getcwd HAVE_GETCWD)
+CHECK_FUNCTION_EXISTS (memalign HAVE_MEMALIGN)
+CHECK_FUNCTION_EXISTS (valloc HAVE_VALLOC)
+CHECK_FUNCTION_EXISTS (posix_memalign HAVE_POSIX_MEMALIGN)
+CHECK_FUNCTION_EXISTS (popen HAVE_POPEN)
+CHECK_FUNCTION_EXISTS (_atoi64 HAVE__ATOI64)
+
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
+add_definitions("-Wall")
+
+if (NOT NAVIT_DEPENDENCY_ERROR)
+   message("\nSummary:\n")
+
+   set(SUMMARY_COMPONENTS ${ALL_PLUGINS} ${ALL_MODULES})
+   list(SORT SUMMARY_COMPONENTS)
+
+   set(LAST_TYPE NONE)
+   foreach ( SUMMARY_COMP ${SUMMARY_COMPONENTS})
+      # split path to type and name
+      string(REPLACE "/" ";" SUMMARY_COMP_LIST ${SUMMARY_COMP})
+      list(GET SUMMARY_COMP_LIST 0 SUMMARY_COMP_TYPE)
+      list(LENGTH SUMMARY_COMP_LIST SUMMARY_COMP_LIST_LENGTH)
+      if ( SUMMARY_COMP_LIST_LENGTH GREATER 1 )
+         list(GET SUMMARY_COMP_LIST 1 SUMMARY_COMP_NAME)
+      else()
+         set(SUMMARY_COMP_NAME ${SUMMARY_COMP})
+      endif()
+      if ( NOT ${LAST_TYPE} STREQUAL ${SUMMARY_COMP_TYPE})
+         message("\n--->>> ${SUMMARY_COMP_TYPE}")
+         set(LAST_TYPE ${SUMMARY_COMP_TYPE})
+      endif()
+      if (${SUMMARY_COMP})
+         message("Enabled   ${SUMMARY_COMP_NAME} ( ${${SUMMARY_COMP}_REASON} )")
+      else()
+         message("Disabled  ${SUMMARY_COMP_NAME} ( ${${SUMMARY_COMP}_REASON} )")
+      endif()
+   endforeach()
+
+   list(SORT ALL_FEATURES)
+   message("\n--->>> Features")
+   foreach ( FEATURE ${ALL_FEATURES})
+      if ( ${FEATURE} )
+         message("Enabled   ${FEATURE} ( ${${FEATURE}_REASON} )")
+      else()
+         message("Disabled  ${FEATURE} ( ${${FEATURE}_REASON} )")
+      endif()
+   endforeach()
+   
+   if (XSL_PROCESSING)
+      if (XSLTS)
+         message("\nProcessing XSLTS: ${XSLTS}")
+      else()
+         message("\nProcessing XSLTS: NONE")
+      endif(XSLTS)
+   endif(XSL_PROCESSING)
+   
+   message("\nTo configure your build use 'cmake -L' to find changeable variables and run cmake again with 'cmake -D <var-name>=<your value> ...'.")
+endif(NOT NAVIT_DEPENDENCY_ERROR)
+
 add_subdirectory (navit)
 add_subdirectory (man)
 
 if (GETTEXT_FOUND)
    add_subdirectory (po)
+   #install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale DESTINATION ${LOCALE_DIR})
 endif(GETTEXT_FOUND)
 
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale DESTINATION ${LOCALE_DIR})
+