Improve MSVC builds
This commit is contained in:
parent
0babf5193b
commit
412e0355a4
6 changed files with 47 additions and 9 deletions
|
@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 2.6)
|
|||
if(POLICY CMP0025)
|
||||
cmake_policy(SET CMP0025 NEW)
|
||||
endif()
|
||||
# Only interpret if() arguments as variables or keywords when unquoted.
|
||||
if(POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
|
||||
project(rtl433 C)
|
||||
|
||||
|
@ -64,6 +68,13 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
|||
ADD_DEFINITIONS(-Wlarge-by-value-copy=8)
|
||||
endif()
|
||||
|
||||
# Shut MSVC up about strdup and strtok
|
||||
if(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ADD_DEFINITIONS(-DNOMINMAX)
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# Find build dependencies
|
||||
########################################################################
|
||||
|
@ -104,7 +115,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Profile")
|
|||
ADD_DEFINITIONS(-fno-builtin-free)
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
if(MINGW OR MSVC)
|
||||
list(APPEND NET_LIBRARIES ws2_32 mswsock)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
// Helper macros
|
||||
// Helper macros, collides with MSVC's stdlib.h unless NOMINMAX is used
|
||||
#ifndef max
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
|
|
@ -132,6 +132,11 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
|||
SET_SOURCE_FILES_PROPERTIES(mongoose.c PROPERTIES COMPILE_FLAGS "-Wno-format-pedantic -Wno-large-by-value-copy")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# needs CMake 3.1 but Windows builds should have that
|
||||
target_sources(rtl_433 PRIVATE getopt/getopt.c)
|
||||
endif()
|
||||
|
||||
add_library(data data.c abuf.c term_ctl.c mongoose.c)
|
||||
target_link_libraries(data ${NET_LIBRARIES})
|
||||
|
||||
|
|
|
@ -766,6 +766,8 @@ static void data_output_csv_start(struct data_output *output, const char **field
|
|||
csv->separator = ",";
|
||||
|
||||
allowed = calloc(num_fields, sizeof(const char *));
|
||||
if (!allowed)
|
||||
goto alloc_error;
|
||||
memcpy(allowed, fields, sizeof(const char *) * num_fields);
|
||||
|
||||
qsort(allowed, num_fields, sizeof(char *), compare_strings);
|
||||
|
|
|
@ -50,13 +50,17 @@
|
|||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _MSC_VER
|
||||
#include "getopt/getopt.h"
|
||||
#define F_OK 0
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#include "getopt/getopt.h"
|
||||
#endif
|
||||
|
||||
#ifdef GIT_VERSION
|
||||
|
|
|
@ -15,7 +15,23 @@
|
|||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _MSC_VER
|
||||
#define F_OK 0
|
||||
#define R_OK (1 << 2)
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "baseband.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue