]> granicus.if.org Git - icinga2/commitdiff
Add cmake build files.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 3 Nov 2013 12:45:26 +0000 (13:45 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 3 Nov 2013 12:45:26 +0000 (13:45 +0100)
Refs #4962

84 files changed:
.gitignore
.vagrant-puppet/files/usr/local/bin/.gitignore [deleted file]
CMakeLists.txt [new file with mode: 0644]
INSTALL
cmake/BoostTestTargets.cmake [new file with mode: 0644]
cmake/BoostTestTargetsDynamic.h [new file with mode: 0644]
cmake/BoostTestTargetsIncluded.h [new file with mode: 0644]
cmake/BoostTestTargetsStatic.h [new file with mode: 0644]
cmake/CopyResourcesToBuildTree.cmake [new file with mode: 0644]
cmake/FindBISON.cmake [new file with mode: 0644]
cmake/FindFLEX.cmake [new file with mode: 0644]
cmake/FindGit.cmake [new file with mode: 0644]
cmake/FindMYSQL.cmake [new file with mode: 0644]
cmake/GNUInstallDirs.cmake [new file with mode: 0644]
cmake/GetForceIncludeDefinitions.cmake [new file with mode: 0644]
cmake/GetGitRevisionDescription.cmake [new file with mode: 0644]
cmake/GetGitRevisionDescription.cmake.in [new file with mode: 0644]
cmake/InstallConfig.cmake [new file with mode: 0644]
components/CMakeLists.txt [new file with mode: 0644]
components/checker/CMakeLists.txt [new file with mode: 0644]
components/cluster/CMakeLists.txt [new file with mode: 0644]
components/compat/CMakeLists.txt [new file with mode: 0644]
components/db_ido_mysql/CMakeLists.txt [new file with mode: 0644]
components/db_ido_mysql/idomysqlconnection.cpp
components/db_ido_mysql/idomysqlconnection.h
components/demo/CMakeLists.txt [new file with mode: 0644]
components/livestatus/CMakeLists.txt [new file with mode: 0644]
components/notification/CMakeLists.txt [new file with mode: 0644]
components/perfdata/CMakeLists.txt [new file with mode: 0644]
config.h.cmake [new file with mode: 0644]
doc/2.6-running-icinga.md
doc/4.2-global-variables.md
doc/CMakeLists.txt [new file with mode: 0644]
etc/CMakeLists.txt [new file with mode: 0644]
etc/init.d/icinga2.cmake [moved from etc/init.d/icinga2.in with 87% similarity]
icinga-app/CMakeLists.txt [new file with mode: 0644]
icinga-app/icinga.cpp
icinga-version.h.cmake [new file with mode: 0644]
icinga2.spec [moved from icinga2.spec.in with 93% similarity]
itl/CMakeLists.txt [new file with mode: 0644]
lib/CMakeLists.txt [new file with mode: 0644]
lib/base/CMakeLists.txt [new file with mode: 0644]
lib/base/application.cpp
lib/base/application.h
lib/base/i2-base.h
lib/base/process-unix.cpp
lib/base/registry.h
lib/base/scriptvariable.cpp
lib/base/scriptvariable.h
lib/base/stacktrace.cpp
lib/base/unix.h
lib/base/utility.cpp
lib/base/visibility.h [new file with mode: 0644]
lib/base/win32.h
lib/config/CMakeLists.txt [new file with mode: 0644]
lib/config/config_lexer.ll
lib/db_ido/CMakeLists.txt [new file with mode: 0644]
lib/db_ido/dbconnection.h
lib/db_ido/dbobject.h
lib/db_ido/dbquery.h
lib/db_ido/dbreference.h
lib/db_ido/dbtype.h
lib/db_ido/dbvalue.h
lib/db_ido/i2-db_ido.h [new file with mode: 0644]
lib/icinga/CMakeLists.txt [new file with mode: 0644]
pki/.gitignore [deleted file]
pki/CMakeLists.txt [new file with mode: 0644]
pki/icinga2-build-ca.cmake [moved from pki/icinga2-build-ca.in with 86% similarity]
pki/icinga2-build-key.cmake [moved from pki/icinga2-build-key.in with 92% similarity]
test/CMakeLists.txt [new file with mode: 0644]
test/test.cpp
third-party/CMakeLists.txt [new file with mode: 0644]
third-party/cJSON/CMakeLists.txt [new file with mode: 0644]
third-party/cJSON/cJSON.h
third-party/execvpe/CMakeLists.txt [new file with mode: 0644]
third-party/execvpe/execvpe.h
third-party/mmatch/CMakeLists.txt [new file with mode: 0644]
third-party/mmatch/mmatch.h
tools/CMakeLists.txt [new file with mode: 0644]
tools/icinga2-enable-feature.cmake [moved from tools/icinga2-enable-feature.in with 89% similarity]
tools/mkclass/CMakeLists.txt [new file with mode: 0644]
tools/mkclass/class_lexer.ll
tools/mkclass/classcompiler.cpp
tools/mkembedconfig/CMakeLists.txt [new file with mode: 0644]

index d0804d04d420eafa492a84f7a440a295a4bc592f..d19b44c16b0aa440a2e032d6f98bd7f2c6f98715 100644 (file)
@@ -1,47 +1,2 @@
-*.sdf
-*.opensdf
-*.suo
-*.lib
-*.exe
-*.pdb
-Debug
-Release
-*.vcxproj.user
-ipch
-*.gcda
-*.o
-*.a
-*.th
-.deps
-*.in
-Makefile
-*.log
-*.la
-*.lo
-*~
-aclocal.m4
-autom4te.cache
-config.guess
-config.h
-config.status
-config.sub
-configure
-config/ylwrap
-depcomp
-icinga-version.h
-install-sh
-libtool
-libtool.old
-ltdl
-ltmain.sh
-missing
-stamp-h1
-.libs
-icinga-app/icinga
-docs/dev
-m4/ylwrap
-m4/test-driver
-icinga2-*.tar.gz
-icinga2.spec
-packages
-.vagrant
\ No newline at end of file
+.vagrant
+build
\ No newline at end of file
diff --git a/.vagrant-puppet/files/usr/local/bin/.gitignore b/.vagrant-puppet/files/usr/local/bin/.gitignore
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9776152
--- /dev/null
@@ -0,0 +1,105 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+cmake_minimum_required(VERSION 2.6)
+project(icinga2)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
+string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
+
+set(ICINGA2_USER "icinga")
+set(ICINGA2_GROUP "icinga")
+set(ICINGA2_COMMAND_USER "icinga")
+set(ICINGA2_COMMAND_GROUP "icingacmd")
+
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
+set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE})
+
+set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
+set(CPACK_WIX_UPGRADE_GUID "68C75073-7CEF-4FC9-8DA5-581758729696")
+include(CPack)
+
+include(GetGitRevisionDescription)
+set(GIT_VERSION ${CPACK_PACKAGE_VERSION})
+git_describe(GIT_VERSION --tags)
+configure_file(icinga-version.h.cmake icinga-version.h)
+
+if(WIN32)
+  set(Boost_USE_STATIC_LIBS ON)
+  add_definitions(-DBOOST_ALL_NO_LIB)
+endif()
+
+find_package(Boost 1.41.0 COMPONENTS thread system program_options REQUIRED)
+link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${Boost_INCLUDE_DIRS})
+
+find_package(OpenSSL REQUIRED)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
+include_directories(
+  ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}/components
+  ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/components
+)
+
+#set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
+if(APPLE)
+  set(CMAKE_INSTALL_NAME_DIR "@executable_path/../lib/icinga2")
+endif(APPLE)
+
+if(MSVC)
+  add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+endif()
+
+set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
+set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
+
+include(CheckFunctionExists)
+check_function_exists(vfork HAVE_VFORK)
+check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
+check_function_exists(pipe2 HAVE_PIPE2)
+check_function_exists(BIO_f_zlib HAVE_BIOZLIB)
+
+include(GNUInstallDirs)
+configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+install(
+  FILES README COPYING COPYING.Exceptions AUTHORS ChangeLog INSTALL NEWS
+  DESTINATION ${CMAKE_INSTALL_DOCDIR}
+)
+
+include(CTest)
+enable_testing()
+
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+add_subdirectory(third-party)
+add_subdirectory(tools)
+add_subdirectory(lib)
+add_subdirectory(components)
+add_subdirectory(icinga-app)
+add_subdirectory(etc)
+add_subdirectory(itl)
+add_subdirectory(doc)
+add_subdirectory(test)
+add_subdirectory(pki)
\ No newline at end of file
diff --git a/INSTALL b/INSTALL
index 907f7b3a6dd61415c0fa324f2723d9d7d851f24e..6e83f15595b3dcd18218e69a9dfbf8f1d8922bfb 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -18,33 +18,19 @@ The following requirements need to be fulfilled in order to build the
 application using a dist tarball (package names for RHEL and Debian in
 parentheses):
 
+* cmake
 * GNU make (make)
 * C++ compiler (gcc-c++ on RHEL, build-essential on Debian)
 * OpenSSL library and header files (openssl-devel on RHEL, libssl-dev
                                     on Debian)
 * Boost library and header files (boost-devel on RHEL, libboost-all-dev
                                   on Debian)
+* GNU bison (bison)
+* GNU flex (flex)
 * optional: Doxygen (doxygen)
 * optional: MySQL (mysql-devel on RHEL, libmysqlclient-dev on Debian)
 * optional: Python (python-devel on RHEL, python-dev on Debian)
 
-Packaging Requirements
-----------------------
-
-In order to build a dist tarball for the application the following external
-software components need to be installed in addition to the build requirements
-mentioned above:
-
-* GNU Automake (automake)
-* GNU Autoconf (autoconf)
-* GNU Libtool (libtool and libtool-ltdl-devel on RHEL, libtool and
-               libltdl-dev on Debian)
-* GNU bison (bison)
-* GNU flex (flex)
-
-In order to build the dist tarball (using "make dist") you need sufficiently
-recent versions of the packages listed above.
-
 User Requirements
 -----------------
 
@@ -72,19 +58,14 @@ Building Icinga 2
 Once you have installed all the necessary build requirements you can build
 Icinga 2 using the following commands:
 
-$ ./configure
+$ mkdir build && cd build
+$ cmake ..
 $ make
 $ make install
 
-The configure script supports all the usual parameters one comes to expect
-from autoconf. In particular you may want to use --prefix to specify an
-alternative installation prefix.
+You can specify an alternative installation prefix using -DCMAKE_INSTALL_PREFIX:
 
-Note: The Git repository does not contain any auto-generated Autotools files,
-i.e. there is no 'configure' script. In this case you will need to regenerate
-the 'configure' script by running 'autogen.sh'. However, as an end-user you
-should reconsider whether you really want to use the code from the Git
-repository. In general it is advisable to use one of the dist tarballs instead.
+$ cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/icinga2
 
 Running Icinga 2
 ----------------
