diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f6fc17d..755f3c6c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,10 @@ check_include_files("unistd.h" HAVE_UNISTD_H) check_include_files("objc/objc-internal.h" HAVE_OBJC) check_library_exists(pthread sem_init "" USE_POSIX_SEM) +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + add_definitions(-DTARGET_OS_WIN32) + add_definitions(-DUSE_WIN32_SEM) +endif() check_symbol_exists(CLOCK_UPTIME "time.h" HAVE_DECL_CLOCK_UPTIME) check_symbol_exists(CLOCK_UPTIME_FAST "time.h" HAVE_DECL_CLOCK_UPTIME_FAST) diff --git a/dispatch/dispatch.h b/dispatch/dispatch.h index 585940cc0..a0622e6cb 100644 --- a/dispatch/dispatch.h +++ b/dispatch/dispatch.h @@ -39,13 +39,17 @@ #endif #endif // __APPLE__ +#if HAVE_SYS_CDEFS_H #include +#endif #include #include #include #include #include +#if HAVE_UNISTD_H #include +#endif #include #if defined(__linux__) && defined(__has_feature) diff --git a/os/object.h b/os/object.h index b0b47059a..b98a93e57 100644 --- a/os/object.h +++ b/os/object.h @@ -26,10 +26,10 @@ #include #include #endif -#ifndef __linux__ -#include -#else +#ifdef __linux__ #include +#else +#include #endif /*! diff --git a/os/object_private.h b/os/object_private.h index 36a807cb0..ebaf8549f 100644 --- a/os/object_private.h +++ b/os/object_private.h @@ -27,7 +27,9 @@ #ifndef __OS_OBJECT_PRIVATE__ #define __OS_OBJECT_PRIVATE__ +#if HAVE_SYS_CDEFS_H #include +#endif #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 113ff4e3b..75c72666b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,24 +72,47 @@ if(WITH_BLOCKS_RUNTIME) SYSTEM BEFORE PRIVATE "${WITH_BLOCKS_RUNTIME}") endif() -# TODO(compnerd) make this portable -target_compile_options(dispatch PRIVATE -fno-exceptions) +if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") + target_compile_options(dispatch PRIVATE /EHsc-) +else() + target_compile_options(dispatch PRIVATE -fno-exceptions) +endif() if(DISPATCH_ENABLE_ASSERTS) target_compile_definitions(dispatch PRIVATE -DDISPATCH_DEBUG=1) endif() +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + target_compile_definitions(dispatch + PRIVATE + -D_CRT_SECURE_NO_WARNINGS) +endif() if(BSD_OVERLAY_FOUND) target_compile_options(dispatch PRIVATE ${BSD_OVERLAY_CFLAGS}) endif() -# FIXME(compnerd) add check for -momit-leaf-frame-pointer? -target_compile_options(dispatch - PRIVATE - -Wall - -fblocks - -momit-leaf-frame-pointer) +if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") + target_compile_options(dispatch + PRIVATE + /W3) +else() + target_compile_options(dispatch + PRIVATE + -Wall) +endif() +# FIXME(compnerd) add check for -fblocks? +if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") + target_compile_options(dispatch + PRIVATE + -Xclang -fblocks) +else() + # FIXME(compnerd) add check for -momit-leaf-frame-pointer? + target_compile_options(dispatch + PRIVATE + -fblocks + -momit-leaf-frame-pointer) +endif() if(BSD_OVERLAY_FOUND) target_link_libraries(dispatch PRIVATE ${BSD_OVERLAY_LDFLAGS}) endif()