Skip to content

Commit bd68d3c

Browse files
committed
fix #13993: simplecpp: bump to 1.4.4
1 parent 0eb4dd8 commit bd68d3c

3 files changed

Lines changed: 204 additions & 126 deletions

File tree

externals/simplecpp/CMakeLists.txt

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
1-
file(GLOB hdrs "*.h")
2-
file(GLOB srcs "*.cpp")
1+
cmake_minimum_required (VERSION 3.10)
2+
project (simplecpp LANGUAGES CXX)
33

4-
add_library(simplecpp_objs OBJECT ${srcs} ${hdrs})
5-
if (BUILD_CORE_DLL)
6-
target_compile_definitions(simplecpp_objs PRIVATE SIMPLECPP_EXPORT)
4+
set(CMAKE_CXX_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
7+
include(CheckCXXCompilerFlag)
8+
9+
if (WIN32)
10+
# prevent simplifyPath_cppcheck() from wasting time on looking for a hypothetical network host
11+
add_definitions(-DUNCHOST=$ENV{COMPUTERNAME})
712
endif()
813

9-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10-
target_compile_options_safe(simplecpp_objs -Wno-zero-as-null-pointer-constant)
14+
function(add_compile_options_safe FLAG)
15+
string(MAKE_C_IDENTIFIER "HAS_CXX_FLAG${FLAG}" mangled_flag)
16+
check_cxx_compiler_flag(${FLAG} ${mangled_flag})
17+
if (${mangled_flag})
18+
add_compile_options(${FLAG})
19+
endif()
20+
endfunction()
21+
22+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
23+
add_compile_options(-pedantic)
24+
add_compile_options(-Wall)
25+
add_compile_options(-Wextra)
26+
add_compile_options(-Wcast-qual) # Cast for removing type qualifiers
27+
add_compile_options(-Wfloat-equal) # Floating values used in equality comparisons
28+
add_compile_options(-Wmissing-declarations) # If a global function is defined without a previous declaration
29+
add_compile_options(-Wmissing-format-attribute) #
30+
add_compile_options(-Wno-long-long)
31+
add_compile_options(-Wpacked) #
32+
add_compile_options(-Wredundant-decls) # if anything is declared more than once in the same scope
33+
add_compile_options(-Wundef)
34+
add_compile_options(-Wno-missing-braces)
35+
add_compile_options(-Wno-sign-compare)
36+
add_compile_options(-Wno-multichar)
37+
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
38+
39+
add_compile_options(-Wsuggest-attribute=noreturn)
40+
add_compile_options_safe(-Wuseless-cast)
41+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
42+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
43+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
44+
add_compile_options(-Weverything)
45+
# no need for c++98 compatibility
46+
add_compile_options(-Wno-c++98-compat-pedantic)
47+
# these are not really fixable
48+
add_compile_options(-Wno-exit-time-destructors -Wno-global-constructors -Wno-weak-vtables)
49+
add_compile_options_safe(-Wno-unsafe-buffer-usage)
50+
# we are not interested in these
51+
add_compile_options(-Wno-multichar -Wno-four-char-constants)
52+
# ignore C++11-specific warning
53+
add_compile_options(-Wno-suggest-override -Wno-suggest-destructor-override)
54+
# contradicts -Wcovered-switch-default
55+
add_compile_options(-Wno-switch-default)
56+
# TODO: fix these?
57+
add_compile_options(-Wno-padded -Wno-sign-conversion -Wno-implicit-int-conversion -Wno-shorten-64-to-32 -Wno-shadow-field-in-constructor)
58+
59+
if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
60+
# TODO: verify this regression still exists in clang-15
61+
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
62+
# work around performance regression - see https://github.com/llvm/llvm-project/issues/53555
63+
add_compile_options(-mllvm -inline-deferral)
64+
endif()
65+
66+
# use force DWARF 4 debug format since not all tools might be able to handle DWARF 5 yet - e.g. valgrind on ubuntu 20.04
67+
add_compile_options(-gdwarf-4)
68+
endif()
1169
endif()
70+
71+
add_library(simplecpp_obj OBJECT simplecpp.cpp)
72+
73+
add_executable(simplecpp $<TARGET_OBJECTS:simplecpp_obj> main.cpp)
74+
add_executable(testrunner $<TARGET_OBJECTS:simplecpp_obj> test.cpp)
75+
76+
enable_testing()
77+
add_test(NAME testrunner COMMAND testrunner)

0 commit comments

Comments
 (0)