Skip to content

Commit 37ec01e

Browse files
committed
build: port to new Swift support
This ports the libdispatch build to use the new builtin Swift support in CMake. It allows for a significant clean up of the build rules.
1 parent 87ae119 commit 37ec01e

File tree

5 files changed

+317
-626
lines changed

5 files changed

+317
-626
lines changed

CMakeLists.txt

Lines changed: 63 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11

2-
cmake_minimum_required(VERSION 3.4.3)
2+
cmake_minimum_required(VERSION 3.15.1)
33

4-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
4+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
5+
6+
# NOTE(compnerd) enable CMP0091 - select MSVC runtime based on
7+
# CMAKE_MSVC_RUNTIME_LIBRARY. Requires CMake 3.15 or newer.
8+
if(POLICY CMP0091)
9+
cmake_policy(SET CMP0091 NEW)
10+
endif()
511

612
project(dispatch
7-
VERSION 1.3
8-
LANGUAGES C CXX)
13+
VERSION 1.3
14+
LANGUAGES C CXX)
915

1016
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
1117
include(ClangClCompileRules)
1218
endif()
1319

20+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
21+
include(DispatchWindowsSupport)
22+
dispatch_windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_MSVC_ARCH)
23+
dispatch_windows_include_for_arch(${DISPATCH_MSVC_ARCH} DISPATCH_INCLUDES)
24+
include_directories(BEFORE SYSTEM ${DISPATCH_INCLUDES})
25+
dispatch_windows_lib_for_arch(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_LIBDIR)
26+
link_directories(${DISPATCH_LIBDIR})
27+
endif()
28+
1429
set(CMAKE_C_STANDARD 11)
1530
set(CMAKE_C_STANDARD_REQUIRED YES)
1631

1732
set(CMAKE_CXX_STANDARD 11)
1833

1934
set(CMAKE_C_VISIBILITY_PRESET hidden)
35+
set(CMAKE_C_VISIBILITY_INLINES_HIDDEN YES)
2036

2137
# NOTE(compnerd) this is a horrible workaround for Windows to ensure that the
2238
# tests can run as there is no rpath equivalent and `PATH` is used to lookup the
@@ -28,74 +44,37 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
2844
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
2945
find_package(Threads REQUIRED)
3046

47+
include(CheckCCompilerFlag)
3148
include(CheckCSourceCompiles)
3249
include(CheckFunctionExists)
3350
include(CheckIncludeFiles)
3451
include(CheckLibraryExists)
3552
include(CheckSymbolExists)
3653
include(GNUInstallDirs)
37-
include(SwiftSupport)
3854
include(CTest)
3955

40-
set(SWIFT_LIBDIR "lib" CACHE PATH "Library folder name, defined by swift main buildscript")
41-
set(INSTALL_LIBDIR "${SWIFT_LIBDIR}" CACHE PATH "Path where the libraries should be installed")
42-
4356
include(DispatchAppleOptions)
4457
include(DispatchSanitization)
45-
4658
include(DispatchCompilerWarnings)
47-
dispatch_common_warnings()
48-
49-
option(ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON)
50-
set(USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR})
59+
include(DTrace)
60+
include(SwiftSupport)
5161

5262
# NOTE(abdulras) this is the CMake supported way to control whether we generate
5363
# shared or static libraries. This impacts the behaviour of `add_library` in
5464
# what type of library it generates.
5565
option(BUILD_SHARED_LIBS "build shared libraries" ON)
5666

57-
option(ENABLE_SWIFT "enable libdispatch swift overlay" OFF)
58-
if(ENABLE_SWIFT)
59-
if(NOT CMAKE_SWIFT_COMPILER)
60-
message(FATAL_ERROR "CMAKE_SWIFT_COMPILER must be defined to enable swift")
61-
endif()
62-
63-
string(TOLOWER ${CMAKE_SYSTEM_NAME} swift_os)
64-
get_swift_host_arch(swift_arch)
65-
66-
if(BUILD_SHARED_LIBS)
67-
set(swift_dir swift)
68-
else()
69-
set(swift_dir swift_static)
70-
endif()
71-
72-
set(INSTALL_TARGET_DIR "${INSTALL_LIBDIR}/${swift_dir}/${swift_os}" CACHE PATH "Path where the libraries will be installed")
73-
set(INSTALL_DISPATCH_HEADERS_DIR "${INSTALL_LIBDIR}/${swift_dir}/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch")
74-
set(INSTALL_BLOCK_HEADERS_DIR "${INSTALL_LIBDIR}/${swift_dir}/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime")
75-
set(INSTALL_OS_HEADERS_DIR "${INSTALL_LIBDIR}/${swift_dir}/os" CACHE PATH "Path where the os/ headers will be installed")
76-
endif()
77-
78-
if(NOT ENABLE_SWIFT)
79-
set(INSTALL_TARGET_DIR "${INSTALL_LIBDIR}" CACHE PATH "Path where the libraries will be installed")
80-
set(INSTALL_DISPATCH_HEADERS_DIR "include/dispatch" CACHE PATH "Path where the headers will be installed")
81-
set(INSTALL_BLOCK_HEADERS_DIR "include" CACHE PATH "Path where the headers will be installed for the blocks runtime")
82-
set(INSTALL_OS_HEADERS_DIR "include/os" CACHE PATH "Path where the headers will be installed")
83-
endif()
84-
8567
option(DISPATCH_ENABLE_ASSERTS "enable debug assertions" FALSE)
8668

