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