Initial cmake conversion of the libt2n project except the example projects. The unit...
authorKristóf Katus <kristof.katus@intra2net.com>
Wed, 24 Aug 2011 07:43:40 +0000 (09:43 +0200)
committerKristóf Katus <kristof.katus@intra2net.com>
Wed, 24 Aug 2011 07:43:40 +0000 (09:43 +0200)
12 files changed:
CMakeLists.txt [new file with mode: 0644]
codegen/CMakeLists.txt [new file with mode: 0644]
codegen/main.cpp
libt2n.spec.in
src/CMakeLists.txt [new file with mode: 0644]
src/command_client.cpp
src/command_server.cpp
test/CMakeLists.txt [new file with mode: 0644]
test/hello.cpp
test/reconnect.cpp
test/timeout.cpp
test/wrapper.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3746728
--- /dev/null
@@ -0,0 +1,131 @@
+# Project
+project(libt2n)
+set(VERSION 0.6)
+set(PROTOCOL_VERSION 1) # protocol version used (integers, increase version if incompatible)
+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)
+
+find_package(Boost 1.33 REQUIRED COMPONENTS serialization unit_test_framework)
+include_directories(${Boost_INCLUDE_DIRS})
+
+pkg_check_modules(XMLPP REQUIRED libxml++-2.6>=2.8.1)
+include_directories(${XMLPP_INCLUDE_DIRS})
+link_directories(${XMLPP_LIBRARY_DIRS})
+
+# 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 codegen examples examples-codegen src 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)
+
+# Spec file
+configure_file(${CMAKE_SOURCE_DIR}/libt2n.spec.in ${CMAKE_SOURCE_DIR}/libt2n.spec @ONLY)
+
+# Check include files and availability of libraries for config file
+include(CheckIncludeFiles)
+
+if(Boost_FOUND)
+    set(HAVE_BOOST 1)
+endif()
+if(Boost_SERIALIZATION_FOUND)
+    set(HAVE_BOOST_SERIALIZATION 1)
+endif()
+if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
+    set(HAVE_BOOST_UNIT_TEST_FRAMEWORK 1)
+endif()
+check_include_files(dlfcn.h HAVE_DLFCN_H)
+check_include_files(inttypes.h HAVE_INTTYPES_H)
+check_include_files(memory.h HAVE_MEMORY_H)
+check_include_files(stdint.h HAVE_STDINT_H)
+check_include_files(stdlib.h HAVE_STDLIB_H)
+check_include_files(strings.h HAVE_STRINGS_H)
+check_include_files(string.h HAVE_STRING_H)
+check_include_files(sys/stat.h HAVE_SYS_STAT_H)
+check_include_files(sys/types.h HAVE_SYS_TYPES_H)
+check_include_files(unistd.h HAVE_UNISTD_H)
+set(STDC_HEADER_NAMES
+    assert.h
+    ctype.h
+    errno.h
+    float.h
+    limits.h
+    locale.h
+    math.h
+    setjmp.h
+    signal.h
+    stdarg.h
+    stddef.h
+    stdio.h
+    stdlib.h
+    string.h
+    time.h
+)
+check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS)
+
+# Config file
+configure_file(${CMAKE_SOURCE_DIR}/config.h.in.cmake ${CMAKE_BINARY_DIR}/config.h)
+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)
+set(bindir      ${exec_prefix})
+set(datadir     ${CMAKE_INSTALL_PREFIX}/share)
+
+# PkgConfig files
+configure_file(${CMAKE_SOURCE_DIR}/libt2n.pc.in ${CMAKE_BINARY_DIR}/libt2n.pc @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/libt2n.pc DESTINATION lib/pkgconfig)
+
+# Installation of scripts
+# install(PROGRAMS libt2n-gccxml.sh DESTINATION /usr/bin)
+
+# Subdirectories
+set(CPACK_SET_DESTDIR "ON")
+add_subdirectory(src)
+add_subdirectory(test)
+# add_subdirectory(examples)
+add_subdirectory(codegen)
+# add_subdirectory(examples-codegen)
+
+include(CPack)
diff --git a/codegen/CMakeLists.txt b/codegen/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cbdf18f
--- /dev/null
@@ -0,0 +1,14 @@
+# Sources
+set(CPP_SOURCES main.cpp)
+set(CPP_HEADERS codegen-stubhead.hxx)
+include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
+
+# Executables
+add_executable(libt2n_codegen ${CPP_SOURCES})
+
+# Dependencies
+target_link_libraries(libt2n_codegen ${XMLPP_LIBRARIES})
+
+# Installation
+install(TARGETS libt2n_codegen DESTINATION bin)
+install(FILES ${CPP_HEADERS} DESTINATION include)
index 75e58a0..105dc24 100644 (file)
@@ -30,9 +30,9 @@
 #include <stdexcept>
 #include <string>
 #include <boost/lexical_cast.hpp>
