From d7a7f9d9b05c3e3a9728bb1644a556527a721afd Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 28 Apr 2017 14:24:36 +0300 Subject: CMakeLists.txt updates Strip symbols, link the runtime statically, fix MinGW-w64 builds, etc. --- um/service/include/libservice/windows_error.hpp | 23 +++++++++++++++++++++++ um/service/test/CMakeLists.txt | 5 ++--- um/service/utils/CMakeLists.txt | 8 ++++---- 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'um/service') diff --git a/um/service/include/libservice/windows_error.hpp b/um/service/include/libservice/windows_error.hpp index f7ac90e..13d7f47 100644 --- a/um/service/include/libservice/windows_error.hpp +++ b/um/service/include/libservice/windows_error.hpp @@ -8,6 +8,7 @@ #include "common.hpp" #include "singleton.hpp" +#include #include #include @@ -25,7 +26,29 @@ namespace libservice private: friend class Singleton; }; + + namespace error + { + inline std::string build_what( + const char* function, + const char* file, + int line) + { + std::ostringstream oss; + oss << "Error in function '" << function + << "' at file '" << file + << "', line " << line; + return oss.str(); + } + } } +#if defined(_MSC_VER) #define LIBSERVICE_ERROR_PREFIX \ "Error in function '" LIBSERVICE_FUNCTION_NAME "' at file '" LIBSERVICE_FILE_PATH "', line " LIBSERVICE_LINE_NUMBER_STRING +#elif defined(__GNUC__) +#define LIBSERVICE_ERROR_PREFIX \ + libservice::error::build_what(LIBSERVICE_FUNCTION_NAME, LIBSERVICE_FILE_PATH, LIBSERVICE_LINE_NUMBER) +#else +#define LIBSERVICE_ERROR_PREFIX "Error" +#endif diff --git a/um/service/test/CMakeLists.txt b/um/service/test/CMakeLists.txt index 4780deb..6825337 100644 --- a/um/service/test/CMakeLists.txt +++ b/um/service/test/CMakeLists.txt @@ -1,4 +1,3 @@ add_executable(libservice_test_windows_error windows_error.cpp) -target_link_libraries(libservice_test_windows_error libservice) -set_target_properties(libservice_test_windows_error PROPERTIES - OUTPUT_NAME windows_error) +target_link_libraries(libservice_test_windows_error PRIVATE libservice) +set_target_properties(libservice_test_windows_error PROPERTIES OUTPUT_NAME windows_error) diff --git a/um/service/utils/CMakeLists.txt b/um/service/utils/CMakeLists.txt index 061ab25..fc5cc1b 100644 --- a/um/service/utils/CMakeLists.txt +++ b/um/service/utils/CMakeLists.txt @@ -1,11 +1,11 @@ add_executable(install_service install_service.cpp) -target_link_libraries(install_service libservice) +target_link_libraries(install_service PRIVATE libservice) add_executable(start_service start_service.cpp) -target_link_libraries(start_service libservice) +target_link_libraries(start_service PRIVATE libservice) add_executable(stop_service stop_service.cpp) -target_link_libraries(stop_service libservice) +target_link_libraries(stop_service PRIVATE libservice) add_executable(uninstall_service uninstall_service.cpp) -target_link_libraries(uninstall_service libservice) +target_link_libraries(uninstall_service PRIVATE libservice) -- cgit v1.2.3