Initial support for building installers (RPM and DEB). Some minor code cleanup.

This commit is contained in:
Marko Zivanovic
2015-09-07 22:48:35 +02:00
parent 208f01dfcb
commit 474670d538
4 changed files with 35 additions and 38 deletions
+2 -8
View File
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(syslog-bulk-uploader)
set(SLBU_DESC "Syslog Bulk Uploader")
set(SLBU_VER "1.0.0-alpha.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
add_definitions(-std=c++11)
add_subdirectory(src)
@@ -10,11 +12,3 @@ add_test(NAME SyslogMessageTests COMMAND SyslogMessageTests)
add_test(NAME RFC3164FormattedSyslogMessageTests COMMAND RFC3164FormattedSyslogMessageTests)
add_test(NAME FrequencyLimitTests COMMAND FrequencyLimitTests)
set(VER_NAME "Syslog Bulk Uploader")
set(VER_MAJOR 1)
set(VER_MINOR 0)
set(VER_PATCH 0)
set(VER_PRERELEASE "alpha.1")
set(VER_BUILD "")
configure_file("src/config.h.in" "src/config.h")
+21
View File
@@ -1,6 +1,8 @@
find_package(Boost COMPONENTS date_time filesystem system thread program_options REQUIRED)
find_package(Threads)
configure_file("config.h.in" "config.h")
include_directories(
${PROJECT_BINARY_DIR}
${Boost_INLUDE_DIRS}
@@ -26,3 +28,22 @@ target_link_libraries(syslog-bulk-uploader
${Boost_PROGRAM_OPTIONS_LIBRARY}
slbu-lib
)
install(TARGETS syslog-bulk-uploader DESTINATION bin )
##
## Installers configuration
##
include(InstallRequiredSystemLibraries)
set(CPACK_GENERATOR "RPM;DEB")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${VER_NAME}")
set(CPACK_PACKAGE_VENDOR "Marko Zivanovic <marko@zivanovic.in.rs>")
set(CPACK_PACKAGE_CONTACT "${CPACK_PACKAGE_VENDOR}")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Utility to send messages from file to remote syslog server")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
set(CPACK_PACKAGE_VERSION "${SLBU_VER}")
set(CPACK_SOURCE_STRIP_FILES TRUE)
set(CPACK_STRIP_FILES TRUE)
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
include(CPack)
+2 -6
View File
@@ -1,7 +1,3 @@
#cmakedefine VER_NAME "${VER_NAME}"
#cmakedefine VER_MAJOR "${VER_MAJOR}"
#cmakedefine VER_MINOR "${VER_MINOR}"
#cmakedefine VER_PATCH "${VER_PATCH}"
#cmakedefine VER_PRERELEASE "${VER_PRERELEASE}"
#cmakedefine VER_BUILD "${VER_BUILD}"
#cmakedefine SLBU_DESC "${SLBU_DESC}"
#cmakedefine SLBU_VER "${SLBU_VER}"
+10 -24
View File
@@ -34,6 +34,7 @@ SOFTWARE.
namespace po = boost::program_options;
using namespace std;
po::options_description desc("Supported options");
size_t mps;
string dest;
uint16_t port;
@@ -41,34 +42,19 @@ vector<string> files;
string version() {
stringstream ss;
ss << VER_NAME << " version " << VER_MAJOR << ".";
#ifdef VER_MINOR
ss << VER_MINOR;
#else
ss << "0";
#endif
ss << ".";
#ifdef VER_PATCH
ss << VER_PATCH;
#else
ss << "0";
#endif
#ifdef VER_PRERELEASE
ss << "-" << VER_PRERELEASE;
#endif
#ifdef VER_BUILD
ss << "+" << VER_BUILD;
#endif
ss << SLBU_DESC << " version " << SLBU_VER;
return ss.str();
}
void help() {
desc.print(cout);
}
int main(int argc, char** argv) {
po::options_description desc("Supported options");
desc.add_options()
("help,h", "display help message")
("version,v", "display version information")
("mps,m", po::value<size_t>(&mps)->default_value(1000), "try to maintain this rate of messages-per-second")
("mps,m", po::value<size_t>(&mps)->default_value(1000), "send messages at specified rate per second")
("dest,d", po::value<string>(&dest), "destination host name")
("port,p", po::value<uint16_t>(&port)->default_value(514), "destination port")
("files,f", po::value<vector < string >> (&files), "input file(s)")
@@ -86,7 +72,7 @@ int main(int argc, char** argv) {
po::notify(vars);
if (vars.count("help")) {
desc.print(std::cout);
help();
return 0;
}
@@ -97,13 +83,13 @@ int main(int argc, char** argv) {
if (!vars.count("dest")) {
cout << "ERROR: You must specify destination hostname" << endl;
desc.print(cout);
help();
return -1;
}
if (!vars.count("files")) {
cout << "ERROR: You must specify at least one input file" << endl;
desc.print(cout);
help();
return -1;
}