The branch, cmake-conversion has been updated
via 471f240f070a5e34892f90be2b0dfc55c09c6fc7 (commit)
via 9fe43ede225bae3072564605f9fd74e663ed19aa (commit)
from ab2a4234912fd8325e966235d592b632290413df (commit)
- Log -----------------------------------------------------------------
commit 471f240f070a5e34892f90be2b0dfc55c09c6fc7
Author: Kristóf Katus <kristof.katus@xxxxxxxxxxxxx>
Date: Wed Aug 24 17:27:54 2011 +0200
Initial commit of example projects (except: example2-client).
commit 9fe43ede225bae3072564605f9fd74e663ed19aa
Author: Kristóf Katus <kristof.katus@xxxxxxxxxxxxx>
Date: Wed Aug 24 17:24:28 2011 +0200
Initial fix of Libt2n.cmake.
-----------------------------------------------------------------------
Summary of changes:
examples-codegen/cmake/Libt2n.cmake | 94 +++++++++++--------
.../example1-client-wrapper/CMakeLists.txt | 36 ++++++++
examples-codegen/example1-client/CMakeLists.txt | 36 ++++++++
examples-codegen/example1/CMakeLists.txt | 61 +++++++++++++
examples-codegen/example2/CMakeLists.txt | 90 +++++++++++++++++++
examples/CMakeLists.txt | 44 +++++++++
6 files changed, 321 insertions(+), 40 deletions(-)
create mode 100644 examples-codegen/example1-client-wrapper/CMakeLists.txt
create mode 100644 examples-codegen/example1-client/CMakeLists.txt
create mode 100644 examples-codegen/example1/CMakeLists.txt
create mode 100644 examples-codegen/example2/CMakeLists.txt
create mode 100644 examples/CMakeLists.txt
diff --git a/examples-codegen/cmake/Libt2n.cmake
b/examples-codegen/cmake/Libt2n.cmake
index dca8d17..ee0e9ef 100644
--- a/examples-codegen/cmake/Libt2n.cmake
+++ b/examples-codegen/cmake/Libt2n.cmake
@@ -1,13 +1,13 @@
-# Detect libt2n. Version of this file: 1.0
+# Detect libt2n. Version of this file: 1.1
pkg_check_modules(LIBT2N REQUIRED libt2n)
-INCLUDE_DIRECTORIES(${LIBT2N_INCLUDE_DIRS})
-LINK_DIRECTORIES(${LIBT2N_LIBRARY_DIRS})
+include_directories(${LIBT2N_INCLUDE_DIRS})
+link_directories(${LIBT2N_LIBRARY_DIRS})
# Get locations from pkgconfig
-execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable libt2n_codegen
libt2n
+execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable libt2n_codegen
libt2n
OUTPUT_VARIABLE LIBT2N_CODEGEN
OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable libt2n_datadir
libt2n
+execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable libt2n_datadir
libt2n
OUTPUT_VARIABLE LIBT2N_DATADIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LIBT2N_CLIENT_PCTEMPLATE ${LIBT2N_DATADIR}/clientlib.pc.in)
@@ -21,48 +21,61 @@ set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
# Setup libt2n. Arguments are the CMDGROUP names
function(setup_libt2n)
- include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})
-
- string(LENGTH ${ARGV} CMDGROUP_LEN)
+ string(LENGTH "${ARGV}" CMDGROUP_LEN)
if (${CMDGROUP_LEN} EQUAL 0)
message(FATAL_ERROR "libt2n CMDGROUP is empty")
endif(${CMDGROUP_LEN} EQUAL 0)
+ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})
+
+ # Compute include directories
+ # TODO: http://www.cmake.org/Bug/view.php?id=11889 contains a better
solution
+ get_property(gcc_include_dirs
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ PROPERTY INCLUDE_DIRECTORIES
+ )
+ set(gccxml_include_dirs "")
+ foreach(gcc_include_dir ${gcc_include_dirs})
+ set(gccxml_include_dirs "${gccxml_include_dirs} -I${gcc_include_dir}")
+ endforeach(gcc_include_dir ${gcc_include_dirs})
+
foreach(CMDGROUP ${ARGV})
message("Processing libt2n command group ${CMDGROUP}")
# Run each .cpp file through gccxml
+ set(T2N_GCCXML_FILES "")
+ # string(REGEX REPLACE "\\.cpp$" ".xml" T2N_GCCXML_FILES
"${${CMDGROUP}_GROUP}")
foreach(T2NFILE ${${CMDGROUP}_GROUP})
get_filename_component(FILE_WE ${T2NFILE} NAME_WE)
- get_filename_component(NAME ${T2NFILE} NAME)
- message(" Processing file ${NAME}")
-
- # Compute include directories
- # TODO: http://www.cmake.org/Bug/view.php?id=11889 contains a
better solution
- get_property(gcc_include_dirs
- DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- PROPERTY INCLUDE_DIRECTORIES
- )
- set(gccxml_include_dirs "")
- foreach(gcc_include_dir ${gcc_include_dirs})
- set(gccxml_include_dirs "${gccxml_include_dirs}
-I${gcc_include_dir}")
- endforeach(gcc_include_dir ${gcc_include_dirs})
-
- add_custom_command(OUTPUT ${FILE_WE}_common.cpp
${FILE_WE}_common.hxx ${FILE_WE}_client.cpp ${FILE_WE}_client.hxx
${FILE_WE}_server.cpp ${FILE_WE}_server.hxx
- # Create dummy _common.hxx file
- COMMAND echo "\\#include \\\"codegen-stubhead.hxx\\\""
>${FILE_WE}_common.hxx
- COMMAND echo "\\#include \\\"${FILE_WE}.hxx\\\""
>>${FILE_WE}_common.hxx
-
- # Invoke gccxml
- COMMAND ${LIBT2N_GCCXML} ${gccxml_include_dirs} ${T2NFILE}
-fxml=${FILE_WE}.xml || rm -f ${FILE_WE}_common.hxx
-
- # Transform xml file to real code
- COMMAND ${LIBT2N_CODEGEN} ${CMDGROUP} ${FILE_WE}.xml
- COMMAND rm -f ${FILE_WE}.xml
-
- DEPENDS ${T2NFILE}
- )
+ get_filename_component(FILE_NAME ${T2NFILE} NAME)
+ message(" Processing file ${FILE_NAME}")
+
+ add_custom_command(
+ OUTPUT ${FILE_WE}.xml
+ # Create dummy _common.hxx file
+ COMMAND echo "\\#include \\\"codegen-stubhead.hxx\\\""
>${CMDGROUP}_common.hxx
+ COMMAND echo "\\#include \\\"${CMDGROUP}.hxx\\\""
>>${CMDGROUP}_common.hxx
+
+ # Invoke gccxml
+ COMMAND ${LIBT2N_GCCXML} ${gccxml_include_dirs} ${T2NFILE}
-fxml=${FILE_WE}.xml || rm -f ${CMDGROUP}_common.hxx
+
+ DEPENDS ${T2NFILE}
+ )
+
+ # Created intermediate gccxml filenames for current CMDGROUP
+ set(T2N_GCCXML_FILES ${T2N_GCCXML_FILES} ${FILE_WE}.xml)
endforeach(T2NFILE ${${CMDGROUP}_GROUP})
+ # Wait till generated gccxml files are available
+ # add_custom_target(${CMDGROUP}_gccxml_done ALL DEPENDS ???)
+message("--- ${T2N_GCCXML_FILES} ---")
+ add_custom_command(OUTPUT ${CMDGROUP}_common.cpp ${CMDGROUP}_common.hxx
${CMDGROUP}_client.cpp ${CMDGROUP}_client.hxx ${CMDGROUP}_server.cpp
${CMDGROUP}_server.hxx
+ # Transform xml files to real code
+ COMMAND ${LIBT2N_CODEGEN} ${CMDGROUP} ${T2N_GCCXML_FILES}
+ COMMAND rm -f ${T2N_GCCXML_FILES}
+
+ DEPENDS ${T2N_GCCXML_FILES}
+ # DEPENDS ${CMDGROUP}_gccxml_done
+ )
# Write out pkgconfig file
configure_file(${LIBT2N_CLIENT_PCTEMPLATE}
${CMAKE_CURRENT_BINARY_DIR}/${CMDGROUP}.pc @ONLY@)
@@ -70,12 +83,12 @@ function(setup_libt2n)
DESTINATION lib/pkgconfig)
# Create shared client library
- add_library(${CMDGROUP} SHARED ${FILE_WE}_client.cpp
${FILE_WE}_client.hxx)
+ add_library(${CMDGROUP} SHARED ${CMDGROUP}_client.cpp
${CMDGROUP}_client.hxx)
set_target_properties(${CMDGROUP} PROPERTIES VERSION ${VERSION}
SOVERSION 1)
install(TARGETS ${CMDGROUP} LIBRARY DESTINATION lib COMPONENT
sharedlibs)
# Create static client library
- add_library(${CMDGROUP}-static STATIC ${FILE_WE}_client.cpp
${FILE_WE}_client.hxx)
+ add_library(${CMDGROUP}-static STATIC ${CMDGROUP}_client.cpp
${CMDGROUP}_client.hxx)
set_target_properties(${CMDGROUP}-static PROPERTIES OUTPUT_NAME
"${CMDGROUP}")
install(TARGETS ${CMDGROUP}-static ARCHIVE DESTINATION lib COMPONENT
staticlibs)
@@ -83,13 +96,14 @@ function(setup_libt2n)
set_target_properties(${CMDGROUP} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(${CMDGROUP}-static PROPERTIES
CLEAN_DIRECT_OUTPUT 1)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${FILE_WE}_client.hxx
${FILE_WE}.hxx
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMDGROUP}_client.hxx
${CMDGROUP}.hxx
DESTINATION include
COMPONENT headers
)
# Wait till generated code is available
- add_custom_target(${CMDGROUP}_codegen_done ALL DEPENDS
${FILE_WE}_common.cpp)
+ # add_custom_target(${CMDGROUP}_codegen_done ALL DEPENDS
${CMDGROUP}_common.cpp)
+ add_custom_target(${CMDGROUP}_codegen_done ALL DEPENDS
${CMDGROUP}_common.cpp ${CMDGROUP}_common.hxx ${CMDGROUP}_client.cpp
${CMDGROUP}_client.hxx ${CMDGROUP}_server.cpp ${CMDGROUP}_server.hxx)
add_dependencies(${CMDGROUP} ${CMDGROUP}_codegen_done)
add_dependencies(${CMDGROUP}-static ${CMDGROUP}_codegen_done)
diff --git a/examples-codegen/example1-client-wrapper/CMakeLists.txt
b/examples-codegen/example1-client-wrapper/CMakeLists.txt
new file mode 100644
index 0000000..dbd8e91
--- /dev/null
+++ b/examples-codegen/example1-client-wrapper/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Project
+project(libt2n-example1-client-wrapper)
+set(VERSION 0.1)
+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)
+
+pkg_check_modules(T2NEXAMPLE REQUIRED t2nexample=0.1)
+include_directories(${T2NEXAMPLE_INCLUDE_DIRS})
+link_directories(${T2NEXAMPLE_LIBRARY_DIRS})
+
+include(CPack)
+
+# Sources
+set(libt2n_example1_client_wrapper_SOURCES
+ client.cpp
+)
+
+# Executables
+add_executable(libt2n-example1-client-wrapper
${libt2n_example1_client_wrapper_SOURCES})
+
+# Dependencies
+target_link_libraries(libt2n-example1-client-wrapper ${T2NEXAMPLE_LIBRARIES})
+
+# Installation
+# install(TARGETS libt2n-example1-client-wrapper DESTINATION bin)
diff --git a/examples-codegen/example1-client/CMakeLists.txt
b/examples-codegen/example1-client/CMakeLists.txt
new file mode 100644
index 0000000..ccfe1ca
--- /dev/null
+++ b/examples-codegen/example1-client/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Project
+project(libt2n-example1-client)
+set(VERSION 0.1)
+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)
+
+pkg_check_modules(T2NEXAMPLE REQUIRED t2nexample=0.1)
+include_directories(${T2NEXAMPLE_INCLUDE_DIRS})
+link_directories(${T2NEXAMPLE_LIBRARY_DIRS})
+
+include(CPack)
+
+# Sources
+set(libt2n_example1_client_SOURCES
+ client.cpp
+)
+
+# Executables
+add_executable(libt2n-example1-client ${libt2n_example1_client_SOURCES})
+
+# Dependencies
+target_link_libraries(libt2n-example1-client ${T2NEXAMPLE_LIBRARIES})
+
+# Installation
+# install(TARGETS libt2n-example1-client DESTINATION bin)
diff --git a/examples-codegen/example1/CMakeLists.txt
b/examples-codegen/example1/CMakeLists.txt
new file mode 100644
index 0000000..3d3efdb
--- /dev/null
+++ b/examples-codegen/example1/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Project
+project(libt2n-example1)
+set(VERSION 0.1)
+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)
+
+pkg_check_modules(LIBT2N REQUIRED libt2n>=0.2)
+include_directories(${LIBT2N_INCLUDE_DIRS})
+link_directories(${LIBT2N_LIBRARY_DIRS})
+
+include(CPack)
+
+# Setup libt2n
+# for each command group list the files to parse for LIBT2N_EXPORT
+set(t2nexample_GROUP ${CMAKE_CURRENT_SOURCE_DIR}/t2nexample.cpp)
+# include CMake snippet doing all the magic
+include(${CMAKE_SOURCE_DIR}/../cmake/Libt2n.cmake)
+# command groups are listed here (seperated by spaces)
+setup_libt2n(t2nexample)
+
+# Sources
+# for each group build a client library from generated source file(s)
+# Note: the library name must match the group name
+set(libt2nexample_SOURCES
+ t2nexample_client.cpp
+)
+set(libt2n_example1_server_SOURCES
+ server.cpp
+ ${t2nexample_GROUP}
+ t2nexample_server.cpp
+)
+
+# Executables
+# build server program
+add_executable(libt2n-example1-server ${libt2n_example1_server_SOURCES})
+
+# Libraries
+add_library(libt2nexample STATIC ${libt2nexample_SOURCES})
+set_target_properties(libt2nexample PROPERTIES OUTPUT_NAME t2nexample)
+
+# Dependencies
+target_link_libraries(libt2n-example1-server ${LIBT2N_LIBRARIES})
+target_link_libraries(libt2nexample t2nexample ${LIBT2N_LIBRARIES})
+
+add_dependencies(libt2n-example1-server t2n_arnielizer_codegen_done)
+add_dependencies(libt2nexample t2n_arnielizer_codegen_done)
+
+# Installation
+# install(TARGETS libt2n-example1-server DESTINATION bin)
+# install(TARGETS libt2nexample ARCHIVE DESTINATION lib)
diff --git a/examples-codegen/example2/CMakeLists.txt
b/examples-codegen/example2/CMakeLists.txt
new file mode 100644
index 0000000..7d4a461
--- /dev/null
+++ b/examples-codegen/example2/CMakeLists.txt
@@ -0,0 +1,90 @@
+# Project
+project(libt2n-example2)
+set(VERSION 0.1)
+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)
+
+pkg_check_modules(LIBT2N REQUIRED libt2n>=0.2)
+include_directories(${LIBT2N_INCLUDE_DIRS})
+link_directories(${LIBT2N_LIBRARY_DIRS})
+
+include(CPack)
+
+# Setup libt2n
+# for each command group list the files to parse for LIBT2N_EXPORT
+set(default_GROUP
+ ${CMAKE_CURRENT_SOURCE_DIR}/default.cpp
+)
+# example of a command group using multiple cpp files
+set(other_GROUP
+ ${CMAKE_CURRENT_SOURCE_DIR}/other-1.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/other-2.cpp
+)
+# headers declaring data types used as rpc arguments must be listed manually
(???)
+# (in this example the class Foo)
+set(CPP_HEADERS
+ ${CMAKE_CURRENT_SOURCE_DIR}/foo.hxx
+)
+# include CMake snippet doing all the magic
+include(${CMAKE_SOURCE_DIR}/../cmake/Libt2n.cmake)
+# command groups are listed here (seperated by spaces)
+setup_libt2n(default other)
+
+# Sources
+# for each group build a client library from generated source file(s)
+# Note: the library name must match the group name
+set(libdefault_SOURCES
+ default_client.cpp
+)
+set(libother_SOURCES
+ other_client.cpp
+)
+# build an example server and client
+set(client_SOURCES
+ client.cpp
+)
+set(libt2n_example2_server_SOURCES
+ other_server.cpp
+ default_server.cpp
+ server.cpp
+ ${other_GROUP}
+ ${default_GROUP}
+)
+
+# Libraries
+add_library(libdefault STATIC ${libdefault_SOURCES})
+set_target_properties(libdefault PROPERTIES OUTPUT_NAME default)
+
+add_library(libother STATIC ${libother_SOURCES})
+set_target_properties(libother PROPERTIES OUTPUT_NAME other)
+
+# Executables
+# build server program
+add_executable(libt2n-example2-server ${libt2n_example2_server_SOURCES})
+
+# Dependencies
+target_link_libraries(libdefault ${LIBT2N_LIBRARIES})
+add_dependencies(libdefault default_codegen_done)
+
+target_link_libraries(libother ${LIBT2N_LIBRARIES})
+add_dependencies(libother other_codegen_done)
+
+target_link_libraries(libt2n-example2-server ${LIBT2N_LIBRARIES} libdefault
libother)
+add_dependencies(libt2n-example2-server default_codegen_done
other_codegen_done)
+
+# Installation
+# install(TARGETS default_client ARCHIVE DESTINATION lib)
+# install(TARGETS other_client ARCHIVE DESTINATION lib)
+# install(TARGETS libt2n-example2-server DESTINATION bin)
+# install(FILES ${CPP_HEADERS} DESTINATION include)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..a5a3396
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,44 @@
+# Sources
+set(libminimalistic_client_SOURCES
+ minimalistic-stub.hxx
+ minimalistic-stub-once.hxx
+ minimalistic-client-stub.hxx
+ minimalistic-client-stub.cpp
+)
+set(minimalistic_client_SOURCES
+ minimalistic-client.cpp
+)
+set(minimalistic_server_SOURCES
+ minimalistic-server.cpp
+ minimalistic-server-stub.cpp
+)
+include_directories(
+ BEFORE
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+# Libraries
+add_library(libminimalistic_client STATIC ${libminimalistic_client_SOURCES})
+set_target_properties(libminimalistic_client PROPERTIES OUTPUT_NAME
minimalistic_client)
+
+# Executables
+add_executable(minimalistic_client ${minimalistic_client_SOURCES})
+add_executable(minimalistic_server ${minimalistic_server_SOURCES})
+
+# Dependencies
+target_link_libraries(minimalistic_client libt2n
${Boost_SERIALIZATION_LIBRARIES} libminimalistic_client)
+target_link_libraries(minimalistic_server libt2n
${Boost_SERIALIZATION_LIBRARIES})
+
+# Generation of minimalistic-server.xml
+get_property(gcc_include_dirs
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ PROPERTY INCLUDE_DIRECTORIES
+)
+foreach(gcc_include_dir ${gcc_include_dirs})
+ set(gccxml_include_dirs "${gccxml_include_dirs} -I${gcc_include_dir}")
+endforeach()
+add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/minimalistic-server.xml
+ COMMAND ${CMAKE_SOURCE_DIR}/libt2n-gccxml.sh ${gccxml_include_dirs}
${CMAKE_CURRENT_SOURCE_DIR}/minimalistic-server.cpp
-fxml=${CMAKE_CURRENT_SOURCE_DIR}/minimalistic-server.xml
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/minimalistic-server.cpp
+)
hooks/post-receive
--
C++ inter-process communication library
--
libt2n-git - see http://www.intra2net.com/en/developer/libt2n for details.
To unsubscribe send a mail to libt2n-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|