--- /dev/null
+# Project
+project(libi2ncommon)
+
+# Version settings
+set(MAJOR_VERSION 2)
+set(MINOR_VERSION 0)
+set(VERSION 2.0)
+
+SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
+
+# CMake
+if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ set(CMAKE_BUILD_TYPE Debug)
+endif("${CMAKE_BUILD_TYPE}" STREQUAL "")
+set(CMAKE_COLOR_MAKEFILE ON)
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+
+# Debug build
+message("-- Build type: ${CMAKE_BUILD_TYPE}")
+if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
+ add_definitions(-DDEBUG)
+endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
+
+# Set components
+set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers)
+set(CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries")
+set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
+
+set(CPACK_COMPONENT_SHAREDLIBS_DESCRIPTION
+"Shared library for general use.")
+set(CPACK_COMPONENT_HEADERS_DESCRIPTION
+"C/C++ header files.")
+
+set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development")
+set(CPACK_COMPONENT_HEADERS_GROUP "Development")
+
+# Package information
+set(CPACK_PACKAGE_VERSION ${VERSION})
+set(CPACK_PACKAGE_CONTACT "Intra2net AG <libi2ncommon@developer.intra2net.com>")
+set(CPACK_PACKAGE_DESCRIPTION "libi2ncommon library.")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION}
+ )
+# Package settings
+set(CPACK_GENERATOR "DEB;RPM")
+set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
+set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
+set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PACK_ARCH})
+
+set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
+
+set(CPACK_SOURCE_GENERATOR TGZ)
+set(CPACK_SOURCE_IGNORE_FILES
+ "~$"
+ "\\\\.git"
+ "build"
+ "build-rpm"
+)
+set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
+
+# documentation
+find_package(Doxygen)
+if(DOXYGEN_FOUND)
+ # Set variables
+ set(PACKAGE libi2ncommon)
+ set(top_srcdir ${CMAKE_SOURCE_DIR})
+
+ # Find doxy config
+ message(STATUS "Doxygen found.")
+ set(DOXY_DIR "${CMAKE_SOURCE_DIR}/doc")
+ set(DOXY_CONFIG "${DOXY_DIR}/Doxyfile.in")
+
+ # Copy doxy.config.in
+ configure_file("${DOXY_CONFIG}" "${CMAKE_BINARY_DIR}/doxy.config")
+
+ # Create doc directory
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/doc
+ COMMAND rm -rf ${CMAKE_BINARY_DIR}/doc/{html,man}
+ COMMAND mkdir -p ${CMAKE_BINARY_DIR}/doc
+ DEPENDS src configlib xmllib utils test
+ )
+
+ # Run doxygen
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/doc/html/index.html
+ COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/doxy.config"
+ DEPENDS "${CMAKE_BINARY_DIR}/doxy.config" "${CMAKE_BINARY_DIR}/doc"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
+ )
+
+ add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
+
+ message(STATUS "Generating API documentation with Doxygen")
+else(DOXYGEN_FOUND)
+ message(STATUS "Not generating API documentation")
+endif(DOXYGEN_FOUND)
+
+# Find external packages
+include(FindPkgConfig)
+
+# Find Boost
+find_package(Boost COMPONENTS iostreams unit_test_framework REQUIRED)
+
+# Find libxml++
+pkg_check_modules(XMLPP REQUIRED libxml++-2.6)
+
+# Find iconv
+pkg_check_modules(ICONV REQUIRED libiconv)
+include_directories($ICONV_INCLUDE_DIRS})
+link_directories(${ICONV_LIBRARY_DIRS})
+
+
+# pkgconfig output
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
+set(includedir ${CMAKE_INSTALL_PREFIX}/include)
+set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
+
+# construct ${BOOST_LDADD} from ${Boost_LIBRARIES}
+string(REGEX REPLACE ";" " -l" BOOST_LDADD "${Boost_IOSTREAMS_LIBRARIES}")
+set(BOOST_LDADD "-l${BOOST_LDADD}")
+
+# construct ${BOOST_CFLAGS} from ${Boost_INCLUDE_DIRS}
+string(REGEX REPLACE ";" " -I" BOOST_CFLAGS "${Boost_INCLUDE_DIRS}")
+set(BOOST_CFLAGS "-I${BOOST_CFLAGS}")
+
+configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon.pc.in ${CMAKE_BINARY_DIR}/libi2ncommon.pc @ONLY)
+configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon_config.pc.in ${CMAKE_BINARY_DIR}/libi2ncommon_config.pc @ONLY)
+configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon_xml.pc.in ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc @ONLY)
+configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon_utils.pc.in ${CMAKE_BINARY_DIR}/libi2ncommon_utils.pc @ONLY)
+
+install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon.pc
+ ${CMAKE_BINARY_DIR}/libi2ncommon_config.pc
+ ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc
+ ${CMAKE_BINARY_DIR}/libi2ncommon_utils.pc
+ DESTINATION lib/pkgconfig)
+
+include(CPack)
+
+# Subdirectories
+set(CPACK_SET_DESTDIR "ON")
+
+add_subdirectory(src)
+add_subdirectory(configlib)
+add_subdirectory(xmllib)
+add_subdirectory(utils)
+add_subdirectory(test)
+++ /dev/null
-# not a GNU package. You can remove this line, if
-# have all needed files, that a GNU package needs
-AUTOMAKE_OPTIONS = foreign 1.4
-ACLOCAL_FLAGS = -I m4
-
-SUBDIRS = src configlib xmllib utils doc test
-
-# Install the pkg-config file:
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libi2ncommon.pc libi2ncommon_config.pc libi2ncommon_xml.pc libi2ncommon_utils.pc
-
-if AUTOCHECK
-all: config.h
- $(MAKE) $(AM_MAKEFLAGS) all-recursive
- $(MAKE) $(AM_MAKEFLAGS) check
-endif
-
-EXTRA_DIST = LICENSE COPYING.GPL
--- /dev/null
+include_directories(${CMAKE_SOURCE_DIR}/src)
+
+set(cpp_sources
+ i2n_global_config.cpp
+)
+
+set(cpp_headers
+ i2n_global_config.hpp
+)
+
+add_library(i2ncommon_config SHARED ${cpp_sources} ${hpp_sources})
+
+set_target_properties(i2ncommon_config PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION})
+
+
+install(TARGETS i2ncommon_config
+ LIBRARY DESTINATION lib
+ COMPONENT sharedlibs)
+
+install(FILES ${cpp_headers}
+ DESTINATION include
+ COMPONENT headers)
+++ /dev/null
-# set the include path found by configure
-INCLUDES = -I$(top_srcdir)/src $(all_includes) \
- @LIBICONV_CFLAGS@ @BOOST_CPPFLAGS@
-
-METASOURCES = AUTO
-
-lib_LTLIBRARIES = libi2ncommon_config.la
-
-include_HEADERS = i2n_global_config.hpp
-
-# Note: If you specify a:b:c as the version in the next line,
-# the library that is made has version (a-c).c.b. In this
-# example, the version is 2.1.2. (3:2:1)
-
-libi2ncommon_config_la_LDFLAGS = -version-info @LIBI2NCOMMON_LIB_VERSION@ @BOOST_LDFLAGS@
-
-libi2ncommon_config_la_LIBADD =
-libi2ncommon_config_la_SOURCES = i2n_global_config.cpp
+++ /dev/null
-CLEANFILES = rm -rf html
-
-if HAVE_DOXYGEN
-MANUALS = html/index.html
-else
-MANUALS =
-endif
-
-all: $(MANUALS)
-
-# todo: separate build dir still doesn't work
-html/index.html: Doxyfile $(top_srcdir)/src/*.cpp $(top_srcdir)/src/*.hxx $(top_srcdir)/src/*.hpp \
- $(top_srcdir)/configlib/*.cpp $(top_srcdir)/configlib/*.hpp \
- $(top_srcdir)/xmllib/*.cpp $(top_srcdir)/xmllib/*.hpp \
- $(top_srcdir)/utils/*.cpp $(top_srcdir)/utils/*.hpp
- $(DOXYGEN)
-
-EXTRA_DIST = Doxyfile.in
Description: library with functions common in Intra2net programs
Requires: libi2ncommon_utils
Version: @VERSION@
-Libs: -L${libdir} -li2ncommon -li2ncommon_utils @BOOST_LDFLAGS@ @BOOST_IOSTREAMS_LIB@
-Cflags: -I${includedir} @BOOST_CPPFLAGS@
+Libs: -L${libdir} -li2ncommon -li2ncommon_utils @BOOST_LDADD@
+Cflags: -I${includedir} @BOOST_CFLAGS@
%build
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/intranator/lib/pkgconfig
-autoreconf --force --install
-./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix}
-dmake
-dmake check
+mkdir build
+cd build
+
+export CFLAGS="$RPM_OPT_FLAGS"
+export CXXFLAGS="$RPM_OPT_FLAGS"
+cmake -DCMAKE_INSTALL_PREFIX="%{prefix}" ../
+
+make %{?_smp_mflags} VERBOSE=1
+
+%check
+cd build
+make check
%install
+
+cd build
make DESTDIR=$RPM_BUILD_ROOT install
%clean
%files devel
%defattr(-,root,root)
-%{prefix}/lib/*.*a*
+# No static library for now
+#%{prefix}/lib/*.*a*
%{prefix}/lib/pkgconfig/*.pc
%{prefix}/include/
Description: library with utility modules common in some Intra2net programs
Version: @VERSION@
Libs: -L${libdir} -li2ncommon_utils
-Cflags: -I${includedir}
+Cflags: -I${includedir} @BOOST_CFLAGS@
--- /dev/null
+include_directories(
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_SOURCE_DIR}/utils
+ ${ICONV_INCLUDE_DIRS}
+)
+
+SET(cpp_sources
+ cron.cpp
+ daemonfunc.cpp
+ filefunc.cpp
+ i18n.cpp
+ i2n_configfile.cpp
+ ipfunc.cpp
+ logfunc.cpp
+ logread.cpp
+ oftmpstream.cpp
+ pidfile.cpp
+ pointer_func.cpp
+ source_track_basics.cpp
+ stringfunc.cpp
+ timefunc.cpp
+ tmpfstream.cpp
+ tracefunc.cpp
+ tribool.cpp
+ userfunc.cpp
+ week.cpp
+)
+
+SET(hpp_sources
+ cron.hpp
+ daemonfunc.hpp
+ exception.hxx
+ filefunc.hxx
+ i18n.h
+ i2n_configdata.hpp
+ i2n_configfile.hpp
+ insocketstream.hxx
+ ip_type.hxx
+ ipfunc.hxx
+ log_macros.hpp
+ logfunc.hpp
+ logread.hxx
+ oftmpstream.hxx
+ pidfile.hpp
+ pipestream.hxx
+ pointer_func.hpp
+ source_track_basics.hpp
+ stringfunc.hxx
+ timefunc.hxx
+ tmpfstream.hpp
+ tmpfstream_impl.hpp
+ tracefunc.hpp
+ tribool.hpp
+ userfunc.hpp
+ week.hpp
+)
+
+add_library(i2ncommon SHARED ${cpp_sources} ${hpp_sources})
+
+target_link_libraries(i2ncommon ${Boost_IOSTREAMS_LIBRARIES} ${ICONV_LIBRARIES})
+
+set_target_properties(i2ncommon PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION})
+
+install(TARGETS i2ncommon
+ LIBRARY DESTINATION lib
+ COMPONENT sharedlibs)
+
+install(FILES ${cpp_headers}
+ DESTINATION include
+ COMPONENT headers)
+++ /dev/null
-
-# set the include path found by configure
-INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/utils @LIBICONV_CFLAGS@ @BOOST_CPPFLAGS@ $(all_includes)
-
-# the library search path.
-lib_LTLIBRARIES = libi2ncommon.la
-include_HEADERS = cron.hpp daemonfunc.hpp exception.hxx filefunc.hxx \
- i2n_configdata.hpp i2n_configfile.hpp insocketstream.hxx ip_type.hxx ipfunc.hxx \
- log_macros.hpp logfunc.hpp logread.hxx oftmpstream.hxx pidfile.hpp pipestream.hxx \
- pointer_func.hpp source_track_basics.hpp stringfunc.hxx timefunc.hxx tmpfstream.hpp \
- tmpfstream_impl.hpp tracefunc.hpp userfunc.hpp week.hpp tribool.hpp i18n.h
-
-libi2ncommon_la_SOURCES = cron.cpp daemonfunc.cpp filefunc.cpp \
- i2n_configfile.cpp ipfunc.cpp logfunc.cpp logread.cpp oftmpstream.cpp pidfile.cpp \
- pointer_func.cpp source_track_basics.cpp stringfunc.cpp timefunc.cpp tmpfstream.cpp \
- tracefunc.cpp userfunc.cpp week.cpp tribool.cpp i18n.cpp
-
-# Note: If you specify a:b:c as the version in the next line,
-# the library that is made has version (a-c).c.b. In this
-# example, the version is 2.1.2. (3:2:1)
-
-libi2ncommon_la_LDFLAGS = -version-info @LIBI2NCOMMON_LIB_VERSION@ @BOOST_LDFLAGS@
-
-libi2ncommon_la_LIBADD = @LIBICONV_LIBS@ @BOOST_IOSTREAMS_LIB@
--- /dev/null
+include_directories(
+ ${CMAKE_SOURCE_DIR}/configlib
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_SOURCE_DIR}/utils)
+
+########### next target ###############
+
+SET(cpp_sources
+ ip_range.cpp
+ stringfunc.cpp
+ test_containerfunc.cpp
+ test_cron_interval.cpp
+ test_cron_point.cpp
+ test_filefunc.cpp
+ test_global_config.cpp
+ test_logging.cpp
+ test_pidfile.cpp
+ test_timefunc.cpp
+ test_tmpfstream.cpp
+)
+
+add_executable(test_i2ncommon ${cpp_sources})
+
+# Add custom "make check" target which automatically builds the library
+add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_i2ncommon)
+
+# Invocation via "make test"
+enable_testing()
+add_test(test_i2ncommon test_i2ncommon)
+
+target_link_libraries(test_i2ncommon
+ i2ncommon
+ i2ncommon_utils
+ i2ncommon_config
+ ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}
+)
+++ /dev/null
-INCLUDES = -I$(top_srcdir)/configlib -I$(top_srcdir)/src -I$(top_srcdir)/utils @BOOST_CPPFLAGS@
-METASOURCES = AUTO
-check_PROGRAMS = test
-test_SOURCES = ip_range.cpp stringfunc.cpp test_containerfunc.cpp \
- test_cron_interval.cpp test_cron_point.cpp test_filefunc.cpp test_global_config.cpp \
- test_logging.cpp test_pidfile.cpp test_timefunc.cpp test_tmpfstream.cpp
-test_LDADD = $(top_builddir)/src/libi2ncommon.la $(top_builddir)/utils/libi2ncommon_utils.la \
- $(top_builddir)/configlib/libi2ncommon_config.la @BOOST_UNIT_TEST_FRAMEWORK_LIB@
-
-TESTS = test
BOOST_AUTO_TEST_CASE(StatTest1)
{
- I2n::Stat stat("test_filefunc.cpp");
+ I2n::Stat stat("Makefile");
BOOST_CHECK_EQUAL( true, (bool)stat );
BOOST_CHECK_EQUAL( true, stat.is_regular_file() );
BOOST_CHECK_EQUAL( true, res );
BOOST_CHECK( ! names.empty() );
- StringVector::iterator it = std::find( names.begin(), names.end(), "test_filefunc.cpp");
+ StringVector::iterator it = std::find( names.begin(), names.end(), "Makefile");
BOOST_CHECK( it != names.end() );
it = std::find( names.begin(), names.end(), "." );
--- /dev/null
+include_directories(${CMAKE_SOURCE_DIR}/src)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+set(cpp_sources
+ containerfunc.cpp
+ signalfunc.cpp
+)
+set(cpp_headers
+ containerfunc.hpp
+ signalfunc.hpp
+)
+
+add_library(i2ncommon_utils SHARED ${cpp_sources} ${hpp_sources})
+
+set_target_properties(i2ncommon_utils PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION})
+
+
+install(TARGETS i2ncommon_utils
+ LIBRARY DESTINATION lib
+ COMPONENT sharedlibs)
+
+install(FILES ${cpp_headers}
+ DESTINATION include
+ COMPONENT headers)
+++ /dev/null
-# set the include path found by configure
-INCLUDES = -I$(top_srcdir)/src @BOOST_CPPFLAGS@ $(all_includes)
-METASOURCES = AUTO
-
-lib_LTLIBRARIES = libi2ncommon_utils.la
-
-include_HEADERS = containerfunc.hpp signalfunc.hpp
-
-# Note: If you specify a:b:c as the version in the next line,
-# the library that is made has version (a-c).c.b. In this
-# example, the version is 2.1.2. (3:2:1)
-
-libi2ncommon_utils_la_LDFLAGS = -version-info @LIBI2NCOMMON_LIB_VERSION@ @BOOST_LDFLAGS@
-
-libi2ncommon_utils_la_SOURCES = containerfunc.cpp signalfunc.cpp
--- /dev/null
+include_directories(${CMAKE_SOURCE_DIR}/src)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${XMLPP_INCLUDE_DIRS})
+
+link_directories(${XMLPP_LIBRARY_DIRS})
+
+set(cpp_sources
+ xmlcommon.cpp
+)
+
+set(cpp_headers
+ xmlcommon.hpp
+)
+
+add_library(i2ncommon_xml SHARED ${cpp_sources} ${hpp_sources})
+
+target_link_libraries(i2ncommon_xml ${Xmlpp_LIBRARIES})
+
+set_target_properties(i2ncommon_xml PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION})
+
+install(TARGETS i2ncommon_xml
+ LIBRARY DESTINATION lib
+ COMPONENT sharedlibs)
+
+install(FILES ${cpp_headers}
+ DESTINATION include
+ COMPONENT headers)
+++ /dev/null
-# set the include path found by configure
-INCLUDES = -I$(top_srcdir)/src $(all_includes) @LIBXMLPP_CFLAGS@
-METASOURCES = AUTO
-
-lib_LTLIBRARIES = libi2ncommon_xml.la
-
-include_HEADERS = xmlcommon.hpp
-
-# Note: If you specify a:b:c as the version in the next line,
-# the library that is made has version (a-c).c.b. In this
-# example, the version is 2.1.2. (3:2:1)
-
-libi2ncommon_xml_la_LDFLAGS = -version-info @LIBI2NCOMMON_LIB_VERSION@
-
-libi2ncommon_xml_la_LIBADD = @LIBXMLPP_LIBS@
-libi2ncommon_xml_la_SOURCES = xmlcommon.cpp