87-
option(ENABLE_DTRACE "enable dtrace support" "")
69+
option(ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON)
70+
set(USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR})
8871

89-
option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via _Thread_local" ON)
90-
set(DISPATCH_USE_THREAD_LOCAL_STORAGE ${ENABLE_THREAD_LOCAL_STORAGE})
72+
option(ENABLE_DTRACE "enable dtrace support" "")
9173

92-
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR
93-
CMAKE_SYSTEM_NAME STREQUAL Android OR
94-
CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR
95-
CMAKE_SYSTEM_NAME STREQUAL Windows)
96-
set(ENABLE_INTERNAL_PTHREAD_WORKQUEUES_DEFAULT ON)
97-
else()
74+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
9875
set(ENABLE_INTERNAL_PTHREAD_WORKQUEUES_DEFAULT OFF)
76+
else()
77+
set(ENABLE_INTERNAL_PTHREAD_WORKQUEUES_DEFAULT ON)
9978
endif()
10079
option(ENABLE_INTERNAL_PTHREAD_WORKQUEUES "use libdispatch's own implementation of pthread workqueues" ${ENABLE_INTERNAL_PTHREAD_WORKQUEUES_DEFAULT})
10180
if(ENABLE_INTERNAL_PTHREAD_WORKQUEUES)
@@ -114,6 +93,15 @@ endif()
11493

11594
option(INSTALL_PRIVATE_HEADERS "installs private headers in the same location as the public ones" OFF)
11695

96+
option(ENABLE_SWIFT "enable libdispatch swift overlay" OFF)
97+
if(ENABLE_SWIFT)
98+
enable_language(Swift)
99+
endif()
100+
101+
option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via _Thread_local" ON)
102+
set(DISPATCH_USE_THREAD_LOCAL_STORAGE ${ENABLE_THREAD_LOCAL_STORAGE})
103+
104+
117105
check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
118106
if(_GNU_SOURCE)
119107
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE)
@@ -144,8 +132,6 @@ check_function_exists(strlcpy HAVE_STRLCPY)
144132
check_function_exists(sysconf HAVE_SYSCONF)
145133
check_function_exists(arc4random HAVE_ARC4RANDOM)
146134

147-
find_package(Threads REQUIRED)
148-
149135
check_include_files("TargetConditionals.h" HAVE_TARGETCONDITIONALS_H)
150136
check_include_files("dlfcn.h" HAVE_DLFCN_H)
151137
check_include_files("fcntl.h" HAVE_FCNTL_H)
@@ -181,7 +167,7 @@ else()
181167
set(USE_MACH_SEM 0)
182168
endif()
183169
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
184-
add_definitions(-DUSE_WIN32_SEM)
170+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:USE_WIN32_SEM>)
185171
endif()
186172
check_library_exists(pthread sem_init "" USE_POSIX_SEM)
187173
# NOTE: android has not always provided a libpthread, but uses the pthreads API
@@ -211,7 +197,7 @@ check_symbol_exists(VQ_FREE_SPACE_CHANGE "sys/mount.h" HAVE_DECL_VQ_FREE_SPACE_C
211197
check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)
212198
check_symbol_exists(program_invocation_name "errno.h" HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME)
213199
if (HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME)
214-
add_definitions(-D_GNU_SOURCE=1)
200+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:_GNU_SOURCE=1>)
215201
endif()
216202
check_symbol_exists(__printflike "bsd/sys/cdefs.h" HAVE_PRINTFLIKE)
217203

@@ -220,31 +206,28 @@ if(CMAKE_SYSTEM_NAME STREQUAL Android)
220206
endif()
221207

222208
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
223-
add_definitions(-D_WITH_DPRINTF)
209+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:_WITH_DPRINTF>)
224210
endif()
225211

