Support OpenBSD (#626)

Co-authored-by: an-tao <antao2002@gmail.com>
This commit is contained in:
Joakim L. Gilje 2020-11-15 05:18:01 +01:00 committed by GitHub
parent 4f9ee82153
commit 886dfc3648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 9 deletions

View File

@ -77,7 +77,9 @@ add_subdirectory(trantor)
target_link_libraries(${PROJECT_NAME} PUBLIC trantor)
if(NOT WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE dl)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
target_link_libraries(${PROJECT_NAME} PRIVATE dl)
endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
else(NOT WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE shlwapi)
endif(NOT WIN32)
@ -100,7 +102,7 @@ find_package(Jsoncpp REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib)
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS})
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT WIN32)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" AND NOT WIN32)
find_package(UUID REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE UUID_lib)
@ -117,7 +119,7 @@ if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT WIN32)
else()
message(FATAL_ERROR "uuid lib error")
endif()
endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT WIN32)
endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" AND NOT WIN32)
find_package(Brotli)
if(Brotli_FOUND)

View File

@ -14,9 +14,9 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
find_dependency(Jsoncpp REQUIRED)
find_dependency(Trantor REQUIRED)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT WIN32)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" AND NOT WIN32)
find_dependency(UUID REQUIRED)
endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT WIN32)
endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" AND NOT WIN32)
find_dependency(ZLIB REQUIRED)
if(@pg_FOUND@)
find_dependency(pg)

View File

@ -344,10 +344,15 @@ std::string getUuid()
std::string ret{binaryStringToHex((const unsigned char *)str, len)};
free(str);
return ret;
#elif defined __FreeBSD__
#elif defined __FreeBSD__ || defined __OpenBSD__
uuid_t *uuid = new uuid_t;
char *binstr = (char *)malloc(16);
#if defined __FreeBSD__
uuidgen(uuid, 1);
#else
uint32_t status;
uuid_create(uuid, &status);
#endif
#if _BYTE_ORDER == _LITTLE_ENDIAN
uuid_enc_le(binstr, uuid);
#else /* _BYTE_ORDER != _LITTLE_ENDIAN */

View File

@ -35,11 +35,11 @@
#include <arpa/inet.h>
#endif
#if defined __linux__ || defined __FreeBSD__
#if defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__
#ifdef __linux__
#include <endian.h> // __BYTE_ORDER __LITTLE_ENDIAN
#elif defined __FreeBSD__
#elif defined __FreeBSD__ || defined __OpenBSD__
#include <sys/endian.h> // _BYTE_ORDER _LITTLE_ENDIAN
#define __BYTE_ORDER _BYTE_ORDER
#define __LITTLE_ENDIAN _LITTLE_ENDIAN

@ -1 +1 @@
Subproject commit 28371795d6479a77771a2b25fc310795872bae46
Subproject commit b2902d217b9f0a59c428bff1ca6ccfe024a86aa6