diff --git a/cmake/BoostTestTargets.cmake b/cmake/BoostTestTargets.cmake
new file mode 100644 (file)
index 0000000..f79f506
--- /dev/null
@@ -0,0 +1,274 @@
+# - Add tests using boost::test
+#
+# Add this line to your test files in place of including a basic boost test header:
+#  #include <BoostTestTargetConfig.h>
+#
+# If you cannot do that and must use the included form for a given test,
+# include the line
+#  // OVERRIDE_BOOST_TEST_INCLUDED_WARNING
+# in the same file with the boost test include.
+#
+#  include(BoostTestTargets)
+#  add_boost_test(<testdriver_name> SOURCES <source1> [<more sources...>]
+#   [FAIL_REGULAR_EXPRESSION <additional fail regex>]
+#   [LAUNCHER <generic launcher script>]
+#   [LIBRARIES <library> [<library>...]]
+#   [RESOURCES <resource> [<resource>...]]
+#   [TESTS <testcasename> [<testcasename>...]])
+#
+#  If for some reason you need access to the executable target created,
+#  it can be found in ${${testdriver_name}_TARGET_NAME} as specified when
+#  you called add_boost_test
+#
+# Requires CMake 2.6 or newer (uses the 'function' command)
+#
+# Requires:
+#      GetForceIncludeDefinitions
+#      CopyResourcesToBuildTree
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright Iowa State University 2009-2010.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+if(__add_boost_test)
+       return()
+endif()
+set(__add_boost_test YES)
+
+set(BOOST_TEST_TARGET_PREFIX "boosttest")
+
+if(NOT Boost_FOUND)
+       find_package(Boost 1.34.0 QUIET)
+endif()
+if("${Boost_VERSION}0" LESS "1034000")
+       set(_shared_msg
+               "NOTE: boost::test-based targets and tests cannot "
+               "be added: boost >= 1.34.0 required but not found. "
+               "(found: '${Boost_VERSION}'; want >=103400) ")
+       if(BUILD_TESTING)
+               message(FATAL_ERROR
+                       ${_shared_msg}
+                       "You may disable BUILD_TESTING to continue without the "
+                       "tests.")
+       else()
+               message(STATUS
+                       ${_shared_msg}
+                       "BUILD_TESTING disabled, so continuing anyway.")
+       endif()
+endif()
+
+include(GetForceIncludeDefinitions)
+include(CopyResourcesToBuildTree)
+
+if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")
+       set(_boosttesttargets_libs)
+       set(_boostConfig "BoostTestTargetsIncluded.h")
+       if(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
+               find_package(Boost 1.34.0 QUIET COMPONENTS unit_test_framework)
+       endif()
+       if(Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
+               set(_boosttesttargets_libs "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
+               if(Boost_USE_STATIC_LIBS)
+                       set(_boostConfig "BoostTestTargetsStatic.h")
+               else()
+                       if(NOT APPLE)
+                               set(_boostConfig "BoostTestTargetsDynamic.h")
+                       endif()
+               endif()
+       endif()
+       get_filename_component(_moddir ${CMAKE_CURRENT_LIST_FILE} PATH)
+       configure_file("${_moddir}/${_boostConfig}"
+               "${CMAKE_CURRENT_BINARY_DIR}/BoostTestTargetConfig.h"
+               COPYONLY)
+       include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+endif()
+
+function(add_boost_test _name)
+       if(NOT BUILD_TESTING)
+               return()
+       endif()
+       if("${CMAKE_VERSION}" VERSION_LESS "2.8.0")
+               if(NOT "${_boost_test_cmakever_pestered}x" EQUAL "${CMAKE_VERSION}x")
+                       message(STATUS
+                               "Not adding boost::test targets - CMake 2.8.0 or newer required, using ${CMAKE_VERSION}")
+                       set(_boost_test_cmakever_pestered
+                               "${CMAKE_VERSION}"
+                               CACHE
+                               INTERNAL
+                               ""
+                               FORCE)
+               endif()
+               return()
+       endif()
+
+       # parse arguments
+       set(_nowhere)
+       set(_curdest _nowhere)
+       set(_val_args
+               SOURCES
+               FAIL_REGULAR_EXPRESSION
+               LAUNCHER
+               LIBRARIES
+               RESOURCES
+               TESTS)
+       set(_bool_args
+               USE_COMPILED_LIBRARY)
+       foreach(_arg ${_val_args} ${_bool_args})
+               set(${_arg})
+       endforeach()
+       foreach(_element ${ARGN})
+               list(FIND _val_args "${_element}" _val_arg_find)
+               list(FIND _bool_args "${_element}" _bool_arg_find)
+               if("${_val_arg_find}" GREATER "-1")
+                       set(_curdest "${_element}")
+               elseif("${_bool_arg_find}" GREATER "-1")
+                       set("${_element}" ON)
+                       set(_curdest _nowhere)
+               else()
+                       list(APPEND ${_curdest} "${_element}")
+               endif()
+       endforeach()
+
+       if(_nowhere)
+               message(FATAL_ERROR "Syntax error in use of add_boost_test!")
+       endif()
+
+       if(NOT SOURCES)
+               message(FATAL_ERROR
+                       "Syntax error in use of add_boost_test: at least one source file required!")
+       endif()
+
+       if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")
+
+               include_directories(${Boost_INCLUDE_DIRS})
+
+               set(includeType)
+               foreach(src ${SOURCES})
+                       file(READ ${src} thefile)
+                       if("${thefile}" MATCHES ".*BoostTestTargetConfig.h.*")
+                               set(includeType CONFIGURED)
+                               set(includeFileLoc ${src})
+                               break()
+                       elseif("${thefile}" MATCHES ".*boost/test/included/unit_test.hpp.*")
+                               set(includeType INCLUDED)
+                               set(includeFileLoc ${src})
+                               set(_boosttesttargets_libs)     # clear this out - linking would be a bad idea
+                               if(NOT
+                                       "${thefile}"
+                                       MATCHES
+                                       ".*OVERRIDE_BOOST_TEST_INCLUDED_WARNING.*")
+                                       message("Please replace the include line in ${src} with this alternate include line instead:")
+                                       message("  \#include <BoostTestTargetConfig.h>")
+                                       message("Once you've saved your changes, re-run CMake. (See BoostTestTargets.cmake for more info)")
+                               endif()
+                               break()
+                       endif()
+               endforeach()
+
+               if(NOT _boostTestTargetsNagged${_name} STREQUAL "${includeType}")
+                       if("includeType" STREQUAL "CONFIGURED")
+                               message(STATUS
+                                       "Test '${_name}' uses the CMake-configurable form of the boost test framework - congrats! (Including File: ${includeFileLoc})")
+                       elseif("${includeType}" STREQUAL "INCLUDED")
+                               message("In test '${_name}': ${includeFileLoc} uses the 'included' form of the boost unit test framework.")
+                       else()
+                               message("In test '${_name}': Didn't detect the CMake-configurable boost test include.")
+                               message("Please replace your existing boost test include in that test with the following:")
+                               message("  \#include <BoostTestTargetConfig.h>")
+                               message("Once you've saved your changes, re-run CMake. (See BoostTestTargets.cmake for more info)")
+                       endif()
+               endif()
+               set(_boostTestTargetsNagged${_name}
+                       "${includeType}"
+                       CACHE
+                       INTERNAL
+                       ""
+                       FORCE)
+
+
+               if(RESOURCES)
+                       list(APPEND SOURCES ${RESOURCES})
+               endif()
+
+               # Generate a unique target name, using the relative binary dir
+               # and provided name. (transform all / into _ and remove all other
+               # non-alphabet characters)
+               file(RELATIVE_PATH
+                       targetpath
+                       "${CMAKE_BINARY_DIR}"
+                       "${CMAKE_CURRENT_BINARY_DIR}")
+               string(REGEX REPLACE "[^A-Za-z/_]" "" targetpath "${targetpath}")
+               string(REPLACE "/" "_" targetpath "${targetpath}")
+
+               set(_target_name ${BOOST_TEST_TARGET_PREFIX}-${targetpath}-${_name})
+               set(${_name}_TARGET_NAME "${_target_name}" PARENT_SCOPE)
+
+               # Build the test.
+               add_executable(${_target_name} ${SOURCES})
+
+               list(APPEND LIBRARIES ${_boosttesttargets_libs})
+
+               if(LIBRARIES)
+                       target_link_libraries(${_target_name} ${LIBRARIES})
+               endif()
+
+               if(RESOURCES)
+                       set_property(TARGET ${_target_name} PROPERTY RESOURCE ${RESOURCES})
+                       copy_resources_to_build_tree(${_target_name})
+               endif()
+
+               if(NOT Boost_TEST_FLAGS)
+#                      set(Boost_TEST_FLAGS --catch_system_error=yes --output_format=XML)
+                       set(Boost_TEST_FLAGS --catch_system_error=yes)
+               endif()
+
+               # TODO: Figure out why only recent boost handles individual test running properly
+
+               if(LAUNCHER)
+                       set(_test_command ${LAUNCHER} "\$<TARGET_FILE:${_target_name}>")
+               else()
+                       set(_test_command ${_target_name})
+               endif()
+
+               if(TESTS AND "${Boost_VERSION}" VERSION_GREATER "103799")
+                       foreach(_test ${TESTS})
+                               add_test(NAME
+                                       ${_name}-${_test}
+                                       COMMAND
+                                       ${_test_command}
+                                       --run_test=${_test}
+                                       ${Boost_TEST_FLAGS})
+                               if(FAIL_REGULAR_EXPRESSION)
+                                       set_tests_properties(${_name}-${_test}
+                                               PROPERTIES
+                                               FAIL_REGULAR_EXPRESSION
+                                               "${FAIL_REGULAR_EXPRESSION}")
+                               endif()
+                       endforeach()
+               else()
+                       add_test(NAME
+                               ${_name}-boost_test
+                               COMMAND
+                               ${_test_command}
+                               ${Boost_TEST_FLAGS})
+                       if(FAIL_REGULAR_EXPRESSION)
+                               set_tests_properties(${_name}-${_test}
+                                       PROPERTIES
+                                       FAIL_REGULAR_EXPRESSION
+                                       "${FAIL_REGULAR_EXPRESSION}")
+                       endif()
+               endif()
+
+               # CppCheck the test if we can.
+               if(COMMAND add_cppcheck)
+                       add_cppcheck(${_target_name} STYLE UNUSED_FUNCTIONS)
+               endif()
+
+       endif()
+endfunction()
diff --git a/cmake/BoostTestTargetsDynamic.h b/cmake/BoostTestTargetsDynamic.h
new file mode 100644 (file)
index 0000000..ae1f38e
--- /dev/null
@@ -0,0 +1,9 @@
+// Small header computed by CMake to set up boost test.
+// include AFTER #define BOOST_TEST_MODULE whatever
+// but before any other boost test includes.
+
+// Using the Boost UTF dynamic library
+
+#define BOOST_TEST_DYN_LINK
+#include <boost/test/unit_test.hpp>
+
diff --git a/cmake/BoostTestTargetsIncluded.h b/cmake/BoostTestTargetsIncluded.h
new file mode 100644 (file)
index 0000000..253133c
--- /dev/null
@@ -0,0 +1,7 @@
+// Small header computed by CMake to set up boost test.
+// include AFTER #define BOOST_TEST_MODULE whatever
+// but before any other boost test includes.
+
+// Using the Boost UTF included framework
+
+#include <boost/test/included/unit_test.hpp>
diff --git a/cmake/BoostTestTargetsStatic.h b/cmake/BoostTestTargetsStatic.h
new file mode 100644 (file)
index 0000000..dd3cdda
--- /dev/null
@@ -0,0 +1,7 @@
+// Small header computed by CMake to set up boost test.
+// include AFTER #define BOOST_TEST_MODULE whatever
+// but before any other boost test includes.
+
+// Using the Boost UTF static library
+
+#include <boost/test/unit_test.hpp>
diff --git a/cmake/CopyResourcesToBuildTree.cmake b/cmake/CopyResourcesToBuildTree.cmake
new file mode 100644 (file)
index 0000000..3512cc4
--- /dev/null
@@ -0,0 +1,83 @@
+# - Copy the resources your app needs to the build tree.
+#
+#  copy_resources_to_build_tree(<target_name>)
+#
+# Requires CMake 2.6 or newer (uses the 'function' command)
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright Iowa State University 2009-2010.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+if(__copy_resources_to_build_tree)
+       return()
+endif()
+set(__copy_resources_to_build_tree YES)
+
+function(copy_resources_to_build_tree _target)
+       get_target_property(_resources ${_target} RESOURCE)
+       if(NOT _resources)
+               # Bail if no resources
+               message(STATUS
+                       "Told to copy resources for target ${_target}, but "
+                       "no resources are set!")
+               return()
+       endif()
+
+       get_target_property(_path ${_target} LOCATION)
+       get_filename_component(_path "${_path}" PATH)
+
+       if(NOT MSVC AND NOT "${CMAKE_GENERATOR}" MATCHES "Makefiles")
+               foreach(_config ${CMAKE_CONFIGURATION_TYPES})
+                       get_target_property(_path${_config} ${_target} LOCATION_${_config})
+                       get_filename_component(_path${_config} "${_path${_config}}" PATH)
+                       add_custom_command(TARGET ${_target}
+                                               POST_BUILD
+                                               COMMAND
+                                               ${CMAKE_COMMAND}
+                                               ARGS -E make_directory "${_path${_config}}/"
+                                               COMMENT "Creating directory ${_path${_config}}/")
+               endforeach()
+       endif()
+
+       foreach(_res ${_resources})
+               if(NOT IS_ABSOLUTE "${_res}")
+                       get_filename_component(_res "${_res}" ABSOLUTE)
+               endif()
+               get_filename_component(_name "${_res}" NAME)
+
+               if(MSVC)
+                       # Working dir is solution file dir, not exe file dir.
+                       add_custom_command(TARGET ${_target}
+                               POST_BUILD
+                               COMMAND
+                               ${CMAKE_COMMAND}
+                               ARGS -E copy "${_res}" "${CMAKE_BINARY_DIR}/"
+                               COMMENT "Copying ${_name} to ${CMAKE_BINARY_DIR}/ for MSVC")
+               else()
+                       if("${CMAKE_GENERATOR}" MATCHES "Makefiles")
+                               add_custom_command(TARGET ${_target}
+                                       POST_BUILD
+                                       COMMAND
+                                       ${CMAKE_COMMAND}
+                                       ARGS -E copy "${_res}" "${_path}/"
+                                       COMMENT "Copying ${_name} to ${_path}/")
+                       else()
+                               foreach(_config ${CMAKE_CONFIGURATION_TYPES})
+                                       add_custom_command(TARGET ${_target}
+                                               POST_BUILD
+                                               COMMAND
+                                               ${CMAKE_COMMAND}
+                                               ARGS -E copy "${_res}" "${_path${_config}}"
+                                               COMMENT "Copying ${_name} to ${_path${_config}}")
+                               endforeach()
+
+                       endif()
+               endif()
+       endforeach()
+endfunction()
diff --git a/cmake/FindBISON.cmake b/cmake/FindBISON.cmake
new file mode 100644 (file)
index 0000000..6c6b420
--- /dev/null
@@ -0,0 +1,221 @@
+# - Find bison executable and provides macros to generate custom build rules
+# The module defines the following variables:
+#
+#  BISON_EXECUTABLE - path to the bison program
+#  BISON_VERSION - version of bison
+#  BISON_FOUND - true if the program was found
+#
+# If bison is found, the module defines the macros:
+#  BISON_TARGET(<Name> <YaccInput> <CodeOutput> [VERBOSE <file>]
+#              [COMPILE_FLAGS <string>] [HEADER <FILE>])
+# which will create  a custom rule to generate  a parser. <YaccInput> is
+# the path to  a yacc file. <CodeOutput> is the name  of the source file
+# generated by bison.  A header file containing the token  list is  also
+# generated according to bison's -d option by default  or if the  HEADER
+# option is used, the argument is passed to  bison's --defines option to
+# specify output file.  If COMPILE_FLAGS option is specified,  the  next
+# parameter is  added in the bison  command line.  if  VERBOSE option is
+# specified, <file> is created  and contains verbose descriptions of the
+# grammar and parser. The macro defines a set of variables:
+#  BISON_${Name}_DEFINED - true is the macro ran successfully
+#  BISON_${Name}_INPUT - The input source file, an alias for <YaccInput>
+#  BISON_${Name}_OUTPUT_SOURCE - The source file generated by bison
+#  BISON_${Name}_OUTPUT_HEADER - The header file generated by bison
+#  BISON_${Name}_OUTPUTS - The sources files generated by bison
+#  BISON_${Name}_COMPILE_FLAGS - Options used in the bison command line
+#
+#  ====================================================================
+#  Example:
+#
+#   find_package(BISON)
+#   BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
+#   add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS})
+#  ====================================================================
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+# Copyright 2006 Tristan Carel
+# Modified 2010 by Jon Siwek, adding HEADER option
+#
+# Distributed under the OSI-approved BSD License (the "License"):
+# CMake - Cross Platform Makefile Generator
+# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+# All rights reserved.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "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 COPYRIGHT
+# HOLDER OR CONTRIBUTORS 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.
+#
+# 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.
+#=============================================================================
+
+FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable")
+MARK_AS_ADVANCED(BISON_EXECUTABLE)
+
+IF(BISON_EXECUTABLE)
+
+  EXECUTE_PROCESS(COMMAND ${BISON_EXECUTABLE} --version
+    OUTPUT_VARIABLE BISON_version_output
+    ERROR_VARIABLE BISON_version_error
+    RESULT_VARIABLE BISON_version_result
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  IF(NOT ${BISON_version_result} EQUAL 0)
+    MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}")
+  ELSE()
+    STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
+      BISON_VERSION "${BISON_version_output}")
+  ENDIF()
+
+  # internal macro
+  MACRO(BISON_TARGET_option_verbose Name BisonOutput filename)
+    LIST(APPEND BISON_TARGET_cmdopt "--verbose")
+    GET_FILENAME_COMPONENT(BISON_TARGET_output_path "${BisonOutput}" PATH)
+    GET_FILENAME_COMPONENT(BISON_TARGET_output_name "${BisonOutput}" NAME_WE)
+    ADD_CUSTOM_COMMAND(OUTPUT ${filename}
+      COMMAND ${CMAKE_COMMAND}
+      ARGS -E copy
+      "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
+      "${filename}"
+      DEPENDS
+      "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
+      COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
+      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+    SET(BISON_${Name}_VERBOSE_FILE ${filename})
+    LIST(APPEND BISON_TARGET_extraoutputs
+      "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output")
+  ENDMACRO(BISON_TARGET_option_verbose)
+
+  # internal macro
+  MACRO(BISON_TARGET_option_extraopts Options)
+    SET(BISON_TARGET_extraopts "${Options}")
+    SEPARATE_ARGUMENTS(BISON_TARGET_extraopts)
+    LIST(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts})
+  ENDMACRO(BISON_TARGET_option_extraopts)
+
+  #============================================================
+  # BISON_TARGET (public macro)
+  #============================================================
+  #
+  MACRO(BISON_TARGET Name BisonInput BisonOutput)
+    SET(BISON_TARGET_output_header "")
+    #SET(BISON_TARGET_command_opt "")
+    SET(BISON_TARGET_cmdopt "")
+    SET(BISON_TARGET_outputs "${BisonOutput}")
+    IF(NOT ${ARGC} EQUAL 3 AND
+       NOT ${ARGC} EQUAL 5 AND
+       NOT ${ARGC} EQUAL 7 AND
+       NOT ${ARGC} EQUAL 9)
+      MESSAGE(SEND_ERROR "Usage")
+    ELSE()
+      # Parsing parameters
+      IF(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5)
+        IF("${ARGV3}" STREQUAL "VERBOSE")
+          BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV4}")
+        ENDIF()
+        IF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+          BISON_TARGET_option_extraopts("${ARGV4}")
+        ENDIF()
+        IF("${ARGV3}" STREQUAL "HEADER")
+          set(BISON_TARGET_output_header "${ARGV4}")
+        ENDIF()
+      ENDIF()
+
+      IF(${ARGC} GREATER 7 OR ${ARGC} EQUAL 7)
+        IF("${ARGV5}" STREQUAL "VERBOSE")
+          BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV6}")
+        ENDIF()
+      
+        IF("${ARGV5}" STREQUAL "COMPILE_FLAGS")
+          BISON_TARGET_option_extraopts("${ARGV6}")
+        ENDIF()
+
+        IF("${ARGV5}" STREQUAL "HEADER")
+          set(BISON_TARGET_output_header "${ARGV6}")
+        ENDIF()
+      ENDIF()
+
+      IF(${ARGC} EQUAL 9)
+        IF("${ARGV7}" STREQUAL "VERBOSE")
+          BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV8}")
+        ENDIF()
+      
+        IF("${ARGV7}" STREQUAL "COMPILE_FLAGS")
+          BISON_TARGET_option_extraopts("${ARGV8}")
+        ENDIF()
+
+        IF("${ARGV7}" STREQUAL "HEADER")
+          set(BISON_TARGET_output_header "${ARGV8}")
+        ENDIF()
+      ENDIF()
+
+      IF(BISON_TARGET_output_header)
+          # Header's name passed in as argument to be used in --defines option
+          LIST(APPEND BISON_TARGET_cmdopt
+               "--defines=${BISON_TARGET_output_header}")
+          set(BISON_${Name}_OUTPUT_HEADER ${BISON_TARGET_output_header})
+      ELSE()
+          # Header's name generated by bison (see option -d)
+          LIST(APPEND BISON_TARGET_cmdopt "-d")
+          STRING(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${ARGV2}")
+          STRING(REPLACE "c" "h" _fileext ${_fileext})
+          STRING(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}" 
+              BISON_${Name}_OUTPUT_HEADER "${ARGV2}")
+      ENDIF()
+
+      LIST(APPEND BISON_TARGET_outputs "${BISON_${Name}_OUTPUT_HEADER}")
+        
+      ADD_CUSTOM_COMMAND(OUTPUT ${BISON_TARGET_outputs}
+        ${BISON_TARGET_extraoutputs}
+        COMMAND ${BISON_EXECUTABLE}
+        ARGS ${BISON_TARGET_cmdopt} -o ${ARGV2} ${ARGV1}
+        DEPENDS ${ARGV1}
+        COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}"
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    
+      # define target variables
+      SET(BISON_${Name}_DEFINED TRUE)
+      SET(BISON_${Name}_INPUT ${ARGV1})
+      SET(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs})
+      SET(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt})
+      SET(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}")
+
+    ENDIF(NOT ${ARGC} EQUAL 3 AND
+          NOT ${ARGC} EQUAL 5 AND
+          NOT ${ARGC} EQUAL 7 AND
+          NOT ${ARGC} EQUAL 9)
+  ENDMACRO(BISON_TARGET)
+  #
+  #============================================================
+
+ENDIF(BISON_EXECUTABLE)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON DEFAULT_MSG BISON_EXECUTABLE)
+
+# FindBISON.cmake ends here
\ No newline at end of file
diff --git a/cmake/FindFLEX.cmake b/cmake/FindFLEX.cmake
new file mode 100644 (file)
index 0000000..df151fb
--- /dev/null
@@ -0,0 +1,179 @@
+# - Find flex executable and provides a macro to generate custom build rules
+#
+# The module defines the following variables:
+#  FLEX_FOUND - true is flex executable is found
+#  FLEX_EXECUTABLE - the path to the flex executable
+#  FLEX_VERSION - the version of flex
+#  FLEX_LIBRARIES - The flex libraries
+#
+# The minimum required version of flex can be specified using the
+# standard syntax, e.g. FIND_PACKAGE(FLEX 2.5.13)
+#
+#
+# If flex is found on the system, the module provides the macro:
+#  FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# which creates a custom command  to generate the <FlexOutput> file from
+# the <FlexInput> file.  If  COMPILE_FLAGS option is specified, the next
+# parameter is added to the flex  command line. Name is an alias used to
+# get  details of  this custom  command.  Indeed the  macro defines  the
+# following variables:
+#  FLEX_${Name}_DEFINED - true is the macro ran successfully
+#  FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
+#  alias for FlexOutput
+#  FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+#
+# Flex scanners oftenly use tokens  defined by Bison: the code generated
+# by Flex  depends of the header  generated by Bison.   This module also
+# defines a macro:
+#  ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget)
+# which  adds the  required dependency  between a  scanner and  a parser
+# where  <FlexTarget>  and <BisonTarget>  are  the  first parameters  of
+# respectively FLEX_TARGET and BISON_TARGET macros.
+#
+#  ====================================================================
+#  Example:
+#
+#   find_package(BISON)
+#   find_package(FLEX)
+#
+#   BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp
+#   FLEX_TARGET(MyScanner lexer.l  ${CMAKE_CURRENT_BIANRY_DIR}/lexer.cpp)
+#   ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
+#
+#   include_directories(${CMAKE_CURRENT_BINARY_DIR})
+#   add_executable(Foo
+#      Foo.cc
+#      ${BISON_MyParser_OUTPUTS}
+#      ${FLEX_MyScanner_OUTPUTS}
+#   )
+#  ====================================================================
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+# Copyright 2006 Tristan Carel
+# Modified 2010 by Jon Siwek, backporting for CMake 2.6 compat
+#
+# Distributed under the OSI-approved BSD License (the "License"):
+# CMake - Cross Platform Makefile Generator
+# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+# All rights reserved.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "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 COPYRIGHT
+# HOLDER OR CONTRIBUTORS 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.
+#
+# 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.
+#=============================================================================
+
+FIND_PROGRAM(FLEX_EXECUTABLE flex DOC "path to the flex executable")
+MARK_AS_ADVANCED(FLEX_EXECUTABLE)
+
+FIND_LIBRARY(FL_LIBRARY NAMES fl
+  DOC "path to the fl library")
+MARK_AS_ADVANCED(FL_LIBRARY)
+SET(FLEX_LIBRARIES ${FL_LIBRARY})
+
+IF(FLEX_EXECUTABLE)
+
+  EXECUTE_PROCESS(COMMAND ${FLEX_EXECUTABLE} --version
+    OUTPUT_VARIABLE FLEX_version_output
+    ERROR_VARIABLE FLEX_version_error
+    RESULT_VARIABLE FLEX_version_result
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  IF(NOT ${FLEX_version_result} EQUAL 0)
+    IF(FLEX_FIND_REQUIRED)
+      MESSAGE(SEND_ERROR "Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_output}\n${FLEX_version_error}")
+    ELSE()
+      MESSAGE("Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_output}\n${FLEX_version_error}\nFLEX_VERSION will not be available")
+    ENDIF()
+  ELSE()
+    STRING(REGEX REPLACE "^flex (.*)$" "\\1"
+      FLEX_VERSION "${FLEX_version_output}")
+  ENDIF()
+
+  #============================================================
+  # FLEX_TARGET (public macro)
+  #============================================================
+  #
+  MACRO(FLEX_TARGET Name Input Output)
+    SET(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
+    IF(${ARGC} GREATER 3)
+      IF(${ARGC} EQUAL 5)
+        IF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+          SET(FLEX_EXECUTABLE_opts  "${ARGV4}")
+          SEPARATE_ARGUMENTS(FLEX_EXECUTABLE_opts)
+        ELSE()
+          MESSAGE(SEND_ERROR ${FLEX_TARGET_usage})
+        ENDIF()
+      ELSE()
+        MESSAGE(SEND_ERROR ${FLEX_TARGET_usage})
+      ENDIF()
+    ENDIF()
+
+    ADD_CUSTOM_COMMAND(OUTPUT ${Output}
+      COMMAND ${FLEX_EXECUTABLE}
+      ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+      DEPENDS ${Input}
+      COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+
+    SET(FLEX_${Name}_DEFINED TRUE)
+    SET(FLEX_${Name}_OUTPUTS ${Output})
+    SET(FLEX_${Name}_INPUT ${Input})
+    SET(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+  ENDMACRO(FLEX_TARGET)
+  #============================================================
+
+
+  #============================================================
+  # ADD_FLEX_BISON_DEPENDENCY (public macro)
+  #============================================================
+  #
+  MACRO(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
+
+    IF(NOT FLEX_${FlexTarget}_OUTPUTS)
+      MESSAGE(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+    ENDIF()
+
+    IF(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
+      MESSAGE(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+    ENDIF()
+
+    SET_SOURCE_FILES_PROPERTIES(${FLEX_${FlexTarget}_OUTPUTS}
+      PROPERTIES OBJECT_DEPENDS ${BISON_${BisonTarget}_OUTPUT_HEADER})
+  ENDMACRO(ADD_FLEX_BISON_DEPENDENCY)
+  #============================================================
+
+ENDIF(FLEX_EXECUTABLE)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLEX FLEX_EXECUTABLE
+                                       FLEX_VERSION)
+
+# FindFLEX.cmake ends here
\ No newline at end of file
diff --git a/cmake/FindGit.cmake b/cmake/FindGit.cmake
new file mode 100644 (file)
index 0000000..1d79f61
--- /dev/null
@@ -0,0 +1,74 @@
+#.rst:
+# FindGit
+# -------
+#
+#
+#
+# The module defines the following variables:
+#
+# ::
+#
+#    GIT_EXECUTABLE - path to git command line client
+#    GIT_FOUND - true if the command line client was found
+#    GIT_VERSION_STRING - the version of git found (since CMake 2.8.8)
+#
+# Example usage:
+#
+# ::
+#
+#    find_package(Git)
+#    if(GIT_FOUND)
+#      message("git found: ${GIT_EXECUTABLE}")
+#    endif()
+
+#=============================================================================
+# Copyright 2010 Kitware, Inc.
+# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
+#
+# 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.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# Look for 'git' or 'eg' (easy git)
+#
+set(git_names git eg)
+
+# Prefer .cmd variants on Windows unless running in a Makefile
+# in the MSYS shell.
+#
+if(WIN32)
+  if(NOT CMAKE_GENERATOR MATCHES "MSYS")
+    set(git_names git.cmd git eg.cmd eg)
+  endif()
+endif()
+
+find_program(GIT_EXECUTABLE
+  NAMES ${git_names}
+  PATH_SUFFIXES Git/cmd Git/bin
+  DOC "git command line client"
+  )
+mark_as_advanced(GIT_EXECUTABLE)
+
+if(GIT_EXECUTABLE)
+  execute_process(COMMAND ${GIT_EXECUTABLE} --version
+                  OUTPUT_VARIABLE git_version
+                  ERROR_QUIET
+                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if (git_version MATCHES "^git version [0-9]")
+    string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
+  endif()
+  unset(git_version)
+endif()
+
+# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
+# all listed variables are TRUE
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Git GIT_EXECUTABLE
+                                      GIT_VERSION_STRING)
\ No newline at end of file
diff --git a/cmake/FindMYSQL.cmake b/cmake/FindMYSQL.cmake
new file mode 100644 (file)
index 0000000..738f588
--- /dev/null
@@ -0,0 +1,47 @@
+# - Find mysqlclient
+# Find the native MySQL includes and library
+#
+#  MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
+#  MYSQL_LIBRARIES   - List of libraries when using MySQL.
+#  MYSQL_FOUND       - True if MySQL found.
+
+IF (MYSQL_INCLUDE_DIR)
+  # Already in cache, be silent
+  SET(MYSQL_FIND_QUIETLY TRUE)
+ENDIF (MYSQL_INCLUDE_DIR)
+
+FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
+  /usr/local/include/mysql
+  /usr/include/mysql
+)
+
+SET(MYSQL_NAMES mysqlclient mysqlclient_r)
+FIND_LIBRARY(MYSQL_LIBRARY
+  NAMES ${MYSQL_NAMES}
+  PATHS /usr/lib /usr/local/lib
+  PATH_SUFFIXES mysql
+)
+
+IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+  SET(MYSQL_FOUND TRUE)
+  SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
+ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+  SET(MYSQL_FOUND FALSE)
+  SET( MYSQL_LIBRARIES )
+ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+
+IF (MYSQL_FOUND)
+  IF (NOT MYSQL_FIND_QUIETLY)
+    MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
+  ENDIF (NOT MYSQL_FIND_QUIETLY)
+ELSE (MYSQL_FOUND)
+  IF (MYSQL_FIND_REQUIRED)
+    MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
+    MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
+  ENDIF (MYSQL_FIND_REQUIRED)
+ENDIF (MYSQL_FOUND)
+
+MARK_AS_ADVANCED(
+  MYSQL_LIBRARY
+  MYSQL_INCLUDE_DIR
+  )
diff --git a/cmake/GNUInstallDirs.cmake b/cmake/GNUInstallDirs.cmake
new file mode 100644 (file)
index 0000000..84829c1
--- /dev/null
@@ -0,0 +1,205 @@
+#.rst:
+# GNUInstallDirs
+# --------------
+#
+# Define GNU standard installation directories
+#
+# Provides install directory variables as defined for GNU software:
+#
+# ::
+#
+#   http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
+#
+# Inclusion of this module defines the following variables:
+#
+# ::
+#
+#   CMAKE_INSTALL_<dir>      - destination for files of a given type
+#   CMAKE_INSTALL_FULL_<dir> - corresponding absolute path
+#
+# where <dir> is one of:
+#
+# ::
+#
+#   BINDIR           - user executables (bin)
+#   SBINDIR          - system admin executables (sbin)
+#   LIBEXECDIR       - program executables (libexec)
+#   SYSCONFDIR       - read-only single-machine data (etc)
+#   SHAREDSTATEDIR   - modifiable architecture-independent data (com)
+#   LOCALSTATEDIR    - modifiable single-machine data (var)
+#   LIBDIR           - object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian)
+#   INCLUDEDIR       - C header files (include)
+#   OLDINCLUDEDIR    - C header files for non-gcc (/usr/include)
+#   DATAROOTDIR      - read-only architecture-independent data root (share)
+#   DATADIR          - read-only architecture-independent data (DATAROOTDIR)
+#   INFODIR          - info documentation (DATAROOTDIR/info)
+#   LOCALEDIR        - locale-dependent data (DATAROOTDIR/locale)
+#   MANDIR           - man documentation (DATAROOTDIR/man)
+#   DOCDIR           - documentation root (DATAROOTDIR/doc/PROJECT_NAME)
+#
+# Each CMAKE_INSTALL_<dir> value may be passed to the DESTINATION
+# options of install() commands for the corresponding file type.  If the
+# includer does not define a value the above-shown default will be used
+# and the value will appear in the cache for editing by the user.  Each
+# CMAKE_INSTALL_FULL_<dir> value contains an absolute path constructed
+# from the corresponding destination by prepending (if necessary) the
+# value of CMAKE_INSTALL_PREFIX.
+
+#=============================================================================
+# Copyright 2011 Nikita Krupen'ko <krnekit@gmail.com>
+# Copyright 2011 Kitware, Inc.
+#
+# 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.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# Installation directories
+#
+if(NOT DEFINED CMAKE_INSTALL_BINDIR)
+  set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_SBINDIR)
+  set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR)
+  set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
+  set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR)
+  set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR)
+  set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
+  set(_LIBDIR_DEFAULT "lib")
+  # Override this default 'lib' with 'lib64' iff:
+  #  - we are on Linux system but NOT cross-compiling
+  #  - we are NOT on debian
+  #  - we are on a 64 bits system
+  # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
+  # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if
+  # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu"
+  # See http://wiki.debian.org/Multiarch
+  if(CMAKE_SYSTEM_NAME MATCHES "Linux"
+      AND NOT CMAKE_CROSSCOMPILING)
+    if (EXISTS "/etc/debian_version") # is this a debian system ?
+       if(CMAKE_LIBRARY_ARCHITECTURE)
+         set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
+       endif()
+    else() # not debian, rely on CMAKE_SIZEOF_VOID_P:
+      if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
+        message(AUTHOR_WARNING
+          "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
+          "Please enable at least one language before including GNUInstallDirs.")
+      else()
+        if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+          set(_LIBDIR_DEFAULT "lib64")
+        endif()
+      endif()
+    endif()
+  endif()
+  set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
+  set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR)
+  set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
+  set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
+endif()
+
+#-----------------------------------------------------------------------------
+# Values whose defaults are relative to DATAROOTDIR.  Store empty values in
+# the cache and store the defaults in local variables if the cache values are
+# not set explicitly.  This auto-updates the defaults as DATAROOTDIR changes.
+
+if(NOT CMAKE_INSTALL_DATADIR)
+  set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
+  set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
+endif()
+
+if(NOT CMAKE_INSTALL_INFODIR)
+  set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
+  set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
+endif()
+
+if(NOT CMAKE_INSTALL_LOCALEDIR)
+  set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)")
+  set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale")
+endif()
+
+if(NOT CMAKE_INSTALL_MANDIR)
+  set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
+  set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
+endif()
+
+if(NOT CMAKE_INSTALL_DOCDIR)
+  set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
+  set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
+endif()
+
+#-----------------------------------------------------------------------------
+
+mark_as_advanced(
+  CMAKE_INSTALL_BINDIR
+  CMAKE_INSTALL_SBINDIR
+  CMAKE_INSTALL_LIBEXECDIR
+  CMAKE_INSTALL_SYSCONFDIR
+  CMAKE_INSTALL_SHAREDSTATEDIR
+  CMAKE_INSTALL_LOCALSTATEDIR
+  CMAKE_INSTALL_LIBDIR
+  CMAKE_INSTALL_INCLUDEDIR
+  CMAKE_INSTALL_OLDINCLUDEDIR
+  CMAKE_INSTALL_DATAROOTDIR
+  CMAKE_INSTALL_DATADIR
+  CMAKE_INSTALL_INFODIR
+  CMAKE_INSTALL_LOCALEDIR
+  CMAKE_INSTALL_MANDIR
+  CMAKE_INSTALL_DOCDIR
+  )
+
+# Result directories
+#
+foreach(dir
+    BINDIR
+    SBINDIR
+    LIBEXECDIR
+    SYSCONFDIR
+    SHAREDSTATEDIR
+    LOCALSTATEDIR
+    LIBDIR
+    INCLUDEDIR
+    OLDINCLUDEDIR
+    DATAROOTDIR
+    DATADIR
+    INFODIR
+    LOCALEDIR
+    MANDIR
+    DOCDIR
+    )
+  if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
+    set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
+  else()
+    set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
+  endif()
+endforeach()
\ No newline at end of file
diff --git a/cmake/GetForceIncludeDefinitions.cmake b/cmake/GetForceIncludeDefinitions.cmake
new file mode 100644 (file)
index 0000000..efcca04
--- /dev/null
@@ -0,0 +1,44 @@
+# - Get the platform-appropriate flags to add to force inclusion of a file
+#
+# The most common use of this is to use a generated config.h-type file
+# placed out of the source tree in all files.
+#
+#  get_force_include_definitions(var forcedincludefiles...) -
+#   where var is the name of  your desired output variable, and everything
+#   else is a source file to forcibly include.
+#   a list item to be filtered.
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright Iowa State University 2009-2010.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+if(__get_force_include_definitions)
+       return()
+endif()
+set(__get_force_include_definitions YES)
+
+function(get_force_include_definitions var)
+       set(_flagprefix)
+       if(CMAKE_COMPILER_IS_GNUCXX)
+               set(_flag "-include")
+       elseif(MSVC)
+               set(_flag "/FI")
+       else()
+               message(SEND_ERROR "You don't seem to be using MSVC or GCC, but")
+               message(SEND_ERROR "the project called get_force_include_definitions.")
+               message(SEND_ERROR "Contact this project with the name of your")
+               message(FATAL_ERROR "compiler and preferably the flag to force includes")
+       endif()
+
+       set(_out)
+       foreach(_item ${ARGN})
+               list(APPEND _out "${_flag} \"${_item}\"")
+       endforeach()
+       set(${var} "${_out}" PARENT_SCOPE)
+endfunction()
diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake
new file mode 100644 (file)
index 0000000..1bf0230
--- /dev/null
@@ -0,0 +1,123 @@
+# - Returns a version string from Git
+#
+# These functions force a re-configure on each git commit so that you can
+# trust the values of the variables in your build system.
+#
+#  get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
+#
+# Returns the refspec and sha hash of the current head revision
+#
+#  git_describe(<var> [<additional arguments to git describe> ...])
+#
+# Returns the results of git describe on the source tree, and adjusting
+# the output so that it tests false if an error occurs.
+#
+#  git_get_exact_tag(<var> [<additional arguments to git describe> ...])
+#
+# Returns the results of git describe --exact-match on the source tree,
+# and adjusting the output so that it tests false if there was no exact
+# matching tag.
+#
+# Requires CMake 2.6 or newer (uses the 'function' command)
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright Iowa State University 2009-2010.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+if(__get_git_revision_description)
+       return()
+endif()
+set(__get_git_revision_description YES)
+
+# We must run the following at "include" time, not at function call time,
+# to find the path to this module rather than the path to a calling list file
+get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+function(get_git_head_revision _refspecvar _hashvar)
+       set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}")
+       set(GIT_DIR "${GIT_PARENT_DIR}/.git")
+       while(NOT EXISTS "${GIT_DIR}")  # .git dir not found, search parent directories
+               set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
+               get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
+               if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
+                       # We have reached the root directory, we are not in git
+                       set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
+                       set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
+                       return()
+               endif()
+               set(GIT_DIR "${GIT_PARENT_DIR}/.git")
+       endwhile()
+       set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
+       if(NOT EXISTS "${GIT_DATA}")
+               file(MAKE_DIRECTORY "${GIT_DATA}")
+       endif()
+
+       if(NOT EXISTS "${GIT_DIR}/HEAD")
+               return()
+       endif()
+       set(HEAD_FILE "${GIT_DATA}/HEAD")
+       configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
+
+       configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
+               "${GIT_DATA}/grabRef.cmake"
+               @ONLY)
+       include("${GIT_DATA}/grabRef.cmake")
+
+       set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
+       set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
+endfunction()
+
+function(git_describe _var)
+       if(NOT GIT_FOUND)
+               find_package(Git QUIET)
+       endif()
+       get_git_head_revision(refspec hash)
+       if(NOT GIT_FOUND)
+               set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
+               return()
+       endif()
+       if(NOT hash)
+               set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
+               return()
+       endif()
+
+       # TODO sanitize
+       #if((${ARGN}" MATCHES "&&") OR
+       #       (ARGN MATCHES "||") OR
+       #       (ARGN MATCHES "\\;"))
+       #       message("Please report the following error to the project!")
+       #       message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
+       #endif()
+
+       #message(STATUS "Arguments to execute_process: ${ARGN}")
+
+       execute_process(COMMAND
+               "${GIT_EXECUTABLE}"
+               describe
+               ${hash}
+               ${ARGN}
+               WORKING_DIRECTORY
+               "${CMAKE_SOURCE_DIR}"
+               RESULT_VARIABLE
+               res
+               OUTPUT_VARIABLE
+               out
+               ERROR_QUIET
+               OUTPUT_STRIP_TRAILING_WHITESPACE)
+       if(NOT res EQUAL 0)
+               set(out "${out}-${res}-NOTFOUND")
+       endif()
+
+       set(${_var} "${out}" PARENT_SCOPE)
+endfunction()
+
+function(git_get_exact_tag _var)
+       git_describe(out --exact-match ${ARGN})
+       set(${_var} "${out}" PARENT_SCOPE)
+endfunction()
diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in
new file mode 100644 (file)
index 0000000..888ce13
--- /dev/null
@@ -0,0 +1,38 @@
+# 
+# Internal file for GetGitRevisionDescription.cmake
+#
+# Requires CMake 2.6 or newer (uses the 'function' command)
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright Iowa State University 2009-2010.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+set(HEAD_HASH)
+
+file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
+
+string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
+if(HEAD_CONTENTS MATCHES "ref")
+       # named branch
+       string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
+       if(EXISTS "@GIT_DIR@/${HEAD_REF}")
+               configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
+       elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
+               configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
+               set(HEAD_HASH "${HEAD_REF}")
+       endif()
+else()
+       # detached HEAD
+       configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
+endif()
+
+if(NOT HEAD_HASH)
+       file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
+       string(STRIP "${HEAD_HASH}" HEAD_HASH)
+endif()
diff --git a/cmake/InstallConfig.cmake b/cmake/InstallConfig.cmake
new file mode 100644 (file)
index 0000000..a1a50dc
--- /dev/null
@@ -0,0 +1,25 @@
+function(install_if_not_exists src dest)
+  if(NOT IS_ABSOLUTE "${src}")
+    set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
+  endif()
+  get_filename_component(src_name "${src}" NAME)
+  if (NOT IS_ABSOLUTE "${dest}")
+    set(dest "${CMAKE_INSTALL_PREFIX}/${dest}")
+  endif()
+  install(CODE "
+    if(NOT EXISTS \"\$ENV{DESTDIR}${dest}/${src_name}\")
+      #file(INSTALL \"${src}\" DESTINATION \"${dest}\")
+      message(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\")
+      execute_process(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\"
+                      \"\$ENV{DESTDIR}${dest}/${src_name}\"
+                      RESULT_VARIABLE copy_result
+                      ERROR_VARIABLE error_output)
+      if(copy_result)
+        message(FATAL_ERROR \${error_output})
+      endif()
+    else()
+      message(STATUS \"Skipping  : \$ENV{DESTDIR}${dest}/${src_name}\")
+    endif()
+  ")
+endfunction(install_if_not_exists)
+
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ad78975
--- /dev/null
@@ -0,0 +1,8 @@
+add_subdirectory(checker)
+add_subdirectory(cluster)
+add_subdirectory(compat)
+add_subdirectory(db_ido_mysql)
+add_subdirectory(demo)
+add_subdirectory(livestatus)
+add_subdirectory(notification)
+add_subdirectory(perfdata)
diff --git a/components/checker/CMakeLists.txt b/components/checker/CMakeLists.txt
new file mode 100644 (file)
index 0000000..940d85b
--- /dev/null
@@ -0,0 +1,37 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(checkercomponent.ti checkercomponent.th)
+
+mkembedconfig_target(checker-type.conf checker-type.cpp)
+
+add_library(checker SHARED checkercomponent.cpp checkercomponent.th checker-type.cpp)
+
+target_link_libraries(checker ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  checker PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(
+  TARGETS checker
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
+
diff --git a/components/cluster/CMakeLists.txt b/components/cluster/CMakeLists.txt
new file mode 100644 (file)
index 0000000..37ccc00
--- /dev/null
@@ -0,0 +1,38 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(clusterlistener.ti clusterlistener.th)
+mkclass_target(endpoint.ti endpoint.th)
+
+mkembedconfig_target(cluster-type.conf cluster-type.cpp)
+
+add_library(cluster SHARED clusterlistener.cpp clusterlistener.th endpoint.cpp endpoint.th jsonrpc.cpp cluster-type.cpp)
+
+target_link_libraries(cluster ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  cluster PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(TARGETS cluster RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)
+
+#install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/cluster\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/cluster/config\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/cluster/log\")")
+
diff --git a/components/compat/CMakeLists.txt b/components/compat/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8b45812
--- /dev/null
@@ -0,0 +1,41 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(checkresultreader.ti checkresultreader.th)
+mkclass_target(compatlogger.ti compatlogger.th)
+mkclass_target(externalcommandlistener.ti externalcommandlistener.th)
+mkclass_target(statusdatawriter.ti statusdatawriter.th)
+
+mkembedconfig_target(compat-type.conf compat-type.cpp)
+
+add_library(compat SHARED checkresultreader.cpp checkresultreader.th compatlogger.cpp compatlogger.th externalcommandlistener.cpp externalcommandlistener.th statusdatawriter.cpp statusdatawriter.th compat-type.cpp)
+
+target_link_libraries(compat ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  compat PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(TARGETS compat RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)
+
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/compat/archives\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/icinga2/cmd\")")
+
diff --git a/components/db_ido_mysql/CMakeLists.txt b/components/db_ido_mysql/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0857a9b
--- /dev/null
@@ -0,0 +1,36 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+find_package(MYSQL)
+
+if(MYSQL_FOUND)
+    mkclass_target(idomysqlconnection.ti idomysqlconnection.th)
+
+    mkembedconfig_target(db_ido_mysql-type.conf db_ido_mysql-type.cpp)
+
+    add_library(db_ido_mysql SHARED idomysqlconnection.cpp idomysqlconnection.th db_ido_mysql-type.cpp)
+
+    include_directories(${MYSQL_INCLUDE_DIR})
+    target_link_libraries(db_ido_mysql ${Boost_LIBRARIES} ${MYSQL_LIBRARIES} base config icinga db_ido)
+
+    set_target_properties (
+      db_ido_mysql PROPERTIES
+      INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+    )
+
+    install(TARGETS db_ido_mysql RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2)
+endif()
index ce2c0bf7e88b18673f222c60aea96f8c71600261..d421f1e145476ab76c2010ac01210d6ffb542d17 100644 (file)
@@ -288,7 +288,7 @@ String IdoMysqlConnection::Escape(const String& s)
 {
        AssertOnWorkQueue();
 
-       ssize_t length = s.GetLength();
+       size_t length = s.GetLength();
        char *to = new char[s.GetLength() * 2 + 1];
 
        mysql_real_escape_string(&m_Connection, to, s.CStr(), length);
index 14bc966696e8914244ebc23f01c8a8a52d0c3eff..c9e36ccff63d32c4a545ae64102e34c0800df903 100644 (file)
@@ -24,7 +24,7 @@
 #include "base/array.h"
 #include "base/timer.h"
 #include "base/workqueue.h"
-#include <mysql/mysql.h>
+#include <mysql.h>
 
 namespace icinga
 {
diff --git a/components/demo/CMakeLists.txt b/components/demo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6a22ba8
--- /dev/null
@@ -0,0 +1,36 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(demo.ti demo.th)
+
+mkembedconfig_target(demo-type.conf demo-type.cpp)
+
+add_library(demo SHARED demo.cpp demo.th demo-type.cpp)
+
+target_link_libraries(demo ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  demo PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(
+  TARGETS demo
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
diff --git a/components/livestatus/CMakeLists.txt b/components/livestatus/CMakeLists.txt
new file mode 100644 (file)
index 0000000..123852b
--- /dev/null
@@ -0,0 +1,32 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(listener.ti listener.th)
+
+mkembedconfig_target(livestatus-type.conf livestatus-type.cpp)
+
+add_library(livestatus SHARED aggregator.cpp andfilter.cpp attributefilter.cpp avgaggregator.cpp column.cpp combinerfilter.cpp commandstable.cpp commentstable.cpp contactgroupstable.cpp contactstable.cpp countaggregator.cpp downtimestable.cpp filter.cpp hostgroupstable.cpp hoststable.cpp invavgaggregator.cpp invsumaggregator.cpp listener.cpp listener.th logtable.cpp maxaggregator.cpp minaggregator.cpp negatefilter.cpp orfilter.cpp query.cpp servicegroupstable.cpp servicestable.cpp statustable.cpp stdaggregator.cpp sumaggregator.cpp table.cpp timeperiodstable.cpp livestatus-type.cpp)
+
+target_link_libraries(livestatus ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  livestatus PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(TARGETS livestatus RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)
diff --git a/components/notification/CMakeLists.txt b/components/notification/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0280c1a
--- /dev/null
@@ -0,0 +1,32 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(notificationcomponent.ti notificationcomponent.th)
+
+mkembedconfig_target(notification-type.conf notification-type.cpp)
+
+add_library(notification SHARED notificationcomponent.cpp notificationcomponent.th notification-type.cpp)
+
+target_link_libraries(notification ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  notification PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(TARGETS notification RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2)
diff --git a/components/perfdata/CMakeLists.txt b/components/perfdata/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a5bf05b
--- /dev/null
@@ -0,0 +1,39 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(graphitewriter.ti graphitewriter.th)
+mkclass_target(perfdatawriter.ti perfdatawriter.th)
+
+mkembedconfig_target(perfdata-type.conf perfdata-type.cpp)
+
+add_library(perfdata SHARED graphitewriter.cpp graphitewriter.th perfdatawriter.cpp perfdatawriter.th perfdata-type.cpp)
+
+target_link_libraries(perfdata ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  perfdata PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Components
+)
+
+install(
+  TARGETS perfdata
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
+
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/perfdata\")")
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644 (file)
index 0000000..2a4fe03
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#cmakedefine HAVE_BIOZLIB
+#cmakedefine HAVE_BACKTRACE_SYMBOLS
+#cmakedefine HAVE_PIPE2
+#cmakedefine HAVE_VFORK
+
+#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
+#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
+#define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2"
+
+#endif /* CONFIG_H */
index 877743ac21817e619320dc704d1307edfc998d0f..697babb56d5a9aa07fd19988557fa5b9b2eee601 100644 (file)
@@ -32,6 +32,7 @@ Icinga 2's init script is installed in `/etc/init.d/icinga2` by default:
       -V [ --version ]      show version information
       -l [ --library ] arg  load a library
       -I [ --include ] arg  add include search directory
+         -D [ --define] args   define a variable
       -c [ --config ] arg   parse a configuration file
       -C [ --validate ]     exit after validating the configuration
       -x [ --debug ]        enable debugging
@@ -49,6 +50,10 @@ Icinga 2's init script is installed in `/etc/init.d/icinga2` by default:
 Instead of loading libraries using the [`library` config directive](#library)
 you can also use the `--library` command-line option.
 
+#### Variables
+
+[Global variables](#global-variables) can be set using the `--define` command-line option.
+
 #### Config Include Path
 
 When including files you can specify that the include search path should be
index 081a30781df3facd4727ed23cf3f2f1968c9bfed..5c92a601c94d90e3fa0b33a464af71851fd8f7db 100644 (file)
@@ -1,12 +1,11 @@
-## Global Variables
+## <a id="global-variables"> Global Variables
 
 Icinga 2 provides a number of special global variables:
 
 Variable                  |Description
 --------------------------|-------------------
-IcingaPrefixDir           |**Read-only.** Contains the installation prefix that was specified with ./configure --prefix. Defaults to /usr/local
+IcingaPrefixDir           |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to /usr/local
 IcingaLocalStateDir       |**Read-only.** Contains the path of the local state directory. Defaults to IcingaPrefixDir + "/var".
-IcingaPkgLibDir           |**Read-only.** Contains the path of the package lib directory. Defaults to IcingaPrefixDir + "/lib/icinga2".
 IcingaPkgDataDir          |**Read-only.** Contains the path of the package data directory. Defaults to IcingaPrefixDir + "/share/icinga2".
 IcingaStatePath           |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to IcingaLocalStateDir + "/lib/icinga2/icinga2.state".
 IcingaPidPath             |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to IcingaLocalStateDir + "/run/icinga2/icinga2.pid".
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5727d7e
--- /dev/null
@@ -0,0 +1,28 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+install(
+  DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+  DESTINATION ${CMAKE_INSTALL_DOCDIR}  FILES_MATCHING PATTERN *.md
+)
+
+if(UNIX OR CYGWIN)
+  install(
+    FILES icinga2.8
+    DESTINATION ${CMAKE_INSTALL_MANDIR}/man8
+  )
+endif()
\ No newline at end of file
diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..31c413e
--- /dev/null
@@ -0,0 +1,53 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+include(InstallConfig)
+
+install_if_not_exists(icinga2/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
+install_if_not_exists(icinga2/conf.d/generic-host.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/generic-service.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/groups.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/localhost.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/macros.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
+install_if_not_exists(icinga2/features-available/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/compatlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/debuglog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/graphite.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/ido-mysql.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/livestatus.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/notification.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/perfdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/statusdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
+
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
+install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")")
+install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/notification.conf\")")
+install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/syslog.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/syslog.conf\")")
+
+if(NOT WIN32)
+  configure_file(init.d/icinga2.cmake ${CMAKE_CURRENT_BINARY_DIR}/init.d/icinga2)
+  install(
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/init.d/icinga2
+    DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/init.d
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+  )
+endif()
similarity index 87%
rename from etc/init.d/icinga2.in
rename to etc/init.d/icinga2.cmake
index c14de653118f4dc4d9f57ab90ced48e0ee14d722..2d86ecebcda44be363af5f7114870e880737962c 100644 (file)
 # Description:       Icinga 2 is a monitoring and management system for hosts, services and networks.
 ### END INIT INFO
 
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-sbindir=@sbindir@
-bindir=@bindir@
-sysconfdir=@sysconfdir@
-localstatedir=@localstatedir@
-icinga_user=@icinga_user@
-icinga_group=@icinga_group@
-
-DAEMON=$sbindir/icinga2
-ICINGA2_CONFIG_FILE=$sysconfdir/icinga2/icinga2.conf
-ICINGA2_PID_FILE=$localstatedir/run/icinga2/icinga2.pid
-ICINGA2_ERROR_LOG=$localstatedir/log/icinga2/error.log
-ICINGA2_USER=$icinga_user
-ICINGA2_GROUP=$icinga_group
+DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2
+ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf
+ICINGA2_PID_FILE=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/run/icinga2/icinga2.pid
+ICINGA2_ERROR_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log
+ICINGA2_USER=@ICINGA2_USER@
+ICINGA2_GROUP=@ICINGA2_GROUP@
 
 test -x $DAEMON || exit 0
 
diff --git a/icinga-app/CMakeLists.txt b/icinga-app/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9ab74a4
--- /dev/null
@@ -0,0 +1,37 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_executable(icinga-app icinga.cpp)
+
+include_directories(${Boost_INCLUDE_DIRS})
+target_link_libraries(icinga-app ${Boost_LIBRARIES} base config)
+
+set_target_properties (
+  icinga-app PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  FOLDER Bin
+  OUTPUT_NAME icinga2
+)
+
+install(
+  TARGETS icinga-app
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+)
+
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2\")")
+install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/icinga2\")")
index 0c3a6d6ef20052d1da6fd8e3797da328b9d17ecd..b92fa5cd8110cc7673e41ff2624a82e8844e586c 100644 (file)
@@ -26,6 +26,8 @@
 #include "base/utility.h"
 #include "base/exception.h"
 #include "base/convert.h"
+#include "base/scriptvariable.h"
+#include "config.h"
 #include <boost/program_options.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <boost/smart_ptr/make_shared.hpp>
@@ -171,34 +173,11 @@ int main(int argc, char **argv)
        /* Install exception handlers to make debugging easier. */
        Application::InstallExceptionHandlers();
 
-#ifdef ICINGA_PREFIX
-       Application::SetPrefixDir(ICINGA_PREFIX);
-#else /* ICINGA_PREFIX */
-       Application::SetPrefixDir(".");
-#endif /* ICINGA_PREFIX */
+       Application::DeclarePrefixDir(ICINGA_PREFIX);
+       Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR);
+       Application::DeclarePkgDataDir(ICINGA_PKGDATADIR);
 
-#ifdef ICINGA_LOCALSTATEDIR
-       Application::SetLocalStateDir(ICINGA_LOCALSTATEDIR);
-#else /* ICINGA_LOCALSTATEDIR */
-       Application::SetLocalStateDir("./var");
-#endif /* ICINGA_LOCALSTATEDIR */
-
-#ifdef ICINGA_PKGLIBDIR
-       Application::SetPkgLibDir(ICINGA_PKGLIBDIR);
-#else /* ICINGA_PKGLIBDIR */
-       Application::SetPkgLibDir(".");
-#endif /* ICINGA_PKGLIBDIR */
-
-#ifdef ICINGA_PKGDATADIR
-       Application::SetPkgDataDir(ICINGA_PKGDATADIR);
-#else /* ICINGA_PKGDATADIR */
-       Application::SetPkgDataDir(".");
-#endif /* ICINGA_PKGDATADIR */
-
-       Application::SetStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
-       Application::SetPidPath(Application::GetLocalStateDir() + "/run/icinga2/icinga2.pid");
-
-       Application::SetApplicationType("IcingaApplication");
+       Application::DeclareApplicationType("IcingaApplication");
 
        po::options_description desc("Supported options");
        desc.add_options()
@@ -206,6 +185,7 @@ int main(int argc, char **argv)
                ("version,V", "show version information")
                ("library,l", po::value<std::vector<String> >(), "load a library")
                ("include,I", po::value<std::vector<String> >(), "add include search directory")
+               ("define,D", po::value<std::vector<String> >(), "define a variable")
                ("config,c", po::value<std::vector<String> >(), "parse a configuration file")
                ("validate,C", "exit after validating the configuration")
                ("debug,x", "enable debugging")
@@ -310,6 +290,25 @@ int main(int argc, char **argv)
                return EXIT_SUCCESS;
        }
 
+       if (g_AppParams.count("define")) {
+               BOOST_FOREACH(const String& define, g_AppParams["define"].as<std::vector<String> >()) {
+                       String key, value;
+                       size_t pos = define.FindFirstOf('=');
+                       if (pos != String::NPos) {
+                               key = define.SubStr(0, pos);
+                               value = define.SubStr(pos + 1);
+                       }
+                       else {
+                               key = define;
+                               value = "1";
+                       }
+                       ScriptVariable::Set(key, value);
+               }
+       }
+
+       Application::DeclareStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
+       Application::DeclarePidPath(Application::GetLocalStateDir() + "/run/icinga2/icinga2.pid");
+
        Log(LogInformation, "icinga-app", "Icinga application loader (version: " + Application::GetVersion() + ")");
 
        (void) Utility::LoadExtensionLibrary("icinga");
diff --git a/icinga-version.h.cmake b/icinga-version.h.cmake
new file mode 100644 (file)
index 0000000..f5887d0
--- /dev/null
@@ -0,0 +1 @@
+#define VERSION "${GIT_VERSION}"
similarity index 93%
rename from icinga2.spec.in
rename to icinga2.spec
index 865dd662f1e35bbd5c641bcbde13f2bfc762359f..4dd936b23bca4e932045893dadcc7a0fd78a8ab2 100644 (file)
@@ -46,8 +46,8 @@
 %define logmsg logger -t %{name}/rpm
 
 Summary: network monitoring application
-Name: @PACKAGE@
-Version: @VERSION@
+Name: icinga2
+Version: 0.0.3
 Release: %{revision}%{?dist}
 License: GPLv2+
 Group: Applications/System
@@ -59,9 +59,7 @@ BuildRequires: doxygen
 BuildRequires: openssl-devel
 BuildRequires: gcc-c++
 BuildRequires: libstdc++-devel
-BuildRequires: automake
-BuildRequires: autoconf
-BuildRequires: libtool
+BuildRequires: cmake
 BuildRequires: flex
 BuildRequires: bison
 BuildRequires: %{apachename}
@@ -72,14 +70,12 @@ BuildRequires: %{apachename}
 BuildRequires: boost%{el5_boost_version}-devel
 BuildRequires: boost%{el5_boost_version}
 Requires: boost%{el5_boost_version}-program-options
-Requires: boost%{el5_boost_version}-signals
 Requires: boost%{el5_boost_version}-system
 Requires: boost%{el5_boost_version}-test
 Requires: boost%{el5_boost_version}-thread
 %else
 BuildRequires: boost-devel >= 1.41
 Requires: boost-program-options >= 1.41
-Requires: boost-signals >= 1.41
 Requires: boost-system >= 1.41
 Requires: boost-test >= 1.41
 Requires: boost-thread >= 1.41
@@ -93,14 +89,12 @@ BuildRequires: boost-license%{sles_boost_version}
 BuildRequires: boost-devel >= 1.41
 Requires: boost-license%{sles_boost_version}
 Requires: libboost_program_options%{sles_boost_version}
-Requires: libboost_signals%{sles_boost_version}
 Requires: libboost_system%{sles_boost_version}
 Requires: libboost_test%{sles_boost_version}
 Requires: libboost_thread%{sles_boost_version}
 %else
 BuildRequires: boost-devel >= 1.41
 Requires: libboost_program_options%{opensuse_boost_version}
-Requires: libboost_signals%{opensuse_boost_version}
 Requires: libboost_system%{opensuse_boost_version}
 Requires: libboost_test%{opensuse_boost_version}
 Requires: libboost_thread%{opensuse_boost_version}
@@ -175,19 +169,29 @@ for Icinga 2.
 %setup -q -n %{name}-%{version}
 
 %build
-%configure --with-icinga-user=%{icinga_user} \
-       --with-icinga-group=%{icinga_group} \
-       --with-icingacmd-user=%{icinga_user} \
-       --with-icingacmd-group=%{icingacmd_group}
+CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
+         -DCMAKE_INSTALL_SYSCONFDIR=/etc \
+                -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
+         -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+         -DICINGA2_USER=%{icinga_user} \
+         -DICINGA2_GROUP=%{icinga_group} \
+            -DICINGA2_COMMAND_USER=%{icinga_user} \
+            -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
+%if "%{_vendor}" == "redhat"
+%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
+CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
+ -DBOOST_INCLUDEDIR=/usr/include/boost141 \
+ -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0'"
+%endif
+%endif
+cmake $CMAKE_OPTS . 
 
 make %{?_smp_mflags}
 
 %install
 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
 make install \
-       DESTDIR="%{buildroot}" \
-       INSTALL_OPTS="" \
-       COMMAND_OPTS=""
+       DESTDIR="%{buildroot}"
 
 # install classicui config
 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
diff --git a/itl/CMakeLists.txt b/itl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..698f52a
--- /dev/null
@@ -0,0 +1,21 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+install(
+  FILES command.conf command-common.conf constants.conf itl.conf timeperiod.conf
+  DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/itl
+)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bbe32b3
--- /dev/null
@@ -0,0 +1,21 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_subdirectory(base)
+add_subdirectory(config)
+add_subdirectory(icinga)
+add_subdirectory(db_ido)
diff --git a/lib/base/CMakeLists.txt b/lib/base/CMakeLists.txt
new file mode 100644 (file)
index 0000000..34bf7e7
--- /dev/null
@@ -0,0 +1,71 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(application.ti application.th)
+mkclass_target(consolelogger.ti consolelogger.th)
+mkclass_target(dynamicobject.ti dynamicobject.th)
+mkclass_target(filelogger.ti filelogger.th)
+mkclass_target(logger.ti logger.th)
+mkclass_target(script.ti script.th)
+mkclass_target(streamlogger.ti streamlogger.th)
+mkclass_target(sysloglogger.ti sysloglogger.th)
+
+add_library(base SHARED
+  application.cpp application.th array.cpp bufferedstream.cpp consolelogger.cpp
+  consolelogger.th convert.cpp dictionary.cpp  dynamicobject.cpp
+  dynamicobject.th dynamictype.cpp exception.cpp fifo.cpp filelogger.cpp
+  filelogger.th logger.cpp logger.th netstring.cpp networkstream.cpp object.cpp
+  objectlock.cpp process.cpp process-unix.cpp process-windows.cpp qstring.cpp
+  reflectionobject.cpp ringbuffer.cpp script.cpp script.th scriptfunction.cpp
+  scriptfunctionwrapper.cpp scriptinterpreter.cpp scriptlanguage.cpp
+  scriptvariable.cpp socket.cpp stacktrace.cpp stdiostream.cpp stream_bio.cpp
+  stream.cpp streamlogger.cpp streamlogger.th sysloglogger.cpp sysloglogger.th
+  tcpsocket.cpp threadpool.cpp timer.cpp tlsstream.cpp tlsutility.cpp
+  unixsocket.cpp utility.cpp value.cpp workqueue.cpp zlibstream.cpp
+)
+
+target_link_libraries(base ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
+
+include_directories(${icinga2_SOURCE_DIR}/third-party/cJSON)
+link_directories(${icinga2_BINARY_DIR}/third-party/cJSON)
+
+include_directories(${icinga2_SOURCE_DIR}/third-party/execvpe)
+link_directories(${icinga2_BINARY_DIR}/third-party/execvpe)
+
+include_directories(${icinga2_SOURCE_DIR}/third-party/mmatch)
+link_directories(${icinga2_BINARY_DIR}/third-party/mmatch)
+
+if(UNIX OR CYGWIN)
+  target_link_libraries(base execvpe)
+endif()
+
+if(WIN32)
+  target_link_libraries(base ws2_32 dbghelp shlwapi)
+endif()
+
+set_target_properties (
+  base PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  DEFINE_SYMBOL I2_BASE_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS base
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
index d578ee8965258c9982e22faa01a347fb09f24b92..b1996c4c958d79cf48dca80ffbfe2d38ef3da19e 100644 (file)
@@ -26,6 +26,7 @@
 #include "base/utility.h"
 #include "base/debug.h"
 #include "base/scriptvariable.h"
+#include "icinga-version.h"
 #include <sstream>
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/thread/thread.hpp>
 #include <boost/exception/errinfo_file_name.hpp>
 #include <iostream>
 
-#ifndef _WIN32
-#      include "icinga-version.h"
-#endif /* _WIN32 */
-
 using namespace icinga;
 
 Application *Application::m_Instance = NULL;
@@ -575,9 +572,9 @@ String Application::GetPrefixDir(void)
  *
  * @param path The new path.
  */
-void Application::SetPrefixDir(const String& path)
+void Application::DeclarePrefixDir(const String& path)
 {
-       ScriptVariable::Set("IcingaPrefixDir", path);
+       ScriptVariable::Declare("IcingaPrefixDir", path);
 }
 
 /**
@@ -595,29 +592,9 @@ String Application::GetLocalStateDir(void)
  *
  * @param path The new path.
  */
-void Application::SetLocalStateDir(const String& path)
-{
-       ScriptVariable::Set("IcingaLocalStateDir", path);
-}
-
-/**
- * Retrieves the path for the package lib dir.
- *
- * @returns The path.
- */
-String Application::GetPkgLibDir(void)
-{
-       return ScriptVariable::Get("IcingaPkgLibDir");
-}
-
-/**
- * Sets the path for the package lib dir.
- *
- * @param path The new path.
- */
-void Application::SetPkgLibDir(const String& path)
+void Application::DeclareLocalStateDir(const String& path)
 {
-       ScriptVariable::Set("IcingaPkgLibDir", path);
+       ScriptVariable::Declare("IcingaLocalStateDir", path);
 }
 
 /**
@@ -635,9 +612,9 @@ String Application::GetPkgDataDir(void)
  *
  * @param path The new path.
  */
-void Application::SetPkgDataDir(const String& path)
+void Application::DeclarePkgDataDir(const String& path)
 {
-       ScriptVariable::Set("IcingaPkgDataDir", path);
+       ScriptVariable::Declare("IcingaPkgDataDir", path);
 }
 
 /**
@@ -655,9 +632,9 @@ String Application::GetStatePath(void)
  *
  * @param path The new path.
  */
-void Application::SetStatePath(const String& path)
+void Application::DeclareStatePath(const String& path)
 {
-       ScriptVariable::Set("IcingaStatePath", path);
+       ScriptVariable::Declare("IcingaStatePath", path);
 }
 
 /**
@@ -675,9 +652,9 @@ String Application::GetPidPath(void)
  *
  * @param path The new path.
  */
-void Application::SetPidPath(const String& path)
+void Application::DeclarePidPath(const String& path)
 {
-       ScriptVariable::Set("IcingaPidPath", path);
+       ScriptVariable::Declare("IcingaPidPath", path);
 }
 
 /**
@@ -695,9 +672,9 @@ String Application::GetApplicationType(void)
  *
  * @param path The new type name.
  */
-void Application::SetApplicationType(const String& type)
+void Application::DeclareApplicationType(const String& type)
 {
-       ScriptVariable::Set("ApplicationType", type);
+       ScriptVariable::Declare("ApplicationType", type);
 }
 
 /**
@@ -713,11 +690,7 @@ ThreadPool& Application::GetTP(void)
 
 String Application::GetVersion(void)
 {
-#ifndef _WIN32
-       return VERSION ", " GIT_MESSAGE;
-#else /* _WIN32 */
-       return "unspecified version";
-#endif /* _WIN32 */
+       return VERSION;
 }
 
 double Application::GetStartTime(void)
index b93f5910e838270e79943fe22a639ed065339d44..518105ce6e6e41c6ff3e35cffa9a5955b87ae30e 100644 (file)
@@ -71,25 +71,22 @@ public:
        static String GetExePath(const String& argv0);
 
        static String GetPrefixDir(void);
-       static void SetPrefixDir(const String& path);
+       static void DeclarePrefixDir(const String& path);
 
        static String GetLocalStateDir(void);
-       static void SetLocalStateDir(const String& path);
-
-       static String GetPkgLibDir(void);
-       static void SetPkgLibDir(const String& path);
+       static void DeclareLocalStateDir(const String& path);
 
        static String GetPkgDataDir(void);
-       static void SetPkgDataDir(const String& path);
+       static void DeclarePkgDataDir(const String& path);
 
        static String GetStatePath(void);
-       static void SetStatePath(const String& path);
+       static void DeclareStatePath(const String& path);
 
        static String GetPidPath(void);
-       static void SetPidPath(const String& path);
+       static void DeclarePidPath(const String& path);
 
        static String GetApplicationType(void);
-       static void SetApplicationType(const String& type);
+       static void DeclareApplicationType(const String& type);
 
        static ThreadPool& GetTP(void);
 
index c7a85176b1d865c09fb20ca8dc328489eb159584..6a301e47ecfdb990ca71a8b8734665e368701303 100644 (file)
@@ -83,6 +83,8 @@
 #      pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #endif
 
+#include "visibility.h"
+
 #ifdef I2_BASE_BUILD
 #      define I2_BASE_API I2_EXPORT
 #else /* I2_BASE_BUILD */
index 3e910d97e6fabbfb46c9cf6ea308278446dff46e..e81736819e30b06b7acbe1e04374d04693191e45 100644 (file)
@@ -50,7 +50,7 @@ ProcessResult Process::Run(void)
 
        int fds[2];
 
-#if HAVE_PIPE2
+#ifdef HAVE_PIPE2
        if (pipe2(fds, O_CLOEXEC) < 0) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("pipe2")
@@ -106,11 +106,11 @@ ProcessResult Process::Run(void)
 
        m_ExtraEnvironment.reset();
 
-#if HAVE_WORKING_VFORK
+#ifdef HAVE_VFORK
        m_Pid = vfork();
-#else /* HAVE_WORKING_VFORK */
+#else /* HAVE_VFORK */
        m_Pid = fork();
-#endif /* HAVE_WORKING_VFORK */
+#endif /* HAVE_VFORK */
 
        if (m_Pid < 0) {
                BOOST_THROW_EXCEPTION(posix_error()
index 071a5729269ac4e3e77c463e1630ce3fdd8b14f7..0ad8dd4d4fe2946be59c8adb3e1a0cf77424ad88 100644 (file)
@@ -48,23 +48,21 @@ public:
                return Singleton<Registry<U, T> >::GetInstance();
        }
 
-       void Register(const String& name, const T& item)
+       void RegisterIfNew(const String& name, const T& item)
        {
-               bool old_item = false;
-
-               {
-                       boost::mutex::scoped_lock lock(m_Mutex);
+               boost::mutex::scoped_lock lock(m_Mutex);
 
-                       if (m_Items.erase(name) > 0)
-                               old_item = true;
+               if (m_Items.find(name) != m_Items.end())
+                       return;
 
-                       m_Items[name] = item;
-               }
+               RegisterInternal(name, item, lock);
+       }
 
-               if (old_item)
-                       OnUnregistered(name);
+       void Register(const String& name, const T& item)
+       {
+               boost::mutex::scoped_lock lock(m_Mutex);
 
-               OnRegistered(name, item);
+               RegisterInternal(name, item, lock);
        }
 
        void Unregister(const String& name)
@@ -126,6 +124,23 @@ public:
 private:
        mutable boost::mutex m_Mutex;
        typename Registry<U, T>::ItemMap m_Items;
+
+       void RegisterInternal(const String& name, const T& item, boost::mutex::scoped_lock& lock)
+       {
+               bool old_item = false;
+
+               if (m_Items.erase(name) > 0)
+                       old_item = true;
+
+               m_Items[name] = item;
+
+               lock.unlock();
+
+               if (old_item)
+                       OnUnregistered(name);
+
+               OnRegistered(name, item);
+       }
 };
 
 }
index 6d30e643e5e8c7292655dc69cee7710540e0b236..73d7ff228926316e6f878749a2202494403c4a5f 100644 (file)
@@ -37,3 +37,8 @@ void ScriptVariable::Set(const String& name, const Value& value)
 {
        m_Registry.Register(name, value);
 }
+
+void ScriptVariable::Declare(const String& name, const Value& value)
+{
+       m_Registry.RegisterIfNew(name, value);
+}
index 628c89026231288e5c5bf12876bae9d26ebe2aa4..7f44ce27d8ac0613157a715efeeda02a44e6f2aa 100644 (file)
@@ -37,6 +37,7 @@ class I2_BASE_API ScriptVariable
 public:
        static Value Get(const String& name);
        static void Set(const String& name, const Value& value);
+       static void Declare(const String& name, const Value& value);
 
 private:
        static Registry<ScriptVariable, Value> m_Registry;
index 3c1601b1f221ff8716ac81ab1378ec298113fee3..8d95dcfe803849ac304a4f9792a293af6022a7d4 100644 (file)
@@ -21,7 +21,7 @@
 #include "base/qstring.h"
 #include "base/utility.h"
 
-#if HAVE_BACKTRACE_SYMBOLS
+#ifdef HAVE_BACKTRACE_SYMBOLS
 #      include <execinfo.h>
 #endif /* HAVE_BACKTRACE_SYMBOLS */
 
@@ -37,7 +37,7 @@ StackTrace::StackTrace(void)
 {
        boost::call_once(m_OnceFlag, &StackTrace::Initialize);
 
-#if HAVE_BACKTRACE_SYMBOLS
+#ifdef HAVE_BACKTRACE_SYMBOLS
        m_Count = backtrace(m_Frames, sizeof(m_Frames) / sizeof(m_Frames[0]));
 #else /* HAVE_BACKTRACE_SYMBOLS */
 #      ifdef _WIN32
@@ -110,7 +110,7 @@ void StackTrace::Print(std::ostream& fp, int ignoreFrames) const
        fp << std::endl << "Stacktrace:" << std::endl;
 
 #ifndef _WIN32
-#      if HAVE_BACKTRACE_SYMBOLS
+#      ifdef HAVE_BACKTRACE_SYMBOLS
        char **messages = backtrace_symbols(m_Frames, m_Count);
 
        for (int i = ignoreFrames + 1; i < m_Count && messages != NULL; ++i) {
index 38d0a83426f7bbb7d478928159e91f9f1bfab4d8..76e8c1d2fc9998f8cdafc595cd2b726e2e5b94a2 100644 (file)
@@ -45,7 +45,4 @@ typedef int SOCKET;
 #ifndef MAXPATHLEN
 #      define MAXPATHLEN PATH_MAX
 #endif /* MAXPATHLEN */
-
-#define I2_EXPORT
-#define I2_IMPORT
 #endif /* UNIX_H */
index 80a5b6ef4463c6d7cc2c1a1e4ab27834dd8ff6a9..23112625cc0723d3a74c911da964f7d9e4e1bfc0 100644 (file)
@@ -33,9 +33,9 @@
 #      include <pthread_np.h>
 #endif /* __FreeBSD__ */
 
-#if HAVE_GCC_ABI_DEMANGLE
+#ifndef _MSC_VER
 #      include <cxxabi.h>
-#endif /* HAVE_GCC_ABI_DEMANGLE */
+#endif /* _MSC_VER */
 
 using namespace icinga;
 
@@ -51,7 +51,7 @@ String Utility::DemangleSymbolName(const String& sym)
 {
        String result = sym;
 
-#if HAVE_GCC_ABI_DEMANGLE
+#ifndef _MSC_VER
        int status;
        char *realname = abi::__cxa_demangle(sym.CStr(), 0, 0, &status);
 
@@ -59,7 +59,7 @@ String Utility::DemangleSymbolName(const String& sym)
                result = String(realname);
                free(realname);
        }
-#endif /* HAVE_GCC_ABI_DEMANGLE */
+#endif /* _MSC_VER */
 
        return result;
 }
@@ -252,9 +252,9 @@ Utility::LoadExtensionLibrary(const String& library)
 {
        String path;
 #ifdef _WIN32
-       path = Application::GetPkgLibDir() + "/" + library + ".dll";
+       path = library + ".dll";
 #else /* _WIN32 */
-       path = Application::GetPkgLibDir() + "/lib" + library + ".so";
+       path = "lib" + library + ".so";
 #endif /* _WIN32 */
 
        Log(LogInformation, "base", "Loading library '" + path + "'");
diff --git a/lib/base/visibility.h b/lib/base/visibility.h
new file mode 100644 (file)
index 0000000..6a54dbe
--- /dev/null
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)   *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+#ifndef VISIBILITY_H
+#define VISIBILITY_H
+
+#ifndef _WIN32
+#      define I2_EXPORT __attribute__ ((visibility("default")))
+#      define I2_IMPORT
+#else /* _WIN32 */
+#      define I2_EXPORT __declspec(dllexport)
+#      define I2_IMPORT __declspec(dllimport)
+#endif /* _WIN32 */
+
+#endif /* VISIBILITY_H */
index 728357d521d8794c1896bb3099c355665f1147c9..d843cc8c7e8976a1b91cbbc20b77e89956bcc4a9 100644 (file)
 #endif /* __MINGW32__ */
 
 typedef int socklen_t;
-typedef DWORD pid_t;
 
 #define MAXPATHLEN MAX_PATH
 
-#define I2_EXPORT __declspec(dllexport)
-#define I2_IMPORT __declspec(dllimport)
-
+#ifdef _MSC_VER
+typedef DWORD pid_t;
 #define strcasecmp stricmp
+#endif /* _MSC_VER */
 
 #endif /* WIN32_H */
diff --git a/lib/config/CMakeLists.txt b/lib/config/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e40f35e
--- /dev/null
@@ -0,0 +1,49 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+find_package(BISON 2.4.1 REQUIRED)
+find_package(FLEX 2.5.37 REQUIRED)
+
+bison_target(config_parser config_parser.yy ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc)
+flex_target(config_lexer config_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc)
+add_flex_bison_dependency(config_lexer config_parser)
+
+mkembedconfig_target(base-type.conf base-type.cpp)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+
+add_library(config SHARED
+  aexpression.cpp avalue.cpp base-type.conf base-type.cpp
+  configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp
+  configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
+  configtype.cpp expression.cpp expressionlist.cpp typerule.cpp typerulelist.cpp
+)
+
+target_link_libraries(config ${Boost_LIBRARIES} base) 
+
+set_target_properties (
+  config PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  DEFINE_SYMBOL I2_CONFIG_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS config
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
index 6729d966e638ce02dab0953d9f7ff52788ca63d7..99adf95fc9af7c2d8074b0ab2d20bf93faa6a27c 100644 (file)
@@ -22,7 +22,7 @@
 #include "config/expression.h"
 #include "config/typerule.h"
 #include "config/configcompilercontext.h"
-#include "config/config_parser.h"
+#include "config/config_parser.hh"
 #include <sstream>
 
 using namespace icinga;
diff --git a/lib/db_ido/CMakeLists.txt b/lib/db_ido/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1eb7571
--- /dev/null
@@ -0,0 +1,44 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(dbconnection.ti dbconnection.th)
+
+mkembedconfig_target(db_ido-type.conf db_ido-type.cpp)
+
+add_library(db_ido SHARED
+  commanddbobject.cpp dbconnection.cpp dbconnection.th dbconnection.th
+  db_ido-type.cpp dbobject.cpp dbquery.cpp dbreference.cpp dbtype.cpp
+  dbvalue.cpp hostdbobject.cpp hostgroupdbobject.cpp servicedbobject.cpp
+  servicegroupdbobject.cpp timeperioddbobject.cpp userdbobject.cpp
+  usergroupdbobject.cpp
+)
+
+include_directories(${Boost_INCLUDE_DIRS})
+target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga)
+
+set_target_properties (
+  db_ido PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  DEFINE_SYMBOL I2_DB_IDO_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS db_ido
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
index 503793effb1239466fe7bb105bac4614977474c9..193f93ccd00156efee882c08b55e929c0a63d745 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DBCONNECTION_H
 #define DBCONNECTION_H
 
+#include "db_ido/i2-db_ido.h"
 #include "db_ido/dbconnection.th"
 #include "db_ido/dbobject.h"
 #include "db_ido/dbquery.h"
@@ -33,7 +34,7 @@ namespace icinga
  *
  * @ingroup db_ido
  */
-class DbConnection : public ReflectionObjectImpl<DbConnection>
+class I2_DB_IDO_API DbConnection : public ReflectionObjectImpl<DbConnection>
 {
 public:
        DECLARE_PTR_TYPEDEFS(DbConnection);
index d1eaac904731f9d7a6dbe182b830d8b179ea74d8..feab08eaa37d44cc4d6266502cf4ddec12a70026 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DBOBJECT_H
 #define DBOBJECT_H
 
+#include "db_ido/i2-db_ido.h"
 #include "db_ido/dbreference.h"
 #include "db_ido/dbquery.h"
 #include "db_ido/dbtype.h"
@@ -56,7 +57,7 @@ enum DbObjectType
  *
  * @ingroup ido
  */
-class DbObject : public Object
+class I2_DB_IDO_API DbObject : public Object
 {
 public:
        DECLARE_PTR_TYPEDEFS(DbObject);
index bea545f02966e429ff6642d481248aad65a1f759..fc434b9436ef7e8b7b98a597839b74ad7fef3b3d 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DBQUERY_H
 #define DBQUERY_H
 
+#include "db_ido/i2-db_ido.h"
 #include "base/dictionary.h"
 
 namespace icinga
@@ -55,7 +56,7 @@ enum DbQueryCategory
 
 class DbObject;
 
-struct DbQuery
+struct I2_DB_IDO_API DbQuery
 {
        int Type;
        DbQueryCategory Category;
index 5b174e9ba49c29278fb815ca426b508697985673..f44b953e723d23a1058a7d769d2349a460699d5c 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef DBREFERENCE_H
 #define DBREFERENCE_H
 
+#include "db_ido/i2-db_ido.h"
+
 namespace icinga
 {
 
@@ -28,7 +30,7 @@ namespace icinga
  *
  * @ingroup ido
  */
-struct DbReference
+struct I2_DB_IDO_API DbReference
 {
 public:
        DbReference(void);
index 282603df0fa1ab58d0a1d79c40ffc6d5866d95af..396fbec597d76f83e7afa08293febd0d79172eaa 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DBTYPE_H
 #define DBTYPE_H
 
+#include "db_ido/i2-db_ido.h"
 #include "base/object.h"
 #include "base/registry.h"
 #include <boost/smart_ptr/make_shared.hpp>
@@ -34,7 +35,7 @@ class DbObject;
  *
  * @ingroup ido
  */
-class DbType : public Object
+class I2_DB_IDO_API DbType : public Object
 {
 public:
        DECLARE_PTR_TYPEDEFS(DbType);
index 76ac1d8d62a2a0bcc2a9212c966d8599aedaa22a..e1dbd60e1591f6066b24aad6860c956c02c134dc 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DBVALUE_H
 #define DBVALUE_H
 
+#include "db_ido/i2-db_ido.h"
 #include "base/object.h"
 #include "base/value.h"
 #include <boost/smart_ptr/make_shared.hpp>
@@ -39,7 +40,7 @@ enum DbValueType
  *
  * @ingroup ido
  */
-struct DbValue : public Object
+struct I2_DB_IDO_API DbValue : public Object
 {
 public:
        DECLARE_PTR_TYPEDEFS(DbValue);
diff --git a/lib/db_ido/i2-db_ido.h b/lib/db_ido/i2-db_ido.h
new file mode 100644 (file)
index 0000000..92ce6f3
--- /dev/null
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)   *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+#ifndef I2DB_IDO_H
+#define I2DB_IDO_H
+
+/**
+ * @defgroup db_ido IDO library
+ *
+ * The Icinga library implements database-agnostic IDO functionality.
+ */
+
+#include "base/i2-base.h"
+
+#ifdef I2_DB_IDO_BUILD
+#      define I2_DB_IDO_API I2_EXPORT
+#else /* I2_DB_IDO_BUILD */
+#      define I2_DB_IDO_API I2_IMPORT
+#endif /* I2_DB_IDO_BUILD */
+
+#endif /* I2DB_IDO_H */
diff --git a/lib/icinga/CMakeLists.txt b/lib/icinga/CMakeLists.txt
new file mode 100644 (file)
index 0000000..aab5860
--- /dev/null
@@ -0,0 +1,65 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+mkclass_target(checkcommand.ti checkcommand.th)
+mkclass_target(command.ti command.th)
+mkclass_target(domain.ti domain.th)
+mkclass_target(eventcommand.ti eventcommand.th)
+mkclass_target(hostgroup.ti hostgroup.th)
+mkclass_target(host.ti host.th)
+mkclass_target(icingaapplication.ti icingaapplication.th)
+mkclass_target(notificationcommand.ti notificationcommand.th)
+mkclass_target(notification.ti notification.th)
+mkclass_target(servicegroup.ti servicegroup.th)
+mkclass_target(service.ti service.th)
+mkclass_target(timeperiod.ti timeperiod.th)
+mkclass_target(usergroup.ti usergroup.th)
+mkclass_target(user.ti user.th)
+
+mkembedconfig_target(icinga-type.conf icinga-type.cpp)
+
+add_library(icinga SHARED
+  api.cpp api.h checkcommand.cpp checkcommand.th cib.cpp command.cpp command.th
+  compatutility.cpp domain.cpp domain.th eventcommand.cpp eventcommand.th
+  externalcommandprocessor.cpp host.cpp host.th hostgroup.cpp hostgroup.th
+  icingaapplication.cpp icingaapplication.th legacytimeperiod.cpp
+  macroprocessor.cpp macroresolver.cpp notificationcommand.cpp
+  notificationcommand.th notification.cpp notification.th nullchecktask.cpp
+  nulleventtask.cpp pluginchecktask.cpp plugineventtask.cpp
+  pluginnotificationtask.cpp randomchecktask.cpp service-check.cpp
+  service-comment.cpp service.cpp service-downtime.cpp service-event.cpp
+  service-flapping.cpp service.th servicegroup.cpp servicegroup.th
+  service-notification.cpp timeperiod.cpp timeperiod.th user.cpp user.th
+  usergroup.cpp usergroup.th icinga-type.cpp
+)
+
+target_link_libraries(icinga ${Boost_LIBRARIES} base config)
+
+set_target_properties (
+  icinga PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  DEFINE_SYMBOL I2_ICINGA_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS icinga
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
+
+
diff --git a/pki/.gitignore b/pki/.gitignore
deleted file mode 100644 (file)
index 3f661b2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-icinga2-build-ca
-icinga2-build-key
diff --git a/pki/CMakeLists.txt b/pki/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a363362
--- /dev/null
@@ -0,0 +1,32 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+if(UNIX OR CYGWIN)
+  configure_file(icinga2-build-ca.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2-build-ca @ONLY)
+  configure_file(icinga2-build-key.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2-build-key @ONLY)
+
+  install(
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/icinga2-build-ca ${CMAKE_CURRENT_BINARY_DIR}/icinga2-build-key
+    DESTINATION ${CMAKE_INSTALL_BINDIR}
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+  )
+
+  install(
+    FILES openssl.cnf pkifuncs vars
+    DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/pki
+  )
+endif()
\ No newline at end of file
similarity index 86%
rename from pki/icinga2-build-ca.in
rename to pki/icinga2-build-ca.cmake
index 6de1fea510daeb034507d9782715c52eaad20408..1ac4eec24e9da82caa847becf00545051c91b64d 100644 (file)
@@ -1,9 +1,5 @@
 #!/bin/bash
-prefix=@prefix@
-datarootdir=@datarootdir@
-datadir=@datadir@
-
-ICINGA2PKIDIR=$datadir/icinga2/pki
+ICINGA2PKIDIR=@CMAKE_INSTALL_FULL_DATADIR@/icinga2/pki
 
 source $ICINGA2PKIDIR/pkifuncs
 
similarity index 92%
rename from pki/icinga2-build-key.in
rename to pki/icinga2-build-key.cmake
index de9931a0dc40926beee217534b24fc9a2651ffa4..44097b3e8ce1d9f8374be48a8f73952c445f1f0f 100644 (file)
@@ -1,9 +1,5 @@
 #!/bin/bash
-prefix=@prefix@
-datarootdir=@datarootdir@
-datadir=@datadir@
-
-ICINGA2PKIDIR=$datadir/icinga2/pki
+ICINGA2PKIDIR=@CMAKE_INSTALL_FULL_DATADIR@/icinga2/pki
 
 source $ICINGA2PKIDIR/pkifuncs
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..56831cd
--- /dev/null
@@ -0,0 +1,66 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+include(BoostTestTargets)
+
+add_boost_test(base
+  SOURCES base-array.cpp base-convert.cpp base-dictionary.cpp base-fifo.cpp base-match.cpp base-netstring.cpp base-object.cpp base-shellescape.cpp base-stacktrace.cpp base-string.cpp base-timer.cpp base-value.cpp test.cpp
+  LIBRARIES base
+  TESTS base_array/construct
+        base_array/getset
+        base_array/remove
+        base_array/foreach
+        base_array/clone
+        base_array/serialize
+        base_convert/tolong
+        base_convert/todouble
+        base_convert/tostring
+        base_convert/tobool
+        base_dictionary/construct
+        base_dictionary/get1
+        base_dictionary/get2
+        base_dictionary/foreach
+        base_dictionary/remove
+        base_dictionary/clone
+        base_dictionary/serialize
+        base_fifo/construct
+        base_fifo/io
+        base_match/tolong
+        base_netstring/netstring
+        base_object/construct
+        base_object/getself
+        base_object/weak
+        base_shellescape/escape_basic
+        base_shellescape/escape_quoted
+        base_stacktrace/stacktrace
+        base_string/construct
+        base_string/equal
+        base_string/clear
+        base_string/append
+        base_string/trim
+        base_string/replace
+        base_string/index
+        base_string/find
+        base_timer/construct
+        base_timer/interval
+        base_timer/invoke
+        base_timer/scope
+        base_value/scalar
+        base_value/convert
+        base_value/format
+)
+
index bca02f1978b770b3696bb7870110c14e8ee11a63..64f9774d3d6710b1d391da497daf6aaa63ba5856 100644 (file)
@@ -19,9 +19,6 @@
 
 #define BOOST_TEST_MAIN
 #define BOOST_TEST_MODULE icinga2_test
-#ifndef _WIN32
-#      define BOOST_TEST_DYN_LINK
-#endif /* _WIN32 */
 
-#include <boost/test/unit_test.hpp>
+#include <BoostTestTargetConfig.h>
 
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a2838dd
--- /dev/null
@@ -0,0 +1,23 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_subdirectory(cJSON)
+add_subdirectory(mmatch)
+
+if(UNIX OR CYGWIN)
+  add_subdirectory(execvpe)
+endif()
diff --git a/third-party/cJSON/CMakeLists.txt b/third-party/cJSON/CMakeLists.txt
new file mode 100644 (file)
index 0000000..aa69e4c
--- /dev/null
@@ -0,0 +1,30 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_library(cJSON SHARED cJSON.c cJSON.h)
+
+set_target_properties (
+  cJSON PROPERTIES
+  DEFINE_SYMBOL I2_CJSON_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS cJSON
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
index b7a6cd3aae953b39ab8dcd3b106365e170f4b283..d9e5b795621e378349aa156a1a966ee052fa6d9c 100644 (file)
 #ifndef cJSON__h
 #define cJSON__h
 
+#include "base/visibility.h"
+
+#ifdef I2_CJSON_BUILD
+#      define I2_CJSON_API I2_EXPORT
+#else
+#      define I2_CJSON_API I2_IMPORT
+#endif /* I2_CJSON_BUILD */
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -59,60 +67,60 @@ typedef struct cJSON_Hooks {
 } cJSON_Hooks;
 
 /* Supply malloc, realloc and free functions to cJSON */
-extern void cJSON_InitHooks(cJSON_Hooks* hooks);
+extern I2_CJSON_API void cJSON_InitHooks(cJSON_Hooks* hooks);
 
 
 /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
-extern cJSON *cJSON_Parse(const char *value);
+extern I2_CJSON_API cJSON *cJSON_Parse(const char *value);
 /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
-extern char  *cJSON_Print(cJSON *item);
+extern I2_CJSON_API char  *cJSON_Print(cJSON *item);
 /* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
-extern char  *cJSON_PrintUnformatted(cJSON *item);
+extern I2_CJSON_API char  *cJSON_PrintUnformatted(cJSON *item);
 /* Delete a cJSON entity and all subentities. */
-extern void   cJSON_Delete(cJSON *c);
+extern I2_CJSON_API void   cJSON_Delete(cJSON *c);
 
 /* Returns the number of items in an array (or object). */
-extern int       cJSON_GetArraySize(cJSON *array);
+extern I2_CJSON_API int          cJSON_GetArraySize(cJSON *array);
 /* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
-extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
+extern I2_CJSON_API cJSON *cJSON_GetArrayItem(cJSON *array,int item);
 /* Get item "string" from object. Case insensitive. */
-extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
+extern I2_CJSON_API cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
 
 /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
-extern const char *cJSON_GetErrorPtr();
+extern I2_CJSON_API const char *cJSON_GetErrorPtr();
        
 /* These calls create a cJSON item of the appropriate type. */
-extern cJSON *cJSON_CreateNull();
-extern cJSON *cJSON_CreateTrue();
-extern cJSON *cJSON_CreateFalse();
-extern cJSON *cJSON_CreateBool(int b);
-extern cJSON *cJSON_CreateNumber(double num);
-extern cJSON *cJSON_CreateString(const char *string);
-extern cJSON *cJSON_CreateArray();
-extern cJSON *cJSON_CreateObject();
+extern I2_CJSON_API cJSON *cJSON_CreateNull();
+extern I2_CJSON_API cJSON *cJSON_CreateTrue();
+extern I2_CJSON_API cJSON *cJSON_CreateFalse();
+extern I2_CJSON_API cJSON *cJSON_CreateBool(int b);
+extern I2_CJSON_API cJSON *cJSON_CreateNumber(double num);
+extern I2_CJSON_API cJSON *cJSON_CreateString(const char *string);
+extern I2_CJSON_API cJSON *cJSON_CreateArray();
+extern I2_CJSON_API cJSON *cJSON_CreateObject();
 
 /* These utilities create an Array of count items. */
-extern cJSON *cJSON_CreateIntArray(int *numbers,int count);
-extern cJSON *cJSON_CreateFloatArray(float *numbers,int count);
-extern cJSON *cJSON_CreateDoubleArray(double *numbers,int count);
-extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
+extern I2_CJSON_API cJSON *cJSON_CreateIntArray(int *numbers,int count);
+extern I2_CJSON_API cJSON *cJSON_CreateFloatArray(float *numbers,int count);
+extern I2_CJSON_API cJSON *cJSON_CreateDoubleArray(double *numbers,int count);
+extern I2_CJSON_API cJSON *cJSON_CreateStringArray(const char **strings,int count);
 
 /* Append item to the specified array/object. */
-extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
-extern void    cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
+extern I2_CJSON_API void cJSON_AddItemToArray(cJSON *array, cJSON *item);
+extern I2_CJSON_API void       cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
 /* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
-extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
-extern void    cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
+extern I2_CJSON_API void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
+extern I2_CJSON_API void       cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
 
 /* Remove/Detatch items from Arrays/Objects. */
-extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
-extern void   cJSON_DeleteItemFromArray(cJSON *array,int which);
-extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
-extern void   cJSON_DeleteItemFromObject(cJSON *object,const char *string);
+extern I2_CJSON_API cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
+extern I2_CJSON_API void   cJSON_DeleteItemFromArray(cJSON *array,int which);
+extern I2_CJSON_API cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
+extern I2_CJSON_API void   cJSON_DeleteItemFromObject(cJSON *object,const char *string);
        
 /* Update array items. */
-extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
-extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
+extern I2_CJSON_API void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
+extern I2_CJSON_API void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
 
 #define cJSON_AddNullToObject(object,name)     cJSON_AddItemToObject(object, name, cJSON_CreateNull())
 #define cJSON_AddTrueToObject(object,name)     cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
diff --git a/third-party/execvpe/CMakeLists.txt b/third-party/execvpe/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9583df4
--- /dev/null
@@ -0,0 +1,30 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_library(execvpe SHARED execvpe.c execvpe.h)
+
+set_target_properties (
+  execvpe PROPERTIES
+  DEFINE_SYMBOL I2_EXECVPE_BUILD
+)
+
+install(
+  TARGETS execvpe
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
+
index b0e16a699c67f36e482cefb61f7c07628e684578..0039a7334e618e153ffa826972174053888febc2 100644 (file)
 #ifndef EXECVPE_H
 #define EXECVPE_H
 
+#include "base/visibility.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
+#ifdef I2_EXECVPE_BUILD
+#      define I2_EXECVPE_API I2_EXPORT
+#else
+#      define I2_EXECVPE_API I2_IMPORT
+#endif /* I2_EXECVPE_BUILD */
+
 #ifndef _MSC_VER
-int icinga2_execvpe(const char *file, char *const argv[], char *const envp[]);
+I2_EXECVPE_API int icinga2_execvpe(const char *file, char *const argv[], char *const envp[]);
 #endif /* _MSC_VER */
 
 #ifdef __cplusplus
diff --git a/third-party/mmatch/CMakeLists.txt b/third-party/mmatch/CMakeLists.txt
new file mode 100644 (file)
index 0000000..42b1d85
--- /dev/null
@@ -0,0 +1,30 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_library(mmatch SHARED mmatch.c mmatch.h)
+
+set_target_properties(
+  mmatch PROPERTIES
+  DEFINE_SYMBOL I2_MMATCH_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS mmatch
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
index 8a451b2edd2d144b1f2e54e91674b63ffa9a1e0c..526bab657367cbe070267959a6dc081c859d9399 100644 (file)
@@ -1,13 +1,21 @@
 #ifndef MMATCH_H
 #define MMATCH_H
 
+#include "base/visibility.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-int mmatch(const char *old_mask, const char *new_mask);
-int match(const char *mask, const char *str);
-char *collapse(char *pattern);
+#ifdef I2_MMATCH_BUILD
+#      define I2_MMATCH_API I2_EXPORT
+#else
+#      define I2_MMATCH_API I2_IMPORT
+#endif /* I2_MMATCH_BUILD */
+
+I2_MMATCH_API int mmatch(const char *old_mask, const char *new_mask);
+I2_MMATCH_API int match(const char *mask, const char *str);
+I2_MMATCH_API char *collapse(char *pattern);
 
 #ifdef __cplusplus
 }
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8696e87
--- /dev/null
@@ -0,0 +1,37 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_subdirectory(mkclass)
+add_subdirectory(mkembedconfig)
+
+if(UNIX OR CYGWIN)
+  configure_file(icinga2-enable-feature.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2-enable-feature @ONLY)
+
+  install(
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/icinga2-enable-feature
+    DESTINATION ${CMAKE_INSTALL_SBINDIR}
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+  )
+
+  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ./icinga2-enable-feature \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SBINDIR}/icinga2-disable-feature\")")
+
+  install(
+    FILES ${CMAKE_CURRENT_SOURCE_DIR}/migration/icinga2-migrate-config
+    DESTINATION ${CMAKE_INSTALL_BINDIR}
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+  )
+endif()
\ No newline at end of file
similarity index 89%
rename from tools/icinga2-enable-feature.in
rename to tools/icinga2-enable-feature.cmake
index 672a33fdf0ef8ee81b75cd2059d10513595ede91..8bcd2cad68703c9c0f50922904c9499a5fcd7a11 100644 (file)
@@ -1,12 +1,5 @@
 #!/bin/sh
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-sbindir=@sbindir@
-bindir=@bindir@
-sysconfdir=@sysconfdir@
-localstatedir=@localstatedir@
-
-ICINGA2CONFDIR=@sysconfdir@/icinga2
+ICINGA2CONFDIR=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2
 
 TOOL=$(basename -- $0)
 
diff --git a/tools/mkclass/CMakeLists.txt b/tools/mkclass/CMakeLists.txt
new file mode 100644 (file)
index 0000000..14423a7
--- /dev/null
@@ -0,0 +1,44 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+find_package(BISON 2.4.1 REQUIRED)
+find_package(FLEX 2.5.37 REQUIRED)
+
+bison_target(class_parser class_parser.yy ${CMAKE_CURRENT_BINARY_DIR}/class_parser.cc)
+flex_target(class_lexer class_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/class_lexer.cc)
+add_flex_bison_dependency(class_lexer class_parser)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+
+add_executable(mkclass mkclass.cpp classcompiler.cpp classcompiler.h ${FLEX_class_lexer_OUTPUTS} ${BISON_class_parser_OUTPUTS})
+
+set_target_properties (
+  mkclass PROPERTIES
+  FOLDER Bin
+)
+
+macro(MKCLASS_TARGET ClassInput ClassOutput)
+    add_custom_command(
+        OUTPUT ${ClassOutput}
+        COMMAND mkclass
+        ARGS ${ClassInput} > ${CMAKE_CURRENT_BINARY_DIR}/${ClassOutput}.tmp
+        COMMAND ${CMAKE_COMMAND}
+        ARGS -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ClassOutput}.tmp ${CMAKE_CURRENT_BINARY_DIR}/${ClassOutput}
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+        DEPENDS mkclass ${ClassInput}
+    )
+endmacro()
index 9bfd935b9b5cea51c24c4aba2b59746c1c00d6db..a6e38f12112350ea958229caa9daa72a5f1ad654 100644 (file)
@@ -18,8 +18,8 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
- #include "classcompiler.h"
- #include "class_parser.h"
+#include "classcompiler.h"
+#include "class_parser.hh"
 
 using namespace icinga;
 
index f0d5c57f33aa0505a562909fc52fbfae4f748054..106d47d9f9081b9ae406a2d69432e9a69773373a 100644 (file)
@@ -329,8 +329,6 @@ void ClassCompiler::CompileFile(const std::string& path)
        if (!stream)
                throw std::invalid_argument("Could not open config file: " + path);
 
-       std::cerr << "Compiling class file: " + path << std::endl;
-
        return CompileStream(path, &stream);
 }
 
diff --git a/tools/mkembedconfig/CMakeLists.txt b/tools/mkembedconfig/CMakeLists.txt
new file mode 100644 (file)
index 0000000..88451d4
--- /dev/null
@@ -0,0 +1,34 @@
+# Icinga 2
+# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+add_executable(mkembedconfig mkembedconfig.c)
+
+set_target_properties (
+  mkembedconfig PROPERTIES
+  FOLDER Bin
+)
+
+macro(MKEMBEDCONFIG_TARGET EmbedInput EmbedOutput)
+    add_custom_command(
+        OUTPUT ${EmbedOutput}
+        COMMAND mkembedconfig
+        ARGS ${EmbedInput} ${CMAKE_CURRENT_BINARY_DIR}/${EmbedOutput}
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+        DEPENDS mkembedconfig ${EmbedInput}
+    )
+endmacro()
+