diff --git a/CMakeLists.txt b/CMakeLists.txt index 9323dc5a0..8000dd72e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) 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 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_library (UUID_LIBRARY NAMES uuid) if (UUID_INCLUDE_DIR AND UUID_LIBRARY) @@ -91,7 +98,7 @@ else (DARWIN OR FREEBSD OR OPENBSD) else (UUID_INCLUDE_DIR AND UUID_LIBRARY) message (FATAL_ERROR "-- libuuid not found.") endif (UUID_INCLUDE_DIR AND UUID_LIBRARY) -endif (DARWIN OR FREEBSD OR OPENBSD) +endif (WINDOWS) if (HAVE_UUID_UNPARSE_LOWER) message ("-- Found libuuid") diff --git a/cmake/CXXSniffer.cmake b/cmake/CXXSniffer.cmake index ef1ec6511..297c20e33 100644 --- a/cmake/CXXSniffer.cmake +++ b/cmake/CXXSniffer.cmake @@ -3,14 +3,23 @@ message ("-- System: ${CMAKE_SYSTEM_NAME}") include (CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG("-std=c++17" _HAS_CXX17) +# 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) -if (_HAS_CXX17) - set (CMAKE_CXX_STANDARD 17) - set (CMAKE_CXX_EXTENSIONS OFF) -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.") -endif (_HAS_CXX17) + if (_HAS_CXX17) + set (CMAKE_CXX_STANDARD 17) + set (CMAKE_CXX_EXTENSIONS OFF) + 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.") + endif (_HAS_CXX17) +endif() if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set (LINUX true) @@ -34,9 +43,15 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "GNU") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN") set (CYGWIN true) 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) -endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +endif () -set (CMAKE_CXX_FLAGS "${_CXX14_FLAGS} ${CMAKE_CXX_FLAGS}") -set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wsign-compare -Wreturn-type ${CMAKE_CXX_FLAGS}") +if(NOT MSVC) + # These flags are not applicable to MSVC + set (CMAKE_CXX_FLAGS "${_CXX14_FLAGS} ${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wsign-compare -Wreturn-type ${CMAKE_CXX_FLAGS}") +endif() diff --git a/src/libshared b/src/libshared index 2aa844cb9..1e949b477 160000 --- a/src/libshared +++ b/src/libshared @@ -1 +1 @@ -Subproject commit 2aa844cb9b015fca81b947c57fde07999ede002b +Subproject commit 1e949b4773df59be0ff6842600b49e265dfacefa diff --git a/src/recur.h b/src/recur.h index db0b6306d..3ae798e8c 100644 --- a/src/recur.h +++ b/src/recur.h @@ -36,11 +36,20 @@ #include #include #include + +// Platform-specific includes +#ifdef _WIN32 +#include +// Windows-specific user info implementation will be needed +// Create a pwd.h equivalent for Windows +#else #include #include +#include +#endif + #include #include -#include #include #include diff --git a/src/util.h b/src/util.h index 782311117..28d8c2702 100644 --- a/src/util.h +++ b/src/util.h @@ -30,16 +30,25 @@ #include // cmake.h include header must come first -#include - #include #include -#if defined(FREEBSD) || defined(OPENBSD) + +// Platform-specific UUID handling +#ifdef _WIN32 +#include +#include +// 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 #include #else +#include #include #endif -#include // util.cpp int confirm4(const std::string&);