diff --git a/.github/workflows/main-mend.yml b/.github/workflows/main-mend.yml new file mode 100644 index 0000000000..bf5aa8848d --- /dev/null +++ b/.github/workflows/main-mend.yml @@ -0,0 +1,19 @@ +name: Mend workflow +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: comcast-runner + steps: + # It will checkout the latest code + - uses: actions/checkout@v3 + - name: Run Whitesource/Mend scan + run: | + java -version + curl -LJO https://github.com/whitesource/unified-agent-distribution/releases/latest/download/wss-unified-agent.jar + java -jar wss-unified-agent.jar -apiKey ${{ secrets.MEND_API_KEY }} -product Thunder -project thunder-github-action-test + diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c40a9c3da..18cdc5b7ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ endif() include(platform) include(CmakeHelperFunctions) +include(GNUInstallDirs) set(PLATFORM "PC_UNIX" CACHE STRING "Defines on what platform the application will run") @@ -96,18 +97,18 @@ configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/project.cmake.in" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${NAMESPACE}.cmake" RENAME "${NAMESPACE}Config.cmake" - DESTINATION lib/cmake/${NAMESPACE}) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}) if(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config" - DESTINATION lib/cmake/${NAMESPACE}) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}) endif(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates" - DESTINATION lib/cmake/${NAMESPACE}) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}) if(APPLE) # Mac needed variables @@ -115,7 +116,7 @@ if(APPLE) set(CMAKE_MACOSX_RPATH ON) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif() diff --git a/Source/WPEFramework/CMakeLists.txt b/Source/WPEFramework/CMakeLists.txt index 610930d3f8..a327e1c5ae 100644 --- a/Source/WPEFramework/CMakeLists.txt +++ b/Source/WPEFramework/CMakeLists.txt @@ -100,10 +100,10 @@ set_target_properties(${TARGET} PROPERTIES install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac ) install(DIRECTORY diff --git a/Source/WPEFramework/Config.h b/Source/WPEFramework/Config.h index 906dedb6da..6d6c2964ed 100644 --- a/Source/WPEFramework/Config.h +++ b/Source/WPEFramework/Config.h @@ -766,7 +766,7 @@ namespace PluginHost { _pluginConfigPath = Core::Directory::Normalize(config.Observe.PluginConfigPath.Value()); } _postMortemPath = Core::Directory::Normalize(config.PostMortemPath.Value()); - _appPath = Core::File::PathName(Core::ProcessInfo().Executable()); + _appPath = Core::Directory::Normalize(Core::File::PathName(Core::ProcessInfo().Executable())); _hashKey = config.Signature.Value(); _communicator = Core::NodeId(config.Communicator.Value().c_str()); _redirect = config.Redirect.Value(); diff --git a/Source/WPEFramework/GenericConfig.cmake b/Source/WPEFramework/GenericConfig.cmake index b657282f48..9e8b6892bf 100644 --- a/Source/WPEFramework/GenericConfig.cmake +++ b/Source/WPEFramework/GenericConfig.cmake @@ -25,10 +25,10 @@ set(SOFT_KILL_CHECK_WAIT_TIME 10 CACHE STRING "Soft kill check waiting time") set(HARD_KILL_CHECK_WAIT_TIME 4 CACHE STRING "Hard kill check waiting time") set(PERSISTENT_PATH "/root" CACHE STRING "Persistent path") set(DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/${NAMESPACE}" CACHE STRING "Data path") -set(SYSTEM_PATH "${CMAKE_INSTALL_PREFIX}/lib/${NAMESPACE_LIB}/plugins" CACHE STRING "System path") +set(SYSTEM_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/plugins" CACHE STRING "System path") set(WEBSERVER_PATH "/boot/www" CACHE STRING "Root path for the HTTP server") set(WEBSERVER_PORT 8080 CACHE STRING "Port for the HTTP server") -set(PROXYSTUB_PATH "${CMAKE_INSTALL_PREFIX}/lib/${NAMESPACE_LIB}/proxystubs" CACHE STRING "Proxy stub path") +set(PROXYSTUB_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/proxystubs" CACHE STRING "Proxy stub path") set(POSTMORTEM_PATH "/opt/minidumps" CACHE STRING "Core file path to do the postmortem of the crash") set(MESSAGECONTROL_PATH "MessageDispatcher" CACHE STRING "MessageControl base path to create message files") set(MESSAGING_PORT 0 CACHE STRING "The port for the messaging") @@ -284,7 +284,7 @@ json_write("${CMAKE_BINARY_DIR}/Config.json" ${CONFIG}) install( FILES ${CMAKE_BINARY_DIR}/Config.json - DESTINATION ${CMAKE_INSTALL_PREFIX}/../etc/${NAMESPACE}/ + DESTINATION ../${CMAKE_INSTALL_SYSCONFDIR}/${NAMESPACE}/ RENAME config.json COMPONENT ${MODULE_NAME}) else() @@ -295,7 +295,7 @@ else() SKIP_CLASSNAME SKIP_LOCATOR CUSTOM_PARAMS_WHITELIST "${CMAKE_CURRENT_LIST_DIR}/params.config" - INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/../etc/${NAMESPACE}/" + INSTALL_PATH "../${CMAKE_INSTALL_SYSCONFDIR}/${NAMESPACE}/" INSTALL_NAME "config.json" PLUGINS "WPEFramework" ) diff --git a/Source/WPEFramework/scripts/CMakeLists.txt b/Source/WPEFramework/scripts/CMakeLists.txt index e3639aa4ec..01bf29c133 100644 --- a/Source/WPEFramework/scripts/CMakeLists.txt +++ b/Source/WPEFramework/scripts/CMakeLists.txt @@ -26,7 +26,7 @@ if (SYSTEMD_SERVICE) ) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/wpeframework.service "${MOD_WPEFRAMEWORK_SYSTEMD_SERVICE}") - install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/../lib) + install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/../${CMAKE_INSTALL_LIBDIR}) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/wpeframework.service PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ @@ -43,7 +43,7 @@ else() install( FILES ${CMAKE_CURRENT_BINARY_DIR}/wpeframework PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ - DESTINATION ${CMAKE_INSTALL_PREFIX}/../etc/init.d/ + DESTINATION ../${CMAKE_INSTALL_SYSCONFDIR}/init.d/ ) endif() diff --git a/Source/WPEProcess/CMakeLists.txt b/Source/WPEProcess/CMakeLists.txt index 166c8ba0e3..77b08c4c1a 100644 --- a/Source/WPEProcess/CMakeLists.txt +++ b/Source/WPEProcess/CMakeLists.txt @@ -69,8 +69,8 @@ set_target_properties(${TARGET} PROPERTIES install( TARGETS COMProcess ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac ) diff --git a/Source/com/CMakeLists.txt b/Source/com/CMakeLists.txt index c69ea64a66..337670dc95 100644 --- a/Source/com/CMakeLists.txt +++ b/Source/com/CMakeLists.txt @@ -1,19 +1,19 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: +#If not stated otherwise in this file or this component's license file the +#following copyright and licenses apply: # -# Copyright 2020 Metrological +#Copyright 2020 Metrological # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +#Licensed under the Apache License, Version 2.0(the "License"); +#you may not use this file except in compliance with the License. +#You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +#http: // www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +#Unless required by applicable law or agreed to in writing, software +#distributed under the License is distributed on an "AS IS" BASIS, +#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +#See the License for the specific language governing permissions and +#limitations under the License. set(TARGET ${NAMESPACE}COM) @@ -93,12 +93,12 @@ set_target_properties(${TARGET} PROPERTIES install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/com COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/com COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) InstallCMakeConfig(TARGETS ${TARGET}) diff --git a/Source/core/CMakeLists.txt b/Source/core/CMakeLists.txt index 2268b53132..b00656d8ae 100644 --- a/Source/core/CMakeLists.txt +++ b/Source/core/CMakeLists.txt @@ -271,12 +271,12 @@ endif() # =========================================================================================== install( TARGETS CompileSettings ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/core COMPONENT devel # for mac - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/core COMPONENT devel # for mac + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) # =========================================================================================== diff --git a/Source/core/CyclicBuffer.cpp b/Source/core/CyclicBuffer.cpp index f5072aa81b..b597beb306 100644 --- a/Source/core/CyclicBuffer.cpp +++ b/Source/core/CyclicBuffer.cpp @@ -394,25 +394,25 @@ namespace Core { foundData = false; } } else { - uint32_t part1 = 0; - uint32_t part2 = 0; + uint32_t newOffset = 0; if (_administration->_size < offset) { - part2 = result - (offset - _administration->_size); + const uint32_t skip = offset - _administration->_size; + newOffset = skip + bufferLength; + ::memcpy(buffer, _realBuffer + skip, bufferLength); } else { - part1 = _administration->_size - offset; - part2 = result - part1; - } - - memcpy(buffer, _realBuffer + offset, std::min(part1, bufferLength)); + const uint32_t part1 = _administration->_size - offset; + newOffset = result - part1; + ::memcpy(buffer, _realBuffer + offset, std::min(part1, bufferLength)); - if (part1 < bufferLength) { - memcpy(buffer + part1, _realBuffer, bufferLength - part1); + if (part1 < bufferLength) { + ::memcpy(buffer + part1, _realBuffer, bufferLength - part1); + } } // Add one round, but prevent overflow. roundCount = (roundCount + 1) % _administration->_roundCountModulo; - uint32_t newTail = part2 + roundCount * (1 + _administration->_tailIndexMask); + uint32_t newTail = newOffset + roundCount * (1 + _administration->_tailIndexMask); if (!_administration->_tail.compare_exchange_weak(oldTail, newTail)) { foundData = false; } diff --git a/Source/core/Frame.h b/Source/core/Frame.h index 8dddae5031..c1e97c66e5 100644 --- a/Source/core/Frame.h +++ b/Source/core/Frame.h @@ -114,7 +114,7 @@ namespace Core { AllocatorType& operator=(const AllocatorType& copy) = delete; AllocatorType() - : _bufferSize(STARTSIZE) + : _bufferSize(static_cast(STARTSIZE)) , _data(static_cast(::malloc(_bufferSize))) { // It looks like there is a bug in the windows compiler. It prepares a default/copy constructor @@ -178,7 +178,7 @@ namespace Core { if (_data != nullptr) { ::free(_data); } - _data == move._data; + _data = move._data; move._data = nullptr; _bufferSize = move._bufferSize; } diff --git a/Source/core/IPFrame.h b/Source/core/IPFrame.h index 91057fca4c..bc780589ef 100644 --- a/Source/core/IPFrame.h +++ b/Source/core/IPFrame.h @@ -126,7 +126,11 @@ namespace Core { public: bool IsValid() const { const ip* ipHeader = reinterpret_cast(Base::Frame()); + #ifdef __WINDOWS__ + return ((ipHeader->protocol == PROTOCOL) && (Checksum() == ipHeader->check)); + #else return ((ipHeader->ip_p == PROTOCOL) && (Checksum() == ipHeader->ip_sum)); + #endif } uint16_t Load(const uint8_t buffer[], const uint16_t size) { uint16_t copySize = std::min(size, static_cast(SIZE + HeaderSize)); @@ -139,47 +143,65 @@ namespace Core { inline NodeId Source() const { NodeId result; const ip* ipHeader = reinterpret_cast(Base::Frame()); - ASSERT (ipHeader->ip_v == IPV4_VERSION); + + ASSERT(ipHeader->ip_v == IPV4_VERSION); sockaddr_in node; ::memset (&node, 0, sizeof(node)); node.sin_family = AF_INET; node.sin_port = 0; +#ifdef __WINDOWS__ + node.sin_addr.S_un.S_addr = ipHeader->ip_src; +#else node.sin_addr = ipHeader->ip_src; +#endif result = node; return (result); } inline void Source(const NodeId& node) { ip* ipHeader = reinterpret_cast(Base::Frame()); - ASSERT (ipHeader->ip_v == IPV4_VERSION); + ASSERT(ipHeader->ip_v == IPV4_VERSION); ASSERT (node.Type() == NodeId::TYPE_IPV4); const sockaddr_in& result = static_cast(node).IPV4Socket; - ipHeader->ip_src = result.sin_addr; +#ifdef __WINDOWS__ + ipHeader->ip_src = result.sin_addr.S_un.S_addr; +#else + ipHeader->ip_src = result.sin_addr; +#endif ipHeader->ip_sum = Checksum(); } inline NodeId Destination() const { NodeId result; const ip* ipHeader = reinterpret_cast(Base::Frame()); - ASSERT (ipHeader->ip_v == IPV4_VERSION); + ASSERT(ipHeader->ip_v == IPV4_VERSION); sockaddr_in node; ::memset (&node, 0, sizeof(node)); node.sin_family = AF_INET; node.sin_port = 0; - node.sin_addr = ipHeader->ip_dst; +#ifdef __WINDOWS__ + node.sin_addr.S_un.S_addr = ipHeader->ip_dst; +#else + node.sin_addr = ipHeader->ip_dst; +#endif result = node; return (result); } inline void Destination(const NodeId& node) { ip* ipHeader = reinterpret_cast(Base::Frame()); - ASSERT (ipHeader->ip_v == IPV4_VERSION); + + ASSERT(ipHeader->ip_v == IPV4_VERSION); ASSERT (node.Type() == NodeId::TYPE_IPV4); const sockaddr_in& result = static_cast(node).IPV4Socket; - ipHeader->ip_dst = result.sin_addr; +#ifdef __WINDOWS__ + ipHeader->ip_dst = result.sin_addr.S_un.S_addr; +#else + ipHeader->ip_dst = result.sin_addr; +#endif ipHeader->ip_sum = Checksum(); } inline uint8_t TTL() const { @@ -187,7 +209,7 @@ namespace Core { } inline void TTL(const uint8_t ttl) { ip* ipHeader = reinterpret_cast(Base::Frame()); - ipHeader->ip_ttl = ttl; + ipHeader->ip_ttl = ttl; ipHeader->ip_sum = Checksum(); } inline uint16_t Length() const { @@ -244,15 +266,14 @@ namespace Core { private: uint16_t Checksum() const { - - ip* ipHeader = const_cast(reinterpret_cast(Base::Frame())); + ip* ipHeader = const_cast(reinterpret_cast(Base::Frame())); uint16_t original = ipHeader->ip_sum; ipHeader->ip_sum = 0; uint32_t result = Checksum(0, reinterpret_cast(ipHeader), HeaderSize); ipHeader->ip_sum = original; + return (Shrink(result)); } - }; static constexpr uint16_t TCPv4FrameSize = sizeof(tcphdr); @@ -449,6 +470,7 @@ namespace Core { udphdr* udpHeader = const_cast(reinterpret_cast(Base::Frame())); uint16_t original = udpHeader->uh_sum; udpHeader->uh_sum = 0; + uint32_t result = Base::Checksum(0, reinterpret_cast(pseudoHeader), sizeof(pseudoHeader)); result = Base::Checksum (result, reinterpret_cast(udpHeader), Base::Length()); udpHeader->uh_sum = original; diff --git a/Source/core/JSONRPC.h b/Source/core/JSONRPC.h index c46f907133..c4b01cb82d 100644 --- a/Source/core/JSONRPC.h +++ b/Source/core/JSONRPC.h @@ -1055,7 +1055,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method) { Register(methodName, [method](const Core::JSONRPC::Context&, const string&, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, method, int())); + return (InternalRegisterImplIO(parameters, result, method)); }); } @@ -1085,7 +1085,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<1>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method) { Register(methodName, [method](const Context& context, const string&, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, method, int(), context)); + return (InternalRegisterImplIO(parameters, result, method, context)); }); } @@ -1108,7 +1108,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<2>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method) { Register(methodName, [method](const Context&, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, method, int(), Message::Index(methodName))); + return (InternalRegisterImplIO(parameters, result, method, Message::Index(methodName))); }); } @@ -1131,7 +1131,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<3>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method) { Register(methodName, [method](const Context& context, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, method, int(), context, Message::Index(methodName))); + return (InternalRegisterImplIO(parameters, result, method, context, Message::Index(methodName))); }); } @@ -1161,7 +1161,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<4>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method) { Register(methodName, [method](const Context&, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, method, int(), Message::InstanceId(methodName))); + return (InternalRegisterImplIO(parameters, result, method, Message::InstanceId(methodName))); }); } @@ -1184,7 +1184,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<6>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method) { Register(methodName, [method](const Context&, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, method, int(), Message::InstanceId(methodName), Message::Index(methodName))); + return (InternalRegisterImplIO(parameters, result, method, Message::InstanceId(methodName), Message::Index(methodName))); }); } @@ -1214,7 +1214,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) { Register(methodName, [method, objectPtr](const Core::JSONRPC::Context&, const string&, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2), int())); + return (InternalRegisterImplIO(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2))); }); } @@ -1244,7 +1244,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<1>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) { Register(methodName, [method, objectPtr](const Context& context, const string&, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), int(), context)); + return (InternalRegisterImplIO(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context)); }); } @@ -1267,7 +1267,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<2>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) { Register(methodName, [method, objectPtr](const Context&, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), int(), Message::Index(methodName))); + return (InternalRegisterImplIO(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), Message::Index(methodName))); }); } @@ -1290,7 +1290,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<3>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) { Register(methodName, [method, objectPtr](const Context& context, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), int(), context, Message::Index(methodName))); + return (InternalRegisterImplIO(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context, Message::Index(methodName))); }); } @@ -1320,7 +1320,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<4>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) { Register(methodName, [method, objectPtr](const Context&, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), int(), Message::InstanceId(methodName))); + return (InternalRegisterImplIO(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), Message::InstanceId(methodName))); }); } @@ -1343,7 +1343,7 @@ namespace Core { void InternalRegister(const ::TemplateIntToType<6>&, const ::TemplateIntToType<0>&, const ::TemplateIntToType<0>&, const string& methodName, const METHOD& method, REALOBJECT* objectPtr) { Register(methodName, [method, objectPtr](const Context&, const string& methodName, const string& parameters, string& result) -> uint32_t { - return (InternalRegisterImpl(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), int(), Message::InstanceId(methodName), Message::Index(methodName))); + return (InternalRegisterImplIO(parameters, result, std::bind(method, objectPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), Message::InstanceId(methodName), Message::Index(methodName))); }); } @@ -1373,7 +1373,7 @@ namespace Core { return(code); } template - static uint32_t InternalRegisterImpl(const string& parameters, string& result, const METHOD& method, int, Args&&... args) + static uint32_t InternalRegisterImplIO(const string& parameters, string& result, const METHOD& method, Args&&... args) { uint32_t code; INBOUND inbound; diff --git a/Source/core/ProcessInfo.h b/Source/core/ProcessInfo.h index a56f8280f4..9a902b5488 100644 --- a/Source/core/ProcessInfo.h +++ b/Source/core/ProcessInfo.h @@ -163,7 +163,7 @@ namespace Core { _index = 0; _current = _pids.begin(); } else { - _index = _pids.size() + 1; + _index = static_cast(_pids.size()) + 1; _current = _pids.end(); } } diff --git a/Source/core/Sync.cpp b/Source/core/Sync.cpp index f285e4aeb2..d854f6c9d4 100644 --- a/Source/core/Sync.cpp +++ b/Source/core/Sync.cpp @@ -925,11 +925,11 @@ namespace Core { if (nResult == ETIMEDOUT) { // Something went wrong, so assume... - TRACE_L1("Timed out waiting for event <%d>.", nTime); + TRACE_L5("Timed out waiting for event <%d>.", nTime); nResult = Core::ERROR_TIMEDOUT; } else if (nResult != 0) { // Something went wrong, so assume... - TRACE_L1("Waiting on semaphore failed. Error code <%d>", nResult); + TRACE_L5("Waiting on semaphore failed. Error code <%d>", nResult); nResult = Core::ERROR_GENERAL; } diff --git a/Source/cryptalgo/CMakeLists.txt b/Source/cryptalgo/CMakeLists.txt index 3b5470de9c..424a9e1c30 100644 --- a/Source/cryptalgo/CMakeLists.txt +++ b/Source/cryptalgo/CMakeLists.txt @@ -81,12 +81,12 @@ target_include_directories( ${TARGET} install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/cryptalgo COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/cryptalgo COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) InstallCMakeConfig(TARGETS ${TARGET}) diff --git a/Source/extensions/hibernate/CMakeLists.txt b/Source/extensions/hibernate/CMakeLists.txt index 284a235b88..42698598e2 100644 --- a/Source/extensions/hibernate/CMakeLists.txt +++ b/Source/extensions/hibernate/CMakeLists.txt @@ -52,12 +52,12 @@ endif() install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/hibernate COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE}/hibernate # headers + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/hibernate COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/hibernate # headers ) InstallCMakeConfig( diff --git a/Source/extensions/localtracer/CMakeLists.txt b/Source/extensions/localtracer/CMakeLists.txt index e3f039d31f..7dbdafb0ee 100644 --- a/Source/extensions/localtracer/CMakeLists.txt +++ b/Source/extensions/localtracer/CMakeLists.txt @@ -22,7 +22,7 @@ target_compile_features(${MODULE_NAME} INTERFACE cxx_std_11) install(TARGETS ${MODULE_NAME} EXPORT ${MODULE_NAME}Targets) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/localtracer/localtracer.h - DESTINATION include/${NAMESPACE}/localtracer) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/localtracer) include(HeaderOnlyInstall) diff --git a/Source/extensions/localtracer/example/CMakeLists.txt b/Source/extensions/localtracer/example/CMakeLists.txt index 8745800490..09262ddada 100644 --- a/Source/extensions/localtracer/example/CMakeLists.txt +++ b/Source/extensions/localtracer/example/CMakeLists.txt @@ -8,5 +8,5 @@ target_link_libraries(local_trace_test PRIVATE ${NAMESPACE}LocalTracer::${NAMESPACE}LocalTracer) if(EXAMPLE_LOCALTRACER) - install(TARGETS local_trace_test DESTINATION bin) + install(TARGETS local_trace_test DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/Source/extensions/privilegedrequest/CMakeLists.txt b/Source/extensions/privilegedrequest/CMakeLists.txt index 752862a0a5..a6969a5524 100644 --- a/Source/extensions/privilegedrequest/CMakeLists.txt +++ b/Source/extensions/privilegedrequest/CMakeLists.txt @@ -38,7 +38,7 @@ install(TARGETS ${MODULE_NAME} EXPORT ${MODULE_NAME}Targets) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/privilegedrequest/PrivilegedRequest.h - DESTINATION include/${NAMESPACE}/privilegedrequest) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/privilegedrequest) include(HeaderOnlyInstall) diff --git a/Source/extensions/privilegedrequest/example/CMakeLists.txt b/Source/extensions/privilegedrequest/example/CMakeLists.txt index 4a83a2ae7e..d4f7f8aaca 100644 --- a/Source/extensions/privilegedrequest/example/CMakeLists.txt +++ b/Source/extensions/privilegedrequest/example/CMakeLists.txt @@ -24,5 +24,5 @@ target_link_libraries(fdpassing PRIVATE ) if(EXAMPLE_PRIVILEGEDREQUEST) -install(TARGETS fdpassing DESTINATION bin) +install(TARGETS fdpassing DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/Source/extensions/processcontainers/CMakeLists.txt b/Source/extensions/processcontainers/CMakeLists.txt index 8ed03ecd52..15b33f348c 100644 --- a/Source/extensions/processcontainers/CMakeLists.txt +++ b/Source/extensions/processcontainers/CMakeLists.txt @@ -150,12 +150,12 @@ endif() install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/processcontainers COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE}/processcontainers # headers + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/processcontainers COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/processcontainers # headers ) InstallCMakeConfig( diff --git a/Source/extensions/warningreporting/CMakeLists.txt b/Source/extensions/warningreporting/CMakeLists.txt index f150297ec4..65d18bdf0b 100644 --- a/Source/extensions/warningreporting/CMakeLists.txt +++ b/Source/extensions/warningreporting/CMakeLists.txt @@ -57,12 +57,12 @@ target_include_directories( ${TARGET} install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/warningreporting COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/warningreporting COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) InstallCMakeConfig(TARGETS ${TARGET}) diff --git a/Source/messaging/CMakeLists.txt b/Source/messaging/CMakeLists.txt index c7bb2fe404..35085c5e98 100644 --- a/Source/messaging/CMakeLists.txt +++ b/Source/messaging/CMakeLists.txt @@ -72,12 +72,12 @@ target_include_directories( ${TARGET} install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/messaging COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/messaging COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) InstallCMakeConfig(TARGETS ${TARGET}) diff --git a/Source/plugins/CMakeLists.txt b/Source/plugins/CMakeLists.txt index 4f751fc198..867b41ba7e 100644 --- a/Source/plugins/CMakeLists.txt +++ b/Source/plugins/CMakeLists.txt @@ -142,26 +142,26 @@ set_target_properties(${TARGET_PROXYSTUBS} PROPERTIES # =========================================================================================== install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/plugins COMPONENT devel # for mac - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/plugins COMPONENT devel # for mac + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) install( - FILES ${JSON_DATA_HEADERS} DESTINATION include/${NAMESPACE}/plugins/json COMPONENT devel # for mac + FILES ${JSON_DATA_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/plugins/json COMPONENT devel # for mac ) install( TARGETS ${TARGET_PROXYSTUBS} EXPORT ${TARGET_PROXYSTUBS}Targets # for downstream dependencies - ARCHIVE DESTINATION lib/${NAMESPACE_LIB}/proxystubs COMPONENT libs # static lib - LIBRARY DESTINATION lib/${NAMESPACE_LIB}/proxystubs COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin/${NAMESPACE_LIB}/proxystubs COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/proxystubs COMPONENT devel # for mac - INCLUDES DESTINATION include/${NAMESPACE}/proxystubs # headers + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/proxystubs COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/proxystubs COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR}/${NAMESPACE_LIB}/proxystubs COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/proxystubs COMPONENT devel # for mac + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/proxystubs # headers ) # =========================================================================================== diff --git a/Source/websocket/CMakeLists.txt b/Source/websocket/CMakeLists.txt index f37f4ebee5..739ef702af 100644 --- a/Source/websocket/CMakeLists.txt +++ b/Source/websocket/CMakeLists.txt @@ -71,12 +71,12 @@ target_include_directories( ${TARGET} install( TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies - ARCHIVE DESTINATION lib COMPONENT libs # static lib - LIBRARY DESTINATION lib COMPONENT libs # shared lib - RUNTIME DESTINATION bin COMPONENT libs # binaries - FRAMEWORK DESTINATION bin COMPONENT libs # for mac - PUBLIC_HEADER DESTINATION include/${NAMESPACE}/websocket COMPONENT devel # headers for mac (note the different component -> different package) - INCLUDES DESTINATION include/${NAMESPACE} # default include path + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries + FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/websocket COMPONENT devel # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path ) install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink websocket ${CMAKE_SYSROOT}${CMAKE_INSTALL_PREFIX}/include/${NAMESPACE}/jsonrpc)") diff --git a/Tests/comrpctester/CMakeLists.txt b/Tests/comrpctester/CMakeLists.txt index 23e2398619..e6b7b9b39a 100644 --- a/Tests/comrpctester/CMakeLists.txt +++ b/Tests/comrpctester/CMakeLists.txt @@ -28,5 +28,5 @@ set_target_properties(comrpctester PROPERTIES CXX_STANDARD_REQUIRED YES ) -install(TARGETS comrpctester DESTINATION bin) +install(TARGETS comrpctester DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Tests/file-unlink/CMakeLists.txt b/Tests/file-unlink/CMakeLists.txt index 7f9239523f..c3b53a4253 100644 --- a/Tests/file-unlink/CMakeLists.txt +++ b/Tests/file-unlink/CMakeLists.txt @@ -29,6 +29,6 @@ set_target_properties(FileClient PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES ) -install(TARGETS FileClient DESTINATION bin) -install(TARGETS FileMaster DESTINATION bin) +install(TARGETS FileClient DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS FileMaster DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Tests/httpsclient/CMakeLists.txt b/Tests/httpsclient/CMakeLists.txt index ea02291f2b..d3f02a8920 100644 --- a/Tests/httpsclient/CMakeLists.txt +++ b/Tests/httpsclient/CMakeLists.txt @@ -16,4 +16,4 @@ target_link_libraries(httpsclient_test ${NAMESPACE}WebSocket ) -install(TARGETS httpsclient_test DESTINATION bin) +install(TARGETS httpsclient_test DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Tests/loader/CMakeLists.txt b/Tests/loader/CMakeLists.txt index a9848c52ec..1d9c450e91 100644 --- a/Tests/loader/CMakeLists.txt +++ b/Tests/loader/CMakeLists.txt @@ -31,5 +31,5 @@ set_target_properties(WPELibraryTestLoader PROPERTIES CXX_STANDARD_REQUIRED YES ) -install(TARGETS WPELibraryTestLoader DESTINATION bin) +install(TARGETS WPELibraryTestLoader DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Tests/message-buffer/CMakeLists.txt b/Tests/message-buffer/CMakeLists.txt index 0088bce2de..df4e3ab7e8 100644 --- a/Tests/message-buffer/CMakeLists.txt +++ b/Tests/message-buffer/CMakeLists.txt @@ -31,4 +31,4 @@ set_target_properties(MessageBufferTest PROPERTIES CXX_STANDARD_REQUIRED YES ) -install(TARGETS MessageBufferTest DESTINATION bin) +install(TARGETS MessageBufferTest DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Tests/redirect/CMakeLists.txt b/Tests/redirect/CMakeLists.txt index 539bd02bf3..9e3597d38e 100644 --- a/Tests/redirect/CMakeLists.txt +++ b/Tests/redirect/CMakeLists.txt @@ -29,5 +29,5 @@ set_target_properties(redirect PROPERTIES SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") -install(TARGETS redirect DESTINATION bin) +install(TARGETS redirect DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Tests/unit/core/CMakeLists.txt b/Tests/unit/core/CMakeLists.txt index d932a1673d..204254aa5e 100644 --- a/Tests/unit/core/CMakeLists.txt +++ b/Tests/unit/core/CMakeLists.txt @@ -123,7 +123,7 @@ add_library(helloworld SHARED test_library_helloworld.cpp) install( TARGETS helloworld - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/testdata) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/testdata) add_test(NAME ${TEST_RUNNER_NAME} COMMAND ${TEST_RUNNER_NAME}) diff --git a/Tests/workerpool-test/CMakeLists.txt b/Tests/workerpool-test/CMakeLists.txt index 3b60232a54..0e4346d8be 100644 --- a/Tests/workerpool-test/CMakeLists.txt +++ b/Tests/workerpool-test/CMakeLists.txt @@ -10,4 +10,4 @@ target_link_libraries(WorkerPoolTest ${NAMESPACE}Core ) -install(TARGETS WorkerPoolTest DESTINATION bin) +install(TARGETS WorkerPoolTest DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/cmake/common/CmakeHelperFunctions.cmake b/cmake/common/CmakeHelperFunctions.cmake index 318758e12c..d065de3610 100644 --- a/cmake/common/CmakeHelperFunctions.cmake +++ b/cmake/common/CmakeHelperFunctions.cmake @@ -15,7 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -include (CMakePackageConfigHelpers) +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) macro(add_element list element) list(APPEND ${list} ${element}) @@ -29,7 +30,7 @@ function(_get_default_link_name lib name location) get_filename_component(_location "${_rel_location}" DIRECTORY) if(NOT "${_location}" STREQUAL "") - string(REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}/lib" "" _location ${_location}) + string(REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" "" _location ${_location}) get_filename_component(_location "${_rel_location}" DIRECTORY) endif() @@ -307,7 +308,7 @@ function(InstallCMakeConfig) message(FATAL_ERROR "Unknown keywords given to InstallCMakeConfig(): \"${Argument_UNPARSED_ARGUMENTS}\"") endif() - set(_install_path "lib/cmake") # default path + set(_install_path "${CMAKE_INSTALL_LIBDIR}/cmake") # default path if(Agument_LOCATION) set(_install_path "${Agument_LOCATION}" FORCE) @@ -316,7 +317,7 @@ function(InstallCMakeConfig) if("${Argument_TEMPLATE}" STREQUAL "") find_file( _config_template NAMES "defaultConfig.cmake.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates" + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH @@ -326,7 +327,7 @@ function(InstallCMakeConfig) find_file(_config_template NAMES "defaultConfig.cmake.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates" ) + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" ) if(NOT EXISTS "${_config_template}") message(SEND_ERROR "Config file generation failed, template '${_config_template}' not found") @@ -479,7 +480,7 @@ function(InstallPackageConfig) if("${Argument_TEMPLATE}" STREQUAL "") find_file( _pc_template NAMES "default.pc.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates" + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH @@ -489,7 +490,7 @@ function(InstallPackageConfig) find_file(_pc_template NAMES "default.pc.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates") + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates") if(NOT EXISTS "${_pc_template}") message(SEND_ERROR "PC file generation failed, template '${_pc_template}' not found") @@ -542,7 +543,7 @@ function(InstallPackageConfig) endif() # Default path on UNIX, if you want Windows or Apple support add the path here. ;-) - set(_install_path "lib/pkgconfig") + set(_install_path "${CMAKE_INSTALL_LIBDIR}/pkgconfig") if (${Argument_OUTPUT_NAME}) set(_pc_filename ${Argument_OUTPUT_NAME}) @@ -587,7 +588,7 @@ function(InstallPackageConfig) get_if_link_libraries(libraries link_dirs ${_target}) if(NOT Argument_NO_DEFAULT_LIB_DIR_FILTER) - # remove the default library dir e.g /usr/lib + # remove the default library dir e.g /usr/${CMAKE_INSTALL_LIBDIR} list(LENGTH link_dirs _link_dirs_count) if (_link_dirs_count GREATER 0) list(REMOVE_ITEM link_dirs "${CMAKE_INSTALL_PREFIX}/${TARGET_LIBRARY_DIR}") @@ -625,7 +626,7 @@ function(InstallFindModule) cmake_parse_arguments(Argument "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - set(DESTINATION lib/cmake/${NAMESPACE}/modules) + set(DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules) if(Argument_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown keywords given to InstallCMakeConfig(): \"${Argument_UNPARSED_ARGUMENTS}\"") @@ -637,11 +638,11 @@ function(InstallFindModule) else() file(GLOB_RECURSE extra_files "${DIRECTORY}/*.cmake") endif(Argument_RECURSE) - install(FILES "${extra_files}" DESTINATION lib/cmake/${NAMESPACE}/modules) + install(FILES "${extra_files}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules) endif() if (Argument_FILES) - install(FILES "${Argument_FILES}" DESTINATION lib/cmake/${NAMESPACE}/modules) + install(FILES "${Argument_FILES}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules) endif() endfunction(InstallFindModule) diff --git a/cmake/common/HeaderOnlyInstall.cmake b/cmake/common/HeaderOnlyInstall.cmake index e7d68c0631..93ca517b6d 100644 --- a/cmake/common/HeaderOnlyInstall.cmake +++ b/cmake/common/HeaderOnlyInstall.cmake @@ -21,7 +21,7 @@ function(HeaderOnlyInstallCMakeConfig) if("${Argument_TEMPLATE}" STREQUAL "") find_file( _config_template NAMES "defaultConfig.cmake.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates" + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH @@ -31,7 +31,7 @@ function(HeaderOnlyInstallCMakeConfig) find_file(_config_template NAMES "defaultConfig.cmake.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates" ) + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" ) if(NOT EXISTS "${_config_template}") message(SEND_ERROR "Config file generation failed, template '${_config_template}' not found") @@ -174,7 +174,7 @@ function(HeaderOnlyInstallPackageConfig) if("${Argument_TEMPLATE}" STREQUAL "") find_file( _pc_template NAMES "default.pc.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates" + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH @@ -184,7 +184,7 @@ function(HeaderOnlyInstallPackageConfig) find_file(_pc_template NAMES "default.pc.in" - PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/lib/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/lib/cmake/${NAMESPACE}/templates") + PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates") if(NOT EXISTS "${_pc_template}") message(SEND_ERROR "PC file generation failed, template '${_pc_template}' not found") @@ -274,7 +274,7 @@ function(HeaderOnlyInstallPackageConfig) get_if_link_libraries(libraries link_dirs ${TARGET}) if(NOT Argument_NO_DEFAULT_LIB_DIR_FILTER) - # remove the default library dir e.g /usr/lib + # remove the default library dir e.g /usr/${CMAKE_INSTALL_LIBDIR} list(LENGTH link_dirs _link_dirs_count) if (_link_dirs_count GREATER 0) list(REMOVE_ITEM link_dirs "${CMAKE_INSTALL_PREFIX}/${TARGET_LIBRARY_DIR}") diff --git a/cmake/project.cmake.in b/cmake/project.cmake.in index ecf33ac0c4..602111bc98 100644 --- a/cmake/project.cmake.in +++ b/cmake/project.cmake.in @@ -20,6 +20,8 @@ ## https://github.com/toeb/cmakepp ## +include(GNUInstallDirs) + macro(project_version) string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _VERSION_MAJOR "${ARGV0}") string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _VERSION_MINOR "${ARGV0}") diff --git a/docs/plugin/interfaces/interfaces.md b/docs/plugin/interfaces/interfaces.md index b5c4341830..5a293a7c01 100644 --- a/docs/plugin/interfaces/interfaces.md +++ b/docs/plugin/interfaces/interfaces.md @@ -185,22 +185,22 @@ endif() string(TOLOWER ${NAMESPACE} NAMESPACE_LIB) install(TARGETS ExampleProxyStubs EXPORT ExampleProxyStubsTargets # for downstream dependencies - LIBRARY DESTINATION lib/${NAMESPACE_LIB}/proxystubs COMPONENT libs # shared lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/proxystubs COMPONENT libs # shared lib ) if(JSON_ENUM_SOURCES) install(TARGETS ExampleDefinitions EXPORT ExampleDefinitionsTargets # for downstream dependencies - LIBRARY DESTINATION lib/ COMPONENT libs # shared lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/ COMPONENT libs # shared lib ) endif() install(FILES ${INTERFACES_HEADERS} - DESTINATION include/${NAMESPACE}/interfaces + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/interfaces ) install(FILES ${JSON_HEADERS} - DESTINATION include/${NAMESPACE}/interfaces/json + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/interfaces/json ) ```