Commit | Line | Data |
---|---|---|
471f240f KK |
1 | # Project |
2 | project(libt2n-example2) | |
3 | set(VERSION 0.1) | |
4 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") | |
5 | ||
6 | # CMake | |
7 | set(CMAKE_COLOR_MAKEFILE ON) | |
8 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) | |
9 | ||
10 | # Source package generation | |
11 | set(CPACK_SOURCE_GENERATOR TGZ) | |
12 | set(CPACK_SOURCE_IGNORE_FILES "~$;\\\\.git;build;build-rpm") | |
13 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION}") | |
14 | ||
15 | # Find external packages | |
16 | include(FindPkgConfig) | |
17 | ||
18 | pkg_check_modules(LIBT2N REQUIRED libt2n>=0.2) | |
19 | include_directories(${LIBT2N_INCLUDE_DIRS}) | |
20 | link_directories(${LIBT2N_LIBRARY_DIRS}) | |
21 | ||
22 | include(CPack) | |
23 | ||
24 | # Setup libt2n | |
25 | # for each command group list the files to parse for LIBT2N_EXPORT | |
26 | set(default_GROUP | |
27 | ${CMAKE_CURRENT_SOURCE_DIR}/default.cpp | |
28 | ) | |
29 | # example of a command group using multiple cpp files | |
30 | set(other_GROUP | |
31 | ${CMAKE_CURRENT_SOURCE_DIR}/other-1.cpp | |
32 | ${CMAKE_CURRENT_SOURCE_DIR}/other-2.cpp | |
33 | ) | |
34 | # headers declaring data types used as rpc arguments must be listed manually (???) | |
35 | # (in this example the class Foo) | |
36 | set(CPP_HEADERS | |
37 | ${CMAKE_CURRENT_SOURCE_DIR}/foo.hxx | |
38 | ) | |
39 | # include CMake snippet doing all the magic | |
40 | include(${CMAKE_SOURCE_DIR}/../cmake/Libt2n.cmake) | |
41 | # command groups are listed here (seperated by spaces) | |
42 | setup_libt2n(default other) | |
43 | ||
44 | # Sources | |
45 | # for each group build a client library from generated source file(s) | |
46 | # Note: the library name must match the group name | |
47 | set(libdefault_SOURCES | |
48 | default_client.cpp | |
49 | ) | |
50 | set(libother_SOURCES | |
51 | other_client.cpp | |
52 | ) | |
53 | # build an example server and client | |
54 | set(client_SOURCES | |
55 | client.cpp | |
56 | ) | |
57 | set(libt2n_example2_server_SOURCES | |
58 | other_server.cpp | |
59 | default_server.cpp | |
60 | server.cpp | |
61 | ${other_GROUP} | |
62 | ${default_GROUP} | |
63 | ) | |
64 | ||
65 | # Libraries | |
66 | add_library(libdefault STATIC ${libdefault_SOURCES}) | |
67 | set_target_properties(libdefault PROPERTIES OUTPUT_NAME default) | |
68 | ||
69 | add_library(libother STATIC ${libother_SOURCES}) | |
70 | set_target_properties(libother PROPERTIES OUTPUT_NAME other) | |
71 | ||
72 | # Executables | |
73 | # build server program | |
74 | add_executable(libt2n-example2-server ${libt2n_example2_server_SOURCES}) | |
75 | ||
76 | # Dependencies | |
77 | target_link_libraries(libdefault ${LIBT2N_LIBRARIES}) | |
78 | add_dependencies(libdefault default_codegen_done) | |
79 | ||
80 | target_link_libraries(libother ${LIBT2N_LIBRARIES}) | |
81 | add_dependencies(libother other_codegen_done) | |
82 | ||
83 | target_link_libraries(libt2n-example2-server ${LIBT2N_LIBRARIES} libdefault libother) | |
84 | add_dependencies(libt2n-example2-server default_codegen_done other_codegen_done) | |
85 | ||
86 | # Installation | |
87 | # install(TARGETS default_client ARCHIVE DESTINATION lib) | |
88 | # install(TARGETS other_client ARCHIVE DESTINATION lib) | |
89 | # install(TARGETS libt2n-example2-server DESTINATION bin) | |
90 | # install(FILES ${CPP_HEADERS} DESTINATION include) |