-#ifdef HAVE_CONFIG_H
+
 #include "config.h"
-#endif
+
 
 
 //! map group to class name
index f8333a9..f0bb751 100644 (file)
@@ -27,14 +27,25 @@ C++ IPC library devel files
 %setup -q
 
 %build
-autoreconf --force --install
-./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix}
-%__make %{?_smp_mflags}
+# autoreconf --force --install
+# ./configure $RPM_BUILD_WITH_OPTIMIZE --prefix=%{prefix}
+# %__make %{?_smp_mflags}
+
+mkdir build
+cd build
+
+export CFLAGS="$RPM_OPT_FLAGS"
+export CXXFLAGS="$RPM_OPT_FLAGS"
+
+cmake -DCMAKE_INSTALL_PREFIX="%{prefix}" ../
+
+dmake %{?_smp_mflags}
 
 export BOOST_TEST_LOG_LEVEL=test_suite
-make check
+dmake check
 
 %install
+cd build
 make DESTDIR=$RPM_BUILD_ROOT install
 
 %clean
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..936635c
--- /dev/null
@@ -0,0 +1,45 @@
+# Sources
+set(libt2n_SOURCES
+    client.cpp
+    client_wrapper.cpp
+    command.cpp
+    command_client.cpp
+    command_server.cpp
+    connection.cpp
+    container.cpp
+    server.cpp
+    socket_client.cpp
+    socket_handler.cpp
+    socket_server.cpp
+    socket_wrapper.cpp
+    t2n_exception.cpp
+)
+set(libt2n_HEADERS 
+    client.hxx
+    client_wrapper.hxx
+    command.hxx
+    command_client.hxx
+    command_server.hxx
+    connection.hxx
+    container.hxx
+    log.hxx
+    server.hxx
+    socket_client.hxx
+    socket_handler.hxx
+    socket_server.hxx
+    socket_wrapper.hxx
+    t2n_exception.hxx
+    types.hxx
+    container.tcc
+    t2n_exception.tcc
+)
+include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
+
+# Libraries
+add_library(libt2n SHARED ${libt2n_SOURCES} ${libt2n_HEADERS})
+set_target_properties(libt2n PROPERTIES VERSION ${VERSION} SOVERSION 0)
+set_target_properties(libt2n PROPERTIES OUTPUT_NAME t2n)
+
+# Installation
+install(TARGETS libt2n LIBRARY DESTINATION lib)
+install(FILES ${libt2n_HEADERS} DESTINATION include)
index 5d618b2..924fdbf 100644 (file)
@@ -33,9 +33,7 @@ on this file might be covered by the GNU General Public License.
 
 #include "command_client.hxx"
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 using namespace std;
 
index 1db24a4..21aeb79 100644 (file)
@@ -37,9 +37,7 @@ on this file might be covered by the GNU General Public License.
 #include "container.hxx"
 #include "log.hxx"
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 using namespace std;
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..66f7e7a
--- /dev/null
@@ -0,0 +1,30 @@
+# Sources
+set(test_SOURCES
+    newserver.cpp
+    callback.cpp
+    cmdgroup.cpp
+    comm.cpp
+    hello.cpp
+    reconnect.cpp
+    reentrant.cpp
+    serialize.cpp
+    simplecmd.cpp
+    timeout.cpp
+    wrapper.cpp
+    test_fixtures.hxx
+)
+include_directories(BEFORE
+    ${CMAKE_SOURCE_DIR}/src
+    ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+# Executables
+add_executable(test ${test_SOURCES})
+
+# Dependencies
+target_link_libraries(test libt2n ${Boost_SERIALIZATION_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
+
+# Tests
+add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test)
+enable_testing()
+add_test(test test)
index 6bce679..a7a885d 100644 (file)
@@ -42,9 +42,7 @@ on this file might be covered by the GNU General Public License.
 
 #include "test_fixtures.hxx"
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 using namespace std;
 using namespace libt2n;
index 80fc57f..227df56 100644 (file)
@@ -39,9 +39,7 @@ on this file might be covered by the GNU General Public License.
 
 #include "test_fixtures.hxx"
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 using namespace std;
 using namespace libt2n;
index c85d43e..936cc6a 100644 (file)
@@ -49,9 +49,7 @@ on this file might be covered by the GNU General Public License.
 
 #include "test_fixtures.hxx"
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 using namespace std;
 using namespace libt2n;
index b1d30cd..5fedaf5 100644 (file)
@@ -50,9 +50,7 @@ on this file might be covered by the GNU General Public License.
 
 #include "test_fixtures.hxx"
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 using namespace std;
 using namespace libt2n;