| 1 | # Project |
| 2 | project(libt2n-example1) |
| 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(t2nexample_GROUP ${CMAKE_CURRENT_SOURCE_DIR}/t2nexample.cpp) |
| 27 | # include CMake snippet doing all the magic |
| 28 | include(${CMAKE_SOURCE_DIR}/codegen/Libt2n.cmake) |
| 29 | # command groups are listed here (seperated by spaces) |
| 30 | setup_libt2n(t2nexample) |
| 31 | |
| 32 | # Sources |
| 33 | # for each group build a client library from generated source file(s) |
| 34 | # Note: the library name must match the group name |
| 35 | set(libt2nexample_SOURCES |
| 36 | t2nexample_client.cpp |
| 37 | ) |
| 38 | set(libt2n_example1_server_SOURCES |
| 39 | server.cpp |
| 40 | ${t2nexample_GROUP} |
| 41 | t2nexample_server.cpp |
| 42 | ) |
| 43 | |
| 44 | # Executables |
| 45 | # build server program |
| 46 | add_executable(libt2n-example1-server ${libt2n_example1_server_SOURCES}) |
| 47 | |
| 48 | # Libraries |
| 49 | add_library(libt2nexample STATIC ${libt2nexample_SOURCES}) |
| 50 | set_target_properties(libt2nexample PROPERTIES OUTPUT_NAME t2nexample) |
| 51 | |
| 52 | # Dependencies |
| 53 | target_link_libraries(libt2n-example1-server ${LIBT2N_LIBRARIES}) |
| 54 | target_link_libraries(libt2nexample t2nexample ${LIBT2N_LIBRARIES}) |
| 55 | |
| 56 | add_dependencies(libt2n-example1-server t2n_arnielizer_codegen_done) |
| 57 | add_dependencies(libt2nexample t2n_arnielizer_codegen_done) |
| 58 | |
| 59 | # Installation |
| 60 | # install(TARGETS libt2n-example1-server DESTINATION bin) |
| 61 | # install(TARGETS libt2nexample ARCHIVE DESTINATION lib) |