cmake_minimum_required (VERSION 3.0) project (GazeTkProtocol) # Versioning set (GazeTkProtocol_VERSION_MAJOR 0) set (GazeTkProtocol_VERSION_MINOR 1) # configure the header of the library configure_file ( "${PROJECT_SOURCE_DIR}/src_cpp/Protocol.h.in" "${PROJECT_BINARY_DIR}/Protocol.h" ) # add the binary tree to the search path for include files # so that the generated files are found include_directories("${PROJECT_BINARY_DIR}") #SET(CMAKE_INSTALL_PREFIX "../../" CACHE PATH "Install path prefix" FORCE INTERNAL ) # add the Google protobuf parts find_package(Protobuf REQUIRED) include_directories(${PROTOBUF_INCLUDE_DIRS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set (PROTOBUF_IMPORT_DIRS specification) PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS specification/basic_types.proto specification/eye_data.proto specification/gaze2d_data.proto specification/gaze3d_data.proto specification/messages.proto) #this dummy list will make all header files appear if you use qtcreator to open the cmake project #file(GLOB HEADER_LIST RELATIVE ${CMAKE_CURRENT_BINARY_DIR}/ *.h ) # add the library add_library(GazeTkProtocol STATIC src_cpp/protocol.cc ${PROTO_SRCS} ${PROTO_HDRS}) target_link_libraries(GazeTkProtocol ${PROTOBUF_LIBRARIES}) install(TARGETS GazeTkProtocol RUNTIME DESTINATION debug/bin COMPONENT libraries LIBRARY DESTINATION debug/lib COMPONENT libraries PUBLIC_HEADER DESTINATION debug/include COMPONENT libraries ARCHIVE DESTINATION debug/lib COMPONENT libraries CONFIGURATIONS Debug) install(TARGETS GazeTkProtocol RUNTIME DESTINATION release/bin COMPONENT libraries LIBRARY DESTINATION release/lib COMPONENT libraries PUBLIC_HEADER DESTINATION release/include COMPONENT libraries ARCHIVE DESTINATION release/lib COMPONENT libraries CONFIGURATIONS Release) install(DIRECTORY src_cpp/ DESTINATION release/include/GazeTkProtocol CONFIGURATIONS Release FILES_MATCHING PATTERN "*.h" ) install(DIRECTORY src_cpp/ DESTINATION debug/include/GazeTkProtocol CONFIGURATIONS Debug FILES_MATCHING PATTERN "*.h" ) # # Installing the header files. # Looks a little bit complicated, the headers are generated, so we have to search # for them. However, if we do so, the install command creates empty subdirs according # to initial structure. By excluding them, this is prohibited. Nicer solutions welcome! # install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION release/include/GazeTkProtocol CONFIGURATIONS Release FILES_MATCHING PATTERN "*.h" PATTERN "Win32" EXCLUDE PATTERN "GazeTkProtocol.dir" EXCLUDE PATTERN "Debug" EXCLUDE PATTERN "Release" EXCLUDE PATTERN "CMakeFiles" EXCLUDE ) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION debug/include/GazeTkProtocol CONFIGURATIONS Debug FILES_MATCHING PATTERN "*.h" PATTERN "Win32" EXCLUDE PATTERN "GazeTkProtocol.dir" EXCLUDE PATTERN "Debug" EXCLUDE PATTERN "Release" EXCLUDE PATTERN "CMakeFiles" EXCLUDE )