226-
if(ENABLE_DTRACE STREQUAL "")
212+
if(ENABLE_DTRACE)
227213
find_program(dtrace_EXECUTABLE dtrace)
228-
if(dtrace_EXECUTABLE)
229-
add_definitions(-DDISPATCH_USE_DTRACE=1)
230-
else()
231-
add_definitions(-DDISPATCH_USE_DTRACE=0)
232-
endif()
233-
elseif(ENABLE_DTRACE)
234-
find_program(dtrace_EXECUTABLE dtrace)
235-
if(NOT dtrace_EXECUTABLE)
214+
if(NOT dtrace_EXECUTABLE AND NOT ENABLE_DTRACE STREQUAL "")
236215
message(FATAL_ERROR "dtrace not found but explicitly requested")
237216
endif()
238-
add_definitions(-DDISPATCH_USE_DTRACE=1)
217+
endif()
218+
219+
if(dtrace_EXECUTABLE)
220+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:DISPATCH_USE_DTRACE=1>)
239221
else()
240-
add_definitions(-DDISPATCH_USE_DTRACE=0)
222+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:DISPATCH_USE_DTRACE=0>)
241223
endif()
242224

243225
find_program(leaks_EXECUTABLE leaks)
244226
if(leaks_EXECUTABLE)
245227
set(HAVE_LEAKS TRUE)
246228
endif()
247229

230+
248231
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
249232
add_custom_command(OUTPUT
250233
"${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
@@ -266,19 +249,25 @@ add_custom_target(module-maps ALL
266249
DEPENDS
267250
"${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
268251
"${PROJECT_SOURCE_DIR}/private/module.modulemap")
252+
269253
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
270254
"${PROJECT_BINARY_DIR}/config/config_ac.h")
271-
add_definitions(-DHAVE_CONFIG_H)
255+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:HAVE_CONFIG_H>)
272256

273-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
274-
include(DispatchWindowsSupport)
275-
dispatch_windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_MSVC_ARCH)
276-
dispatch_windows_include_for_arch(${DISPATCH_MSVC_ARCH} DISPATCH_INCLUDES)
277-
include_directories(BEFORE SYSTEM ${DISPATCH_INCLUDES})
278-
dispatch_windows_lib_for_arch(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_LIBDIR)
279-
link_directories(${DISPATCH_LIBDIR})
257+
258+
if(ENABLE_SWIFT)
259+
set(INSTALL_TARGET_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>" CACHE PATH "Path where the libraries will be installed")
260+
set(INSTALL_DISPATCH_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch")
261+
set(INSTALL_BLOCK_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime")
262+
set(INSTALL_OS_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/os" CACHE PATH "Path where the os/ headers will be installed")
263+
else()
264+
set(INSTALL_TARGET_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Path where the libraries will be installed")
265+
set(INSTALL_DISPATCH_HEADERS_DIR "include/dispatch" CACHE PATH "Path where the headers will be installed")
266+
set(INSTALL_BLOCK_HEADERS_DIR "include" CACHE PATH "Path where the headers will be installed for the blocks runtime")
267+
set(INSTALL_OS_HEADERS_DIR "include/os" CACHE PATH "Path where the headers will be installed")
280268
endif()
281269

270+
282271
add_subdirectory(dispatch)
283272
add_subdirectory(man)
284273
add_subdirectory(os)
@@ -287,4 +276,3 @@ add_subdirectory(src)
287276
if(BUILD_TESTING)
288277
add_subdirectory(tests)
289278
endif()
290-
Lines changed: 67 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,75 @@
11

22
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
33
# TODO: someone needs to provide the msvc equivalent warning flags
4-
macro(dispatch_common_warnings)
5-
endmacro()
64
else()
7-
macro(dispatch_common_warnings)
8-
add_compile_options(-Werror)
9-
add_compile_options(-Wall)
10-
add_compile_options(-Wextra)
5+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror>)
6+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wall>)
7+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wextra>)
118

12-
add_compile_options(-Warray-bounds-pointer-arithmetic)
13-
add_compile_options(-Wassign-enum)
14-
add_compile_options(-Watomic-properties)
15-
add_compile_options(-Wcomma)
16-
add_compile_options(-Wconditional-uninitialized)
17-
add_compile_options(-Wconversion)
18-
add_compile_options(-Wcovered-switch-default)
19-
add_compile_options(-Wdate-time)
20-
add_compile_options(-Wdeprecated)
21-
add_compile_options(-Wdocumentation)
22-
add_compile_options(-Wdouble-promotion)
23-
add_compile_options(-Wduplicate-enum)
24-
add_compile_options(-Wexpansion-to-defined)
25-
add_compile_options(-Wfloat-equal)
26-
add_compile_options(-Widiomatic-parentheses)
27-
add_compile_options(-Winfinite-recursion)
28-
add_compile_options(-Wmissing-prototypes)
29-
add_compile_options(-Wnewline-eof)
30-
add_compile_options(-Wnullable-to-nonnull-conversion)
31-
add_compile_options(-Wobjc-interface-ivars)
32-
add_compile_options(-Wover-aligned)
33-
add_compile_options(-Wpacked)
34-
add_compile_options(-Wpointer-arith)
35-
add_compile_options(-Wselector)
36-
add_compile_options(-Wshadow)
37-
add_compile_options(-Wshorten-64-to-32)
38-
add_compile_options(-Wsign-conversion)
39-
add_compile_options(-Wstatic-in-inline)
40-
add_compile_options(-Wsuper-class-method-mismatch)
41-
add_compile_options(-Wswitch)
42-
add_compile_options(-Wunguarded-availability)
43-
add_compile_options(-Wunreachable-code)
44-
add_compile_options(-Wunused)
9+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Warray-bounds-pointer-arithmetic>)
10+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wassign-enum>)
11+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Watomic-properties>)
12+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wcomma>)
13+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wconditional-uninitialized>)
14+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wconversion>)
15+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wcovered-switch-default>)
16+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wdate-time>)
17+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wdeprecated>)
18+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wdocumentation>)
19+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wdouble-promotion>)
20+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wduplicate-enum>)
21+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wexpansion-to-defined>)
22+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wfloat-equal>)
23+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Widiomatic-parentheses>)
24+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Winfinite-recursion>)
25+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wmissing-prototypes>)
26+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wnewline-eof>)
27+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wnullable-to-nonnull-conversion>)
28+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wobjc-interface-ivars>)
29+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wover-aligned>)
30+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wpacked>)
31+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wpointer-arith>)
32+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wselector>)
33+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wshadow>)
34+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wshorten-64-to-32>)
35+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wsign-conversion>)
36+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wstatic-in-inline>)
37+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wsuper-class-method-mismatch>)
38+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wswitch>)
39+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wunguarded-availability>)
40+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wunreachable-code>)
41+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wunused>)
4542

