Skip to content

Commit

Permalink
improved compiling checks
Browse files Browse the repository at this point in the history
  • Loading branch information
weinrank committed Aug 6, 2018
1 parent 3c3962c commit 2e5216b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Copyright (C) 2015-2015 Oleg Alexeenkov
# Copyright (C) 2015-2017 Felix Weinrank
# Copyright (C) 2015-2018 Felix Weinrank
#
# All rights reserved.
#
Expand Down Expand Up @@ -236,12 +236,25 @@ endif ()
# SETTINGS FOR VISUAL STUDIO COMPILER
if (CMAKE_C_COMPILER_ID MATCHES "MSVC")
if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif ()

if (WERROR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4100") # 'identifier' : unreferenced formal parameter
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127") # conditional expression is constant
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4200") # nonstandard extension used : zero-sized array in struct/union
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4214") # bit field types other than int
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706") # assignment within conditional expression
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4245") # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4389") # 'operator' : signed/unsigned mismatch
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4702") # unreachable code
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4701") # Potentially uninitialized local variable 'name' used

# ToDo
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244") # 'conversion' conversion from 'type1' to 'type2', possible loss of data

if (sctp_werror)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif ()
endif ()
Expand Down
7 changes: 4 additions & 3 deletions programs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ include_directories(${CMAKE_SOURCE_DIR}/usrsctplib)
# OS DEPENDENT
#################################################

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-D__APPLE_USE_RFC_2292)
endif ()

Expand Down Expand Up @@ -99,7 +99,8 @@ foreach (source_file ${check_programs})
${source_file}
)

target_link_libraries(${source_file_we}
target_link_libraries(
${source_file_we}
${programs_link_library}
${CMAKE_THREAD_LIBS_INIT}
)
Expand Down
3 changes: 3 additions & 0 deletions programs/rtcweb.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct peer_connection {
#define SCTP_PACKED
#endif

#pragma warning( push )
#pragma warning( disable : 4200 )
struct rtcweb_datachannel_open_request {
uint8_t msg_type; /* DATA_CHANNEL_OPEN_REQUEST */
uint8_t channel_type;
Expand All @@ -127,6 +129,7 @@ struct rtcweb_datachannel_open_request {
int16_t priority;
char label[];
} SCTP_PACKED;
#pragma warning( pop )

struct rtcweb_datachannel_open_response {
uint8_t msg_type; /* DATA_CHANNEL_OPEN_RESPONSE */
Expand Down
12 changes: 6 additions & 6 deletions usrsctplib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,32 @@ add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
# OS DEPENDENT
#################################################

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions(-U__FreeBSD__)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member")
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-U__APPLE__)
add_definitions(-D__APPLE_USE_RFC_2292)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member -Wno-deprecated-declarations")
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
if (CMAKE_SYSTEM_NAME MATCHES "DragonFly")
add_definitions(-U__DragonFly__)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_definitions(-U__NetBSD__)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_definitions(-U__OpenBSD__)
endif ()

Expand Down

0 comments on commit 2e5216b

Please sign in to comment.