cmake: for MSVC, enable /W4 and /Zc:strictStrings
This commit is contained in:
parent
31e8daca93
commit
100af32b21
@ -75,7 +75,14 @@ endif()
|
||||
|
||||
# Specific flags for Visual C++
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -TC")
|
||||
# Treat all files a C source files
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TC")
|
||||
# Set warning level to /W4
|
||||
string(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
# Enable /Zc:strictStrings when msvc_ver > 2012 and build_type != Debug
|
||||
if((MSVC_VERSION GREATER 1700) AND NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zc:strictStrings")
|
||||
endif()
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
|
@ -22,6 +22,11 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127) /* "conditional expression is constant" */
|
||||
#endif
|
||||
|
||||
const char* test_platform__alignment()
|
||||
{
|
||||
UTEST_ASSERT(offsetof(gmio_stl_coords_t, x) == 0);
|
||||
@ -56,6 +61,10 @@ const char* test_platform__global_h()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
const char* all_tests()
|
||||
{
|
||||
UTEST_SUITE_START();
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#define UTEST_MAIN(name) \
|
||||
int main(int argc, char *argv[]) {\
|
||||
(void)argc; \
|
||||
const char *result = NULL; \
|
||||
\
|
||||
printf("----\nRUNNING: %s\n", argv[0]);\
|
||||
|
Loading…
Reference in New Issue
Block a user