46-
add_compile_options(-Wno-unknown-warning-option)
47-
add_compile_options(-Wno-trigraphs)
48-
add_compile_options(-Wno-four-char-constants)
49-
add_compile_options(-Wno-disabled-macro-expansion)
50-
add_compile_options(-Wno-pedantic)
51-
add_compile_options(-Wno-bad-function-cast)
52-
add_compile_options(-Wno-c++-compat)
53-
add_compile_options(-Wno-c++98-compat)
54-
add_compile_options(-Wno-c++98-compat-pedantic)
55-
add_compile_options(-Wno-cast-align)
56-
add_compile_options(-Wno-cast-qual)
57-
add_compile_options(-Wno-documentation-unknown-command)
58-
add_compile_options(-Wno-format-nonliteral)
59-
add_compile_options(-Wno-missing-variable-declarations)
60-
add_compile_options(-Wno-old-style-cast)
61-
add_compile_options(-Wno-padded)
62-
add_compile_options(-Wno-reserved-id-macro)
63-
add_compile_options(-Wno-shift-sign-overflow)
64-
add_compile_options(-Wno-undef)
65-
add_compile_options(-Wno-unreachable-code-aggressive)
66-
add_compile_options(-Wno-unused-macros)
67-
add_compile_options(-Wno-used-but-marked-unused)
68-
add_compile_options(-Wno-vla)
43+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-unknown-warning-option>)
44+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-trigraphs>)
45+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-four-char-constants>)
46+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-disabled-macro-expansion>)
47+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-pedantic>)
48+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-bad-function-cast>)
49+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-c++-compat>)
50+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-c++98-compat>)
51+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-c++98-compat-pedantic>)
52+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-cast-align>)
53+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-cast-qual>)
54+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-documentation-unknown-command>)
55+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-format-nonliteral>)
56+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-missing-variable-declarations>)
57+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-old-style-cast>)
58+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-padded>)
59+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-reserved-id-macro>)
60+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-shift-sign-overflow>)
61+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-undef>)
62+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-unreachable-code-aggressive>)
63+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-unused-macros>)
64+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-used-but-marked-unused>)
65+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-vla>)
6966

70-
if(CMAKE_SYSTEM_NAME STREQUAL Android)
71-
add_compile_options(-Wno-incompatible-function-pointer-types)
72-
add_compile_options(-Wno-implicit-function-declaration)
73-
add_compile_options(-Wno-conversion)
74-
add_compile_options(-Wno-int-conversion)
75-
add_compile_options(-Wno-shorten-64-to-32)
76-
endif()
77-
add_compile_options(-Wno-error=assign-enum)
78-
endmacro()
67+
if(CMAKE_SYSTEM_NAME STREQUAL Android)
68+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-incompatible-function-pointer-types>)
69+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-implicit-function-declaration>)
70+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-conversion>)
71+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-int-conversion>)
72+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-shorten-64-to-32>)
73+
endif()
74+
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-error=assign-enum>)
7975
endif()

0 commit comments

Comments
 (0)