PROJECT(vlc)

ENABLE_TESTING()

# Set the module path
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# Our own include
include( vlc_module_funcs )

# Our config
include( config )

# Global definitions
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-D__LIBVLC__)
# Large file support for Solaris and Linux:
add_definitions(-D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE)
# Thread safety:
add_definitions(-D_REENTRANT -D_THREAD_SAFE)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Needed for glibc:
add_definitions(-D_GNU_SOURCE)

# Our main include directories
include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)

# our sources:
add_subdirectory(libs/loader)
add_subdirectory(src)
add_subdirectory(modules)
add_subdirectory(po)

# Enable uninstall
configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/extras/buildsystem/cmake/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

add_custom_target(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

# Target to reinstall the CMake files (until cmake gets defaulted)
add_custom_target(recmake
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && sh "${CMAKE_CURRENT_SOURCE_DIR}/extras/buildsystem/cmake/scripts/convert_vlc_to_cmake.sh")

# Enable CPack: Automatic package creation

set(README "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(LICENCE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")

if(APPLE)
set(README "${CMAKE_CURRENT_SOURCE_DIR}/extras/package/macosx/README.MacOSX.rtf")
set(LICENCE "") # FIXME: Mac OS X's Package Maker doesn't allow non .*
endif(APPLE)

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "VLC Media Player")
set(CPACK_PACKAGE_VENDOR "VideoLAN Team")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${README})
set(CPACK_RESOURCE_FILE_LICENSE ${LICENCE})
set(CPACK_PACKAGE_VERSION_MAJOR "${VLC_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VLC_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VLC_VERSION_PATCH}${VLC_VERSION_EXTRA}")

include(CPack)
