This commit is contained in:
Foad S. Farimani 2025-05-01 08:52:10 +02:00 committed by GitHub
commit 1415e6303d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 20 deletions

View file

@ -75,10 +75,17 @@ check_struct_has_member ("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF)
check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME) check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME)
message ("-- Looking for libuuid") message ("-- Looking for libuuid")
if (DARWIN OR FREEBSD OR OPENBSD) if (WINDOWS)
# Windows has built-in UUID functionality via RPC API
message ("-- Windows detected, using Windows UUID API")
# Add the required Windows libraries for UUID support
set (TASK_LIBRARIES ${TASK_LIBRARIES} rpcrt4)
set (HAVE_UUID_UNPARSE_LOWER TRUE)
# No need to add include dirs as Windows headers are already available
elseif (DARWIN OR FREEBSD OR OPENBSD)
# Apple and FreeBSD include the uuid functions in their libc, rather than libuuid # Apple and FreeBSD include the uuid functions in their libc, rather than libuuid
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER) check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
else (DARWIN OR FREEBSD OR OPENBSD) else (WINDOWS)
find_path (UUID_INCLUDE_DIR uuid/uuid.h) find_path (UUID_INCLUDE_DIR uuid/uuid.h)
find_library (UUID_LIBRARY NAMES uuid) find_library (UUID_LIBRARY NAMES uuid)
if (UUID_INCLUDE_DIR AND UUID_LIBRARY) if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
@ -91,7 +98,7 @@ else (DARWIN OR FREEBSD OR OPENBSD)
else (UUID_INCLUDE_DIR AND UUID_LIBRARY) else (UUID_INCLUDE_DIR AND UUID_LIBRARY)
message (FATAL_ERROR "-- libuuid not found.") message (FATAL_ERROR "-- libuuid not found.")
endif (UUID_INCLUDE_DIR AND UUID_LIBRARY) endif (UUID_INCLUDE_DIR AND UUID_LIBRARY)
endif (DARWIN OR FREEBSD OR OPENBSD) endif (WINDOWS)
if (HAVE_UUID_UNPARSE_LOWER) if (HAVE_UUID_UNPARSE_LOWER)
message ("-- Found libuuid") message ("-- Found libuuid")

View file

@ -3,6 +3,14 @@ message ("-- System: ${CMAKE_SYSTEM_NAME}")
include (CheckCXXCompilerFlag) include (CheckCXXCompilerFlag)
# Check for MSVC compiler to use the correct flag
if(MSVC)
set(_HAS_CXX17 ON) # MSVC 2019 supports C++17 by default
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
else()
# For GCC, Clang, etc.
CHECK_CXX_COMPILER_FLAG("-std=c++17" _HAS_CXX17) CHECK_CXX_COMPILER_FLAG("-std=c++17" _HAS_CXX17)
if (_HAS_CXX17) if (_HAS_CXX17)
@ -11,6 +19,7 @@ if (_HAS_CXX17)
else (_HAS_CXX17) else (_HAS_CXX17)
message (FATAL_ERROR "C++17 support missing. Try upgrading your C++ compiler. If you have a good reason for using an outdated compiler, please let us know at support@gothenburgbitfactory.org.") message (FATAL_ERROR "C++17 support missing. Try upgrading your C++ compiler. If you have a good reason for using an outdated compiler, please let us know at support@gothenburgbitfactory.org.")
endif (_HAS_CXX17) endif (_HAS_CXX17)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (LINUX true) set (LINUX true)
@ -34,9 +43,15 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "GNU")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
set (CYGWIN true) set (CYGWIN true)
set (CMAKE_CXX_EXTENSIONS ON) set (CMAKE_CXX_EXTENSIONS ON)
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (WINDOWS true)
# Add Windows-specific flags if needed
else ()
set (UNKNOWN true) set (UNKNOWN true)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif ()
if(NOT MSVC)
# These flags are not applicable to MSVC
set (CMAKE_CXX_FLAGS "${_CXX14_FLAGS} ${CMAKE_CXX_FLAGS}") set (CMAKE_CXX_FLAGS "${_CXX14_FLAGS} ${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wsign-compare -Wreturn-type ${CMAKE_CXX_FLAGS}") set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wsign-compare -Wreturn-type ${CMAKE_CXX_FLAGS}")
endif()

@ -1 +1 @@
Subproject commit 2aa844cb9b015fca81b947c57fde07999ede002b Subproject commit 1e949b4773df59be0ff6842600b49e265dfacefa

View file

@ -36,11 +36,20 @@
#include <Duration.h> #include <Duration.h>
#include <Lexer.h> #include <Lexer.h>
#include <format.h> #include <format.h>
// Platform-specific includes
#ifdef _WIN32
#include <windows.h>
// Windows-specific user info implementation will be needed
// Create a pwd.h equivalent for Windows
#else
#include <pwd.h> #include <pwd.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h>
#endif
#include <time.h> #include <time.h>
#include <unicode.h> #include <unicode.h>
#include <unistd.h>
#include <util.h> #include <util.h>
#include <optional> #include <optional>

View file

@ -30,16 +30,25 @@
#include <cmake.h> #include <cmake.h>
// cmake.h include header must come first // cmake.h include header must come first
#include <sys/types.h>
#include <string> #include <string>
#include <vector> #include <vector>
#if defined(FREEBSD) || defined(OPENBSD)
// Platform-specific UUID handling
#ifdef _WIN32
#include <rpc.h>
#include <windows.h>
// Define uuid_t for Windows compatibility
typedef UUID uuid_t;
#ifndef uuid_unparse_lower
void uuid_unparse_lower(uuid_t uu, char* out);
#endif
#elif defined(FREEBSD) || defined(OPENBSD)
#include <sys/types.h>
#include <uuid.h> #include <uuid.h>
#else #else
#include <sys/types.h>
#include <uuid/uuid.h> #include <uuid/uuid.h>
#endif #endif
#include <Table.h>
// util.cpp // util.cpp
int confirm4(const std::string&); int confirm4(const std::string&);