--- /dev/null
+project(LIBTEVENT C)
+# provides dirs and definec C only project
+# LIBTEVENT_SOURCE_DIR
+# LIBTEVENT_BINARY_DIR
+
+# WITH_LIBTEVENT should be set if it is not built as a standalone project.
+if (NOT WITH_LIBTEVENT)
+ # Required cmake version
+ cmake_minimum_required(VERSION 2.6.0)
+
+ # global needed variables
+ set(APPLICATION_NAME tevent)
+
+ # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
+ set(CMAKE_MODULE_PATH
+ ${LIBTEVENT_SOURCE_DIR}/cmake/Modules
+ )
+
+ # add definitions
+ include(DefineCMakeDefaults)
+ include(DefineCompilerFlags)
+ include(DefineInstallationPaths)
+ include(CPackConfig.cmake)
+
+ # disallow in-source build
+ include(MacroEnsureOutOfSourceBuild)
+ macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${APPLICATION_NAME} [options]' there.")
+
+ # libreplace
+ set(WITH_LIBREPLACE TRUE)
+
+ if (EXISTS ${${LIBTEVENT_SOURCE_DIR}}/replace)
+ add_subdirectory(replace)
+ elseif (EXISTS ${LIBTEVENT_SOURCE_DIR}/../replace)
+ add_subdirectory(${LIBTEVENT_SOURCE_DIR}/../replace ${LIBTEVENT_BINARY_DIR}/replace)
+ else (EXISTS ${${LIBTEVENT_SOURCE_DIR}}/replace)
+ message(FATAL_ERROR "Could not find libreplace")
+ endif (EXISTS ${${LIBTEVENT_SOURCE_DIR}}/replace)
+
+ # talloc
+ # TODO: move me to a file?
+ option(WITH_SYSTEM_TALLOC ON)
+
+ if (WITH_SYSTEM_TALLOC)
+ find_package(Talloc REQUIRED)
+ else (WITH_SYSTEM_TALLOC)
+ if (EXISTS ${LIBTEVENT_SOURCE_DIR}/../talloc)
+ set (WITH_LIBTALLOC TRUE)
+
+ add_subdirectory(${LIBTEVENT_SOURCE_DIR}/../talloc ${LIBTEVENT_BINARY_DIR}/talloc)
+
+ set (TALLOC_INCLUDE_DIRS ${TALLOC_PUBLIC_INCLUDE_DIRS})
+ set (TALLOC_LIBRARIES ${TALLOC_LIBARY})
+ else (EXISTS ${LIBTEVENT_SOURCE_DIR}/../talloc)
+ message(FATAL_ERROR "Could not find talloc")
+ endif (EXISTS ${LIBTEVENT_SOURCE_DIR}/../talloc)
+ endif (WITH_SYSTEM_TALLOC)
+
+endif (NOT WITH_LIBTEVENT)
+
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+
+check_include_file(sys/epoll.h HAVE_SYS_EPOLL_H)
+check_function_exists(epoll_create HAVE_EPOLL_CREATE)
+
+set(LIBTEVENT_VERSION "0.9.8")
+set(LIBTEVENT_SOVERSION "0")
+
+# define include dirs and the library for later use and cache it.
+set(LIBTEVENT_PUBLIC_INCLUDE_DIRS
+ ${TALLOC_INCLUDE_DIRS}
+ ${LIBTEVENT_SOURCE_DIR}
+ CACHE INTERNAL "libreplace public include directories"
+)
+
+set(LIBTEVENT_PRIVATE_INCLUDE_DIRS
+ ${LIBREPLACE_PUBLIC_INCLUDE_DIRS}
+ ${LIBTEVENT_PUBLIC_INCLUDE_DIRS}
+ ${LIBTEVENT_BINARY_DIR}
+)
+
+set(LIBTEVENT_LIBRARY
+ tevent
+ CACHE INTERNAL "libtevent library"
+)
+
+add_definitions(${CMAKE_PLATFORM_DEFINITIONS})
+include_directories(${LIBTEVENT_PRIVATE_INCLUDE_DIRS})
+
+set(tevent_HDRS
+ tevent.h
+)
+
+set(tevent_SRCS
+ tevent.c
+ tevent_debug.c
+ tevent_fd.c
+ tevent_immediate.c
+ tevent_liboop.c
+ tevent_queue.c
+ tevent_req.c
+ tevent_select.c
+ tevent_signal.c
+ tevent_standard.c
+ tevent_timed.c
+ tevent_util.c
+ tevent_wakeup.c
+)
+
+if (HAVE_SYS_EPOLL_H AND HAVE_EPOLL_CREATE)
+ add_definitions(-DHAVE_SYS_EPOLL_H=1 -DHAVE_EPOLL_CREATE=2)
+ set(tevent_SRCS
+ tevent_epoll.c
+ )
+endif (HAVE_SYS_EPOLL_H AND HAVE_EPOLL_CREATE)
+
+# build libraries and binaries
+add_library(${LIBTEVENT_LIBRARY} SHARED ${tevent_SRCS})
+target_link_libraries(${LIBTEVENT_LIBRARY} ${LIBREPLACE_LIBRARY} ${TALLOC_LIBARIES})
+
+set_target_properties(
+ ${LIBTEVENT_LIBRARY}
+ PROPERTIES
+ VERSION
+ ${LIBTEVENT_VERSION}
+ SOVERSION
+ ${LIBTEVENT_SOVERSION}
+)
+
+set_target_properties(
+ ${LIBTEVENT_LIBRARY}
+ PROPERTIES
+ LINK_FLAGS
+ "-Wl,--version-script -Wl,'${LIBTEVENT_SOURCE_DIR}/tevent.exports'"
+)
+
+# Works only in Samba source tree
+#if (WITH_LIBTEVENT)
+# set(tevent_testsuite_SRCS
+# testsuite.c
+# )
+#
+# add_executable(tevent_testsuite ${tevent_testsuite_SRCS})
+# target_link_libraries(tevent_testsuite ${LIBTEVENT_LIBRARY})
+#endif (WITH_LIBTEVENT)
+
+# install files
+install(
+ TARGETS
+ ${LIBTEVENT_LIBRARY}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT Libraries
+)
+
+install(
+ FILES
+ ${tevent_HDRS}
+ DESTINATION
+ ${INCLUDE_INSTALL_DIR}
+ COMPONENT Header
+)
--- /dev/null
+# For help take a look at:
+# http://www.cmake.org/Wiki/CMake:CPackConfiguration
+
+### general settings
+set(CPACK_PACKAGE_NAME ${APPLICATION_NAME})
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The ${APPLICATION_NAME} library")
+#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_VENDOR "The Samba Team")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
+#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
+
+
+### versions
+set(CPACK_PACKAGE_VERSION_MAJOR "2")
+set(CPACK_PACKAGE_VERSION_MINOR "0")
+set(CPACK_PACKAGE_VERSION_PATCH "1")
+set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+
+
+### source generator
+set(CPACK_SOURCE_GENERATOR "TGZ")
+set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
+
+include(CPack)
--- /dev/null
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+@CHECK_PROTOTYPE_DEFINITION_HEADER@
+
+static void cmakeRequireSymbol(int dummy, ...) {
+ (void) dummy;
+}
+
+static void checkSymbol(void) {
+#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
+ cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
+#endif
+}
+
+@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
+ return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
+}
+
+#ifdef __CLASSIC_C__
+int main() {
+ int ac;
+ char*av[];
+#else
+int main(int ac, char *av[]) {
+#endif
+ checkSymbol();
+ if (ac > 1000) {
+ return *av[0];
+ }
+ return 0;
+}
--- /dev/null
+# - Check if the protoype we expect is correct.
+# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
+#
+# FUNCTION - The name of the function (used to check if prototype exists)
+# PROTOTYPE- The prototype to check.
+# RETURN - The return value of the function.
+# HEADER - The header files required.
+# VARIABLE - The variable to store the result.
+#
+# Example:
+#
+# check_prototype_definition(getpwent_r
+# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
+# "NULL"
+# "unistd.h;pwd.h"
+# SOLARIS_GETPWENT_R)
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+
+
+function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
+
+ if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+ set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
+
+ set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ if (CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_PROTOTYPE_DEFINITION_LIBS
+ "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+ else(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_PROTOTYPE_DEFINITION_LIBS)
+ endif(CMAKE_REQUIRED_LIBRARIES)
+ if (CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_SYMBOL_EXISTS_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_SYMBOL_EXISTS_INCLUDES)
+ endif(CMAKE_REQUIRED_INCLUDES)
+
+ foreach(_FILE ${_HEADER})
+ set(CHECK_PROTOTYPE_DEFINITION_HEADER
+ "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
+ endforeach(_FILE)
+
+ set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
+ set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
+ set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
+
+ #configure_file("${CMAKE_ROOT}/Modules/CheckPrototypeDefinition.c.in"
+ # "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
+ configure_file("${CMAKE_MODULE_PATH}/CheckPrototypeDefinition.c.in"
+ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
+
+ file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
+
+ try_compile(${_VARIABLE}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
+ "${CHECK_PROTOTYPE_DEFINITION_LIBS}"
+ "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ if (${_VARIABLE})
+ set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
+ "${OUTPUT}\n\n")
+ else (${_VARIABLE})
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+ set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
+ "${OUTPUT}\n\n${_SOURCE}\n\n")
+ endif (${_VARIABLE})
+ endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+
+endfunction(CHECK_PROTOTYPE_DEFINITION)
--- /dev/null
+#include <sys/types.h>
+#include <signal.h>
+
+#ifdef signal
+# undef signal
+#endif
+
+#ifdef __cplusplus
+extern "C" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+
+#ifdef __CLASSIC_C__
+int main() {
+#else
+int main(void) {
+#endif
+ return 0;
+}
--- /dev/null
+# - Check for the signal handler return type.
+# CHECK_SIGNAL_TYPE(VARIABLE)
+# Test for the return type of the signal handler defined in <signal.h>
+#
+# VARIABLE - variable to return result
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+#
+
+#=============================================================================
+# Copyright 2010 Andreas Schneider <mail@cynapses.org>.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+function(CHECK_SIGNAL_TYPE _VARIABLE)
+ if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+ message(STATUS "Check for signal return type in <signal.h>")
+
+ #configure_file(${CMAKE_ROOT}/Module/CheckSignalType.c.in
+ # ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSignalType.c @ONLY)
+ configure_file(${CMAKE_MODULE_PATH}/CheckSignalType.c.in
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSignalType.c @ONLY)
+ try_compile(CMAKE_TEST_SIGNAL_TYPE
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSignalType.c
+ CMAKE_FLAGS
+ -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
+ OUTPUT_VARIABLE
+ OUTPUT)
+ if (CMAKE_TEST_SIGNAL_TYPE)
+ message(STATUS "Check for signal handler return type 'void' - found")
+ set(${_VARIABLE} void CACHE INTERNAL "signal handler return type")
+
+ file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
+ "Determining if signal handler return type is void passed with "
+ "the following output:\n${OUTPUT}\n\n")
+ else (CMAKE_TEST_SIGNAL_TYPE)
+ message(STATUS "Check for signal handler return type 'void' - not found")
+ set (_VARIABLE int CACHE INTERNAL "signal handler return type")
+ file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+ "Determining if signal handler return type is void failed with "
+ "the following output:\n${OUTPUT}\n\n")
+ endif (CMAKE_TEST_SIGNAL_TYPE)
+ endif ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+endfunction(CHECK_SIGNAL_TYPE)
--- /dev/null
+# Always include srcdir and builddir in include path
+# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
+# about every subdir
+# since cmake 2.4.0
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# Put the include dirs which are in the source or build tree
+# before all other include dirs, so the headers in the sources
+# are prefered over the already installed ones
+# since cmake 2.4.1
+set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
+
+# Use colored output
+# since cmake 2.4.0
+set(CMAKE_COLOR_MAKEFILE ON)
+
+# Define the generic version of the libraries here
+set(GENERIC_LIB_VERSION "0.1.0")
+set(GENERIC_LIB_SOVERSION "0")
+
+# Set the default build type to release with debug info
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE RelWithDebInfo
+ CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ )
+endif (NOT CMAKE_BUILD_TYPE)
--- /dev/null
+# define system dependent compiler flags
+
+include(CheckCCompilerFlag)
+
+if (UNIX AND NOT WIN32)
+ if (CMAKE_SYSTEM_NAME MATCHES Linux)
+ set(CMAKE_PLATFORM_DEFINITIONS "-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_GNU_SOURCE")
+ endif (CMAKE_SYSTEM_NAME MATCHES Linux)
+
+ if (CMAKE_SYSTEM_NAME MATCHES BSD)
+ set(CMAKE_PLATFORM_DEFINITIONS "-D_GNU_SOURCE")
+ endif (CMAKE_SYSTEM_NAME MATCHES BSD)
+
+ if (CMAKE_COMPILER_IS_GNUCC)
+ # add -Wconversion ?
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute")
+
+ # with -fPIC
+ check_c_compiler_flag("-fPIC" WITH_FPIC)
+ if (WITH_FPIC)
+ add_definitions(-fPIC)
+ endif (WITH_FPIC)
+
+ check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR)
+ if (WITH_STACK_PROTECTOR)
+ add_definitions(-fstack-protector)
+ endif (WITH_STACK_PROTECTOR)
+
+ check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
+ if (WITH_FORTIFY_SOURCE)
+ add_definitions(-D_FORTIFY_SOURCE=2)
+ endif (WITH_FORTIFY_SOURCE)
+
+ endif (CMAKE_COMPILER_IS_GNUCC)
+
+ if (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ # with large file support
+ execute_process(
+ COMMAND
+ getconf LFS64_CFLAGS
+ OUTPUT_VARIABLE
+ _lfs_CFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ else (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ # with large file support
+ execute_process(
+ COMMAND
+ getconf LFS_CFLAGS
+ OUTPUT_VARIABLE
+ _lfs_CFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ if (_lfs_CFLAGS)
+ string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
+ add_definitions(${_lfs_CFLAGS})
+ endif (_lfs_CFLAGS)
+
+endif (UNIX AND NOT WIN32)
+
+# suppress warning about "deprecated" functions
+if (MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+endif (MSVC)
--- /dev/null
+if (UNIX)
+ IF (NOT APPLICATION_NAME)
+ MESSAGE(STATUS "${PROJECT_NAME} is used as APPLICATION_NAME")
+ SET(APPLICATION_NAME ${PROJECT_NAME})
+ ENDIF (NOT APPLICATION_NAME)
+
+ # Suffix for Linux
+ SET(LIB_SUFFIX
+ CACHE STRING "Define suffix of directory name (32/64)"
+ )
+
+ SET(EXEC_INSTALL_PREFIX
+ "${CMAKE_INSTALL_PREFIX}"
+ CACHE PATH "Base directory for executables and libraries"
+ )
+ SET(SHARE_INSTALL_PREFIX
+ "${CMAKE_INSTALL_PREFIX}/share"
+ CACHE PATH "Base directory for files which go to share/"
+ )
+ SET(DATA_INSTALL_PREFIX
+ "${SHARE_INSTALL_PREFIX}/${APPLICATION_NAME}"
+ CACHE PATH "The parent directory where applications can install their data")
+
+ # The following are directories where stuff will be installed to
+ SET(BIN_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/bin"
+ CACHE PATH "The ${APPLICATION_NAME} binary install dir (default prefix/bin)"
+ )
+ SET(SBIN_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/sbin"
+ CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
+ )
+ SET(LIB_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
+ CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/lib)"
+ )
+ SET(LIBEXEC_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/libexec"
+ CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/libexec)"
+ )
+ SET(PLUGIN_INSTALL_DIR
+ "${LIB_INSTALL_DIR}/${APPLICATION_NAME}"
+ CACHE PATH "The subdirectory relative to the install prefix where plugins will be installed (default is prefix/lib/${APPLICATION_NAME})"
+ )
+ SET(INCLUDE_INSTALL_DIR
+ "${CMAKE_INSTALL_PREFIX}/include"
+ CACHE PATH "The subdirectory to the header prefix (default prefix/include)"
+ )
+
+ SET(DATA_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}"
+ CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})"
+ )
+ SET(HTML_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/doc/HTML"
+ CACHE PATH "The HTML install dir for documentation (default data/doc/html)"
+ )
+ SET(ICON_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/icons"
+ CACHE PATH "The icon install dir (default data/icons/)"
+ )
+ SET(SOUND_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/sounds"
+ CACHE PATH "The install dir for sound files (default data/sounds)"
+ )
+
+ SET(LOCALE_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/locale"
+ CACHE PATH "The install dir for translations (default prefix/share/locale)"
+ )
+
+ SET(XDG_APPS_DIR
+ "${SHARE_INSTALL_PREFIX}/applications/"
+ CACHE PATH "The XDG apps dir"
+ )
+ SET(XDG_DIRECTORY_DIR
+ "${SHARE_INSTALL_PREFIX}/desktop-directories"
+ CACHE PATH "The XDG directory"
+ )
+
+ SET(SYSCONF_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/etc"
+ CACHE PATH "The ${APPLICATION_NAME} sysconfig install dir (default prefix/etc)"
+ )
+ SET(MAN_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/man"
+ CACHE PATH "The ${APPLICATION_NAME} man install dir (default prefix/man)"
+ )
+ SET(INFO_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/info"
+ CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
+ )
+endif (UNIX)
+
+if (WIN32)
+ # Same same
+ set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
+ set(SBIN_INSTALL_DIR "." CACHE PATH "-")
+ set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
+ set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
+ set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
+ set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
+ set(ICON_INSTALL_DIR "." CACHE PATH "-")
+ set(SOUND_INSTALL_DIR "." CACHE PATH "-")
+ set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
+endif (WIN32)
--- /dev/null
+# - Try to find Talloc
+# Once done this will define
+#
+# TALLOC_FOUND - system has Talloc
+# TALLOC_INCLUDE_DIRS - the Talloc include directory
+# TALLOC_LIBRARIES - Link these to use Talloc
+# TALLOC_DEFINITIONS - Compiler switches required for using Talloc
+#
+# Copyright (c) 2010 Andreas Schneider <asn@redhat.com>
+#
+# Redistribution and use is allowed according to the terms of the New
+# BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+
+if (TALLOC_LIBRARIES AND TALLOC_INCLUDE_DIRS)
+ # in cache already
+ set(TALLOC_FOUND TRUE PARENT_SCOPE)
+else (TALLOC_LIBRARIES AND TALLOC_INCLUDE_DIRS)
+ find_package(PkgConfig)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(_TALLOC talloc)
+ endif (PKG_CONFIG_FOUND)
+
+ find_path(TALLOC_INCLUDE_DIR
+ NAMES
+ talloc.h
+ PATHS
+ ${_TALLOC_INCLUDEDIR}
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+ find_library(TALLOC_LIBRARY
+ NAMES
+ talloc
+ PATHS
+ ${_TALLOC_LIBDIR}
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+ )
+
+ set(TALLOC_INCLUDE_DIRS
+ ${TALLOC_INCLUDE_DIR}
+ )
+
+ set(TALLOC_LIBRARIES
+ ${TALLOC_LIBRARIES}
+ ${TALLOC_LIBRARY}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Talloc DEFAULT_MSG TALLOC_LIBRARIES TALLOC_INCLUDE_DIRS)
+
+ # show the TALLOC_INCLUDE_DIRS and TALLOC_LIBRARIES variables only in the advanced view
+ mark_as_advanced(TALLOC_INCLUDE_DIRS TALLOC_LIBRARIES)
+
+endif (TALLOC_LIBRARIES AND TALLOC_INCLUDE_DIRS)
--- /dev/null
+# - MACRO_ADD_COMPILE_FLAGS(target_name flag1 ... flagN)
+
+# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
+# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+macro (MACRO_ADD_COMPILE_FLAGS _target)
+
+ get_target_property(_flags ${_target} COMPILE_FLAGS)
+ if (_flags)
+ set(_flags ${_flags} ${ARGN})
+ else (_flags)
+ set(_flags ${ARGN})
+ endif (_flags)
+
+ set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags})
+
+endmacro (MACRO_ADD_COMPILE_FLAGS)
--- /dev/null
+# - MACRO_ADD_LINK_FLAGS(target_name flag1 ... flagN)
+
+# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
+# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro (MACRO_ADD_LINK_FLAGS _target)
+
+ get_target_property(_flags ${_target} LINK_FLAGS)
+ if (_flags)
+ set(_flags "${_flags} ${ARGN}")
+ else (_flags)
+ set(_flags "${ARGN}")
+ endif (_flags)
+
+ set_target_properties(${_target} PROPERTIES LINK_FLAGS "${_flags}")
+
+endmacro (MACRO_ADD_LINK_FLAGS)
--- /dev/null
+# - MACRO_ADD_PLUGIN(name [WITH_PREFIX] file1 .. fileN)
+#
+# Create a plugin from the given source files.
+# If WITH_PREFIX is given, the resulting plugin will have the
+# prefix "lib", otherwise it won't.
+#
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
+# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
+# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+macro (MACRO_ADD_PLUGIN _target_NAME _with_PREFIX)
+
+ if (${_with_PREFIX} STREQUAL "WITH_PREFIX")
+ set(_first_SRC)
+ else (${_with_PREFIX} STREQUAL "WITH_PREFIX")
+ set(_first_SRC ${_with_PREFIX})
+ endif (${_with_PREFIX} STREQUAL "WITH_PREFIX")
+
+ add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
+
+ if (_first_SRC)
+ set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
+ endif (_first_SRC)
+
+endmacro (MACRO_ADD_PLUGIN _name _sources)
--- /dev/null
+# - macro_copy_file(_src _dst)
+# Copies a file to ${_dst} only if ${_src} is different (newer) than ${_dst}
+#
+# Example:
+# macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/icon.png ${CMAKE_CURRENT_BINARY_DIR}/.)
+# Copies file icon.png to ${CMAKE_CURRENT_BINARY_DIR} directory
+#
+# Copyright (c) 2006-2007 Wengo
+# Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING file.
+
+
+macro (macro_copy_file _src _dst)
+ # Removes all path containing .svn or CVS or CMakeLists.txt during the copy
+ if (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
+
+ if (CMAKE_VERBOSE_MAKEFILE)
+ message(STATUS "Copy file from ${_src} to ${_dst}")
+ endif (CMAKE_VERBOSE_MAKEFILE)
+
+ # Creates directory if necessary
+ get_filename_component(_path ${_dst} PATH)
+ file(MAKE_DIRECTORY ${_path})
+
+ execute_process(
+ COMMAND
+ ${CMAKE_COMMAND} -E copy_if_different ${_src} ${_dst}
+ OUTPUT_QUIET
+ )
+ endif (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
+endmacro (macro_copy_file)
--- /dev/null
+# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
+
+ string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource)
+ if (_insource)
+ message(SEND_ERROR "${_errorMessage}")
+ message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.")
+ endif (_insource)
+
+endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
--- /dev/null
+# -helper macro to add a "doc" target with CMake build system.
+# and configure doxy.config.in to doxy.config
+#
+# target "doc" allows building the documentation with doxygen/dot on WIN32 and Linux
+# Creates .chm windows help file if MS HTML help workshop
+# (available from http://msdn.microsoft.com/workshop/author/htmlhelp)
+# is installed with its DLLs in PATH.
+#
+#
+# Please note, that the tools, e.g.:
+# doxygen, dot, latex, dvips, makeindex, gswin32, etc.
+# must be in path.
+#
+# Note about Visual Studio Projects:
+# MSVS has its own path environment which may differ from the shell.
+# See "Menu Tools/Options/Projects/VC++ Directories" in VS 7.1
+#
+# author Jan Woetzel 2004-2006
+# www.mip.informatik.uni-kiel.de/~jw
+
+
+FIND_PACKAGE(Doxygen)
+
+IF (DOXYGEN_FOUND)
+
+ # click+jump in Emacs and Visual Studio (for doxy.config) (jw)
+ IF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
+ SET(DOXY_WARN_FORMAT "\"$file($line) : $text \"")
+ ELSE (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
+ SET(DOXY_WARN_FORMAT "\"$file:$line: $text \"")
+ ENDIF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
+
+ #Build the documentation for libssh developpers if asked
+ IF (WITH_INTERNAL_DOC)
+ SET(CMAKE_INTERNAL_DOC "Yes")
+ ELSE (WITH_INTERNAL_DOC)
+ SET(CMAKE_INTERNAL_DOC "No")
+ ENDIF (WITH_INTERNAL_DOC)
+
+ # we need latex for doxygen because of the formulas
+ FIND_PACKAGE(LATEX)
+ IF (NOT LATEX_COMPILER)
+ MESSAGE(STATUS "latex command LATEX_COMPILER not found but usually required. You will probably get warnings and user inetraction on doxy run.")
+ ENDIF (NOT LATEX_COMPILER)
+ IF (NOT MAKEINDEX_COMPILER)
+ MESSAGE(STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.")
+ ENDIF (NOT MAKEINDEX_COMPILER)
+ IF (NOT DVIPS_CONVERTER)
+ MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
+ ENDIF (NOT DVIPS_CONVERTER)
+ FIND_PROGRAM(DOXYGEN_DOT_EXECUTABLE_PATH NAMES dot)
+ IF (DOXYGEN_DOT_EXECUTABLE_PATH)
+ SET(DOXYGEN_DOT_FOUND "YES")
+ ENDIF (DOXYGEN_DOT_EXECUTABLE_PATH)
+
+ IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
+ MESSAGE(STATUS "Generate ${CMAKE_CURRENT_BINARY_DIR}/doxy.config from doxy.config.in")
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in
+ ${CMAKE_CURRENT_BINARY_DIR}/doxy.config
+ @ONLY )
+ # use (configured) doxy.config from (out of place) BUILD tree:
+ SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
+ ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
+ # use static hand-edited doxy.config from SOURCE tree:
+ SET(DOXY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
+ IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
+ MESSAGE(STATUS "WARNING: using existing ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config instead of configuring from doxy.config.in file.")
+ ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
+ IF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
+ # using template doxy.config.in
+ MESSAGE(STATUS "Generate ${CMAKE_CURRENT_BINARY_DIR}/doxy.config from doxy.config.in")
+ CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in
+ ${CMAKE_CURRENT_BINARY_DIR}/doxy.config
+ @ONLY )
+ SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
+ ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
+ # failed completely...
+ MESSAGE(SEND_ERROR "Please create ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in (or doxy.config as fallback)")
+ ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
+
+ ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
+ ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
+
+ ADD_CUSTOM_TARGET(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doxy.config)
+
+ # create a windows help .chm file using hhc.exe
+ # HTMLHelp DLL must be in path!
+ # fallback: use hhw.exe interactively
+ IF (WIN32)
+ FIND_PACKAGE(HTMLHelp)
+ IF (HTML_HELP_COMPILER)
+ SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\doc\\html\\index.hhp")
+ STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
+ # MESSAGE(SEND_ERROR "DBG HHP_FILE=${HHP_FILE}")
+ ADD_CUSTOM_TARGET(winhelp ${HTML_HELP_COMPILER} ${HHP_FILE})
+ ADD_DEPENDENCIES (winhelp doc)
+
+ IF (NOT TARGET_DOC_SKIP_INSTALL)
+ # install windows help?
+ # determine useful name for output file
+ # should be project and version unique to allow installing
+ # multiple projects into one global directory
+ IF (EXISTS "${PROJECT_BINARY_DIR}/doc/html/index.chm")
+ IF (PROJECT_NAME)
+ SET(OUT "${PROJECT_NAME}")
+ ELSE (PROJECT_NAME)
+ SET(OUT "Documentation") # default
+ ENDIF(PROJECT_NAME)
+ IF (${PROJECT_NAME}_VERSION_MAJOR)
+ SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
+ IF (${PROJECT_NAME}_VERSION_MINOR)
+ SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
+ IF (${PROJECT_NAME}_VERSION_PATCH)
+ SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}")
+ ENDIF(${PROJECT_NAME}_VERSION_PATCH)
+ ENDIF(${PROJECT_NAME}_VERSION_MINOR)
+ ENDIF(${PROJECT_NAME}_VERSION_MAJOR)
+ # keep suffix
+ SET(OUT "${OUT}.chm")
+
+ #MESSAGE("DBG ${PROJECT_BINARY_DIR}/doc/html/index.chm \n${OUT}")
+ # create target used by install and package commands
+ INSTALL(FILES "${PROJECT_BINARY_DIR}/doc/html/index.chm"
+ DESTINATION "doc"
+ RENAME "${OUT}"
+ )
+ ENDIF(EXISTS "${PROJECT_BINARY_DIR}/doc/html/index.chm")
+ ENDIF(NOT TARGET_DOC_SKIP_INSTALL)
+
+ ENDIF(HTML_HELP_COMPILER)
+ # MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}")
+ ENDIF (WIN32)
+ENDIF(DOXYGEN_FOUND)