From: Kristóf Katus Date: Tue, 23 Aug 2011 08:00:23 +0000 (+0200) Subject: Initial commit of the cmake conversion of the libasyncio project. The test testsimple... X-Git-Tag: v0.3~11^2~5 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=6cb16c219a47b5b776a64c495090ba284a06cbd2;p=libasyncio Initial commit of the cmake conversion of the libasyncio project. The test testsimpleio fails with buffer overflow. --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bd5d8e4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,105 @@ +# Project +project(libasyncio) +set(VERSION 0.2) +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") + +# CMake +set(CMAKE_COLOR_MAKEFILE ON) +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) + +# Source package generation +set(CPACK_SOURCE_GENERATOR TGZ) +set(CPACK_SOURCE_IGNORE_FILES "~$;\\\\.git;build;build-rpm") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION}") + +# Find external packages +include(FindPkgConfig) + +option(WITH_LIBI2NCOMMON OFF) +if(WITH_LIBI2NCOMMON) + pkg_check_modules(LIBI2NCOMMON REQUIRED libi2ncommon) + include_directories(${LIBI2NCOMMON_INCLUDE_DIRS}) + link_directories(${LIBI2NCOMMON_LIBRARY_DIRS}) +elseif(WITH_LIBI2NCOMMON) + message(STATUS "[!] Building *without* libi2ncommon support. [!]") +endif(WITH_LIBI2NCOMMON) + +find_package(Boost 1.34 REQUIRED COMPONENTS signals unit_test_framework) +include_directories(${Boost_INCLUDE_DIRS}) + +option(WITH_LIBT2N OFF) +if(WITH_LIBT2N) + pkg_check_modules(LIBT2N REQUIRED libt2n) + include_directories(${LIBT2N_INCLUDE_DIRS}) + link_directories(${LIBT2N_LIBRARY_DIRS}) + set(T2NDIRS glue_t2n) +elseif(WITH_LIBT2N) + message(STATUS "[!] Building *without* libt2n support. [!]") +endif(WITH_LIBT2N) + +# Documentation +find_package(Doxygen) +if(DOXYGEN_FOUND) + # 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 utils asyncio ${T2NDIRS} unittest + ) + + # 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) + +# Spec file +configure_file(${CMAKE_SOURCE_DIR}/libasyncio.spec.in ${CMAKE_SOURCE_DIR}/libasyncio.spec @ONLY) + +# Config file +configure_file(${CMAKE_SOURCE_DIR}/asyncio_config.hpp.in.cmake ${CMAKE_BINARY_DIR}/asyncio_config.hpp) +include_directories(BEFORE ${CMAKE_BINARY_DIR}) + +# 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) + +# PkgConfig files +configure_file(${CMAKE_SOURCE_DIR}/asyncio/libasyncio.pc.in ${CMAKE_BINARY_DIR}/asyncio/libasyncio.pc @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/utils/libasyncio_utils.pc.in ${CMAKE_BINARY_DIR}/utils/libasyncio_utils.pc @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/glue_t2n/libasyncio_t2n.pc.in ${CMAKE_BINARY_DIR}/glue_t2n/libasyncio_t2n.pc @ONLY) + +install(FILES ${CMAKE_BINARY_DIR}/asyncio/libasyncio.pc DESTINATION lib/pkgconfig) +install(FILES ${CMAKE_BINARY_DIR}/utils/libasyncio_utils.pc DESTINATION lib/pkgconfig) +install(FILES ${CMAKE_BINARY_DIR}/glue_t2n/libasyncio_t2n.pc DESTINATION lib/pkgconfig) + +# Subdirectories +set(CPACK_SET_DESTDIR "ON") +add_subdirectory(utils) +add_subdirectory(asyncio) +if(${WITH_LIBT2N}) + add_subdirectory(${T2NDIRS}) +endif(${WITH_LIBT2N}) +add_subdirectory(unittest) + +include(CPack) diff --git a/asyncio/CMakeLists.txt b/asyncio/CMakeLists.txt new file mode 100644 index 0000000..4d16a7f --- /dev/null +++ b/asyncio/CMakeLists.txt @@ -0,0 +1,41 @@ +# Sources +set(libasyncio_SOURCES + async_callout.cpp + async_io.cpp + async_pipe.cpp + async_process.cpp + async_socket.cpp + async_timer.cpp +) +set(libasyncio_HEADERS + async_callout.hpp + async_io.hpp + async_pipe.hpp + async_process.hpp + async_socket.hpp + async_timer.hpp + ${CMAKE_BINARY_DIR}/asyncio_config.hpp +) +include_directories(BEFORE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/utils + ${CMAKE_SOURCE_DIR}/utils/i2ncommon + ) + +# Libraries +add_library(libasyncio SHARED ${libasyncio_SOURCES} ${libasyncio_HEADERS}) +set_target_properties(libasyncio PROPERTIES VERSION ${VERSION} SOVERSION 0) +set_target_properties(libasyncio PROPERTIES OUTPUT_NAME asyncio) + +# Dependencies +target_link_libraries(libasyncio ${LIBI2NCOMMON_LIBRARIES} ${Boost_LIBRARIES}) + +# Headerlist +foreach(header_file_in ${libasyncio_HEADERS}) + set(header_files_out "${header_files_out}${includedir}/${header_file_in}\n") +endforeach() +file(WRITE ${CMAKE_BINARY_DIR}/headerlist.asyncio ${header_files_out}) + +# Installation +install(TARGETS libasyncio LIBRARY DESTINATION lib) +install(FILES ${libasyncio_HEADERS} DESTINATION include) diff --git a/asyncio_config.hpp.in.cmake b/asyncio_config.hpp.in.cmake new file mode 100644 index 0000000..b21e03a --- /dev/null +++ b/asyncio_config.hpp.in.cmake @@ -0,0 +1,73 @@ +/* asyncio_config.hpp.in: configure input file for cmake */ + +/* define if the Boost library is available */ +#cmakedefine HAVE_BOOST ${Boost_FOUND} + +/* define if the Boost::Signals library is available */ +#cmakedefine HAVE_BOOST_SIGNALS ${Boost_SIGNALS_FOUND} + +/* define if the Boost::Unit_Test_Framework library is available */ +#cmakedefine HAVE_BOOST_UNIT_TEST_FRAMEWORK ${Boost_UNIT_TEST_FRAMEWORK_FOUND} + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_INTTYPES_H + +/* define if libi2ncommon is available */ +#cmakedefine HAVE_LIBI2NCOMMON ${LIBI2NCOMMON_FOUND} + +/* define if libt2n is available */ +#cmakedefine HAVE_LIBT2N ${LIBT2N_FOUND} + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_UNISTD_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. */ +#cmakedefine LT_OBJDIR "${LT_OBJDIR}" + +/* Name of package */ +#cmakedefine PACKAGE "${PROJECT_NAME}" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME "${PROJECT_NAME}" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "${PROJECT_NAME} ${VERSION}" + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME "${PROJECT_NAME}" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "${VERSION}" + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine01 STDC_HEADERS + +/* Version number of package */ +#cmakedefine VERSION "${VERSION}" diff --git a/glue_t2n/CMakeLists.txt b/glue_t2n/CMakeLists.txt new file mode 100644 index 0000000..e97088e --- /dev/null +++ b/glue_t2n/CMakeLists.txt @@ -0,0 +1,20 @@ +# Sources +set(libasyncio_t2n_SOURCES asyncio_t2n.cpp) +set(libasyncio_t2n_HEADERS asyncio_t2n.hpp) +include_directories(BEFORE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/asyncio + ${CMAKE_SOURCE_DIR}/utils + ) + +# Libraries +add_library(libasyncio_t2n SHARED ${libasyncio_t2n_SOURCES} ${libasyncio_t2n_HEADERS}) +set_target_properties(libasyncio_t2n PROPERTIES VERSION ${VERSION} SOVERSION 0) +set_target_properties(libasyncio_t2n PROPERTIES OUTPUT_NAME asyncio_t2n) + +# Dependencies +target_link_libraries(libasyncio_t2n libasyncio ${LIBT2N_LIBRARIES} ${LIBI2NCOMMON_LIBRARIES} ${Boost_SIGNALS_LIBRARIES}) + +# Installation +install(TARGETS libasyncio_t2n LIBRARY DESTINATION lib) +install(FILES ${libasyncio_t2n_HEADERS} DESTINATION include) diff --git a/libasyncio.spec b/libasyncio.spec.bak similarity index 79% rename from libasyncio.spec rename to libasyncio.spec.bak index 0f17acf..ef43b31 100644 --- a/libasyncio.spec +++ b/libasyncio.spec.bak @@ -6,11 +6,11 @@ License: GPL version 2 + linking exception Group: Intranator Vendor: Intra2net AG Source: %{name}-%{version}.tar.gz -Buildroot: /tmp/%{name}-%{version}-root +# Buildroot: /tmp/%{name}-%{version}-root Prefix: /usr Requires: libi2ncommon >= 1.0 Requires: boost >= 1.32.0 -BuildPrereq: libtool +# BuildPrereq: libtool BuildRequires: boost-devel >= 1.32.0 Obsoletes: libsimpleio @@ -43,7 +43,7 @@ are also usable for other purposes, too. %package utils-devel Summary: library with asynchronous io functionality Group: Intranator/Development -Requires: boost-devel >= 1.32.0 +Requires: boost-devel >= 1.32.0 %description utils-devel development files for asyncio utils. @@ -75,17 +75,36 @@ development files for glue lib for using t2n with simpleio. %build export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/intranator/lib/pkgconfig -autoreconf --force -i -./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix} -make +# autoreconf --force -i +# ./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix} + +mkdir build +cd build + +export CFLAGS="$RPM_OPT_FLAGS" +export CXXFLAGS="$RPM_OPT_FLAGS" + +CMAKE_OPTS="" +%if %{with libi2ncommon} + CMAKE_OPTS="$CMAKE_OPTS -DWITH_LIBI2NCOMMON=ON" +%endif +%if %{with libt2n} + CMAKE_OPTS="$CMAKE_OPTS -DWITH_LIBT2N=ON" +%endif + +cmake -DCMAKE_INSTALL_PREFIX="%{prefix}" $CMAKE_OPTS ../ + +dmake %{?_smp_mflags} -for dir in utils asyncio; do - make -C $dir headerlist -done +# for dir in utils asyncio; do +# make -C $dir headerlist +# done -make check +export BOOST_TEST_LOG_LEVEL=test_suite +dmake check %install +cd build make DESTDIR=$RPM_BUILD_ROOT install # Remove unpackaged files diff --git a/libasyncio.spec.in b/libasyncio.spec.in index acfe250..a496757 100644 --- a/libasyncio.spec.in +++ b/libasyncio.spec.in @@ -1,7 +1,9 @@ -@HAVE_LIBI2NCOMMON_TRUE@%define with_libi2ncommon 1 -@HAVE_LIBI2NCOMMON_FALSE@%define with_libi2ncommon 0 -@HAVE_LIBT2N_TRUE@%define with_t2n 1 -@HAVE_LIBT2N_FALSE@%define with_t2n 1 +# @HAVE_LIBI2NCOMMON_TRUE@%define with_libi2ncommon 1 +# @HAVE_LIBI2NCOMMON_FALSE@%define with_libi2ncommon 0 +# @HAVE_LIBT2N_TRUE@%define with_libt2n 1 +# @HAVE_LIBT2N_FALSE@%define with_libt2n 0 +%define with_libi2ncommon 1 +%define with_libt2n 1 Summary: library with asynchronous io functionality Name: libasyncio @@ -11,11 +13,12 @@ License: GPL version 2 + linking exception Group: Intranator Vendor: Intra2net AG Source: %{name}-%{version}.tar.gz -Buildroot: /tmp/%{name}-%{version}-root +# Buildroot: /tmp/%{name}-%{version}-root Prefix: /usr Requires: libi2ncommon >= 1.0 +Requires: boost >= 1.32.0 Requires: libasynio-utils = %{version} -BuildRequires: libtool +# BuildRequires: libtool BuildRequires: boost-devel >= 1.32.0 Obsoletes: libsimpleio @@ -38,9 +41,10 @@ development files for library with asynchronous io functionality %package utils Summary: library with asynchronous io functionality Group: Intranator -%if %{with_libi2ncommon} +%if %{with libi2ncommon} Requires: libi2ncommon >= 1.0 %endif +Requires: boost >= 1.32.0 %description utils A collection of util function and classes used within asyncio, but @@ -56,7 +60,7 @@ Requires: boost-devel >= 1.32.0 development files for asyncio utils. -%if %{with_libt2n} +%if %{with libt2n} %package t2n Summary: glue library for using t2n with libasyncio Group: Intranator @@ -84,18 +88,36 @@ development files for glue lib for using t2n with simpleio. %build export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/intranator/lib/pkgconfig -autoreconf --force -i -./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix} -make %{?_smp_mflags} +# autoreconf --force -i +# ./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix} -for dir in utils asyncio; do - make -C $dir headerlist -done +mkdir build +cd build + +export CFLAGS="$RPM_OPT_FLAGS" +export CXXFLAGS="$RPM_OPT_FLAGS" + +CMAKE_OPTS="" +%if %{with libi2ncommon} + CMAKE_OPTS="$CMAKE_OPTS -DWITH_LIBI2NCOMMON=ON" +%endif +%if %{with libt2n} + CMAKE_OPTS="$CMAKE_OPTS -DWITH_LIBT2N=ON" +%endif + +cmake -DCMAKE_INSTALL_PREFIX="%{prefix}" $CMAKE_OPTS ../ + +dmake %{?_smp_mflags} + +# for dir in utils asyncio; do +# make -C $dir headerlist +# done export BOOST_TEST_LOG_LEVEL=test_suite -make check +dmake check %install +cd build make DESTDIR=$RPM_BUILD_ROOT install # Remove unpackaged files @@ -129,8 +151,7 @@ rm -fr $RPM_BUILD_ROOT %{prefix}/lib/libasyncio.*a* %{prefix}/lib/pkgconfig/libasyncio_utils.pc - -%if %{with_libt2n} +%if %{with libt2n} %files t2n %defattr(-,root,root) %doc LICENSE diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 0000000..f7ee01f --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,17 @@ +# Sources +set(testsimpleio_SOURCES test_simpleio_basics.cpp) +include_directories(BEFORE + ${CMAKE_SOURCE_DIR}/asyncio + ${CMAKE_SOURCE_DIR}/utils +) + +# Executables +add_executable(testsimpleio ${testsimpleio_SOURCES}) + +# Dependencies +target_link_libraries(testsimpleio libasyncio_utils libasyncio ${Boost_LIBRARIES} ${LIBI2NCOMMON_LIBRARIES}) + +# Tests +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS testsimpleio) +enable_testing() +add_test(testsimpleio testsimpleio) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000..9e00c25 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,38 @@ +# Sources +if(WITH_LIBI2NCOMMON) + set(compat_HEADERS i2ncommon/containerfunc.hpp i2ncommon/signalfunc.hpp) + set(compat_SOURCES i2ncommon/containerfunc.cpp i2ncommon/signalfunc.cpp) +endif(WITH_LIBI2NCOMMON) +set(libasyncio_utils_SOURCES + asyncio_time_tools.cpp + asyncio_utils.cpp + asyncio_system_tools.cpp + ${compat_SOURCES} +) +set(libasyncio_utils_HEADERS + asyncio_ptr_list.hpp + asyncio_utils.hpp + asyncio_time_tools.hpp + asyncio_pointer_func.hpp + asyncio_system_tools.hpp + asyncio_containerfunc.hpp + asyncio_signalfunc.hpp + ${compat_HEADERS} +) +include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/i2ncommon) + +# Libraries +add_library(libasyncio_utils SHARED ${libasyncio_utils_SOURCES} ${libasyncio_utils_HEADERS}) +set_target_properties(libasyncio_utils PROPERTIES VERSION ${VERSION} SOVERSION 0) +set_target_properties(libasyncio_utils PROPERTIES OUTPUT_NAME asyncio_utils) + +# Headerlist +foreach(header_file_in ${libasyncio_utils_HEADERS}) + set(header_files_out "${header_files_out}${includedir}/${header_file_in}\n") +endforeach() +file(WRITE ${CMAKE_BINARY_DIR}/headerlist.utils ${header_files_out}) + +# Installation +install(TARGETS libasyncio_utils LIBRARY DESTINATION lib) +install(FILES ${libasyncio_utils_HEADERS} DESTINATION include)