Skip to content

Commit

Permalink
Clean up some warnings and build flags
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed May 1, 2018
1 parent 60a7c6b commit cd26965
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
21 changes: 18 additions & 3 deletions loguru_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ cmake_minimum_required(VERSION 2.8)
project(loguru_example)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -pedantic -fsanitize=address -fno-omit-frame-pointer")
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-noreturn")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
endif() # Clang

file(GLOB source
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
Expand All @@ -20,4 +33,6 @@ add_executable(loguru_example ${source})

find_package(Threads)
target_link_libraries(loguru_example ${CMAKE_THREAD_LIBS_INIT}) # For pthreads
target_link_libraries(loguru_example dl) # For ldl
if(NOT WIN32)
target_link_libraries(loguru_example dl) # For ldl
endif()
13 changes: 10 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ cmake_minimum_required(VERSION 2.8)

project(loguru_test)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -pedantic -fsanitize=address -fno-omit-frame-pointer")
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand All @@ -22,7 +29,7 @@ add_executable(loguru_test loguru_test.cpp)
find_package(Threads)
target_link_libraries(loguru_test ${CMAKE_THREAD_LIBS_INIT}) # For pthreads
if(NOT WIN32)
target_link_libraries(loguru_test dl) # For ldl
target_link_libraries(loguru_test dl) # For ldl
endif()

enable_testing()
Expand Down
4 changes: 2 additions & 2 deletions test/loguru_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ int main(int argc, char* argv[])
} else if (test == "ABORT_S") {
ABORT_S() << "ABORT_S stream message";
} else if (test == "assert") {
const char* ptr = 0;
const char* ptr = nullptr;
assert(ptr && "Error that was unexpected");
} else if (test == "LOG_F_FATAL") {
LOG_F(FATAL, "Fatal format message");
} else if (test == "LOG_S_FATAL") {
LOG_S(FATAL) << "Fatal stream message";
} else if (test == "CHECK_NOTNULL_F") {
const char* ptr = 0;
const char* ptr = nullptr;
CHECK_NOTNULL_F(ptr);
} else if (test == "CHECK_F") {
CHECK_F(1 > 2);
Expand Down

0 comments on commit cd26965

Please sign in to comment.