mirror of
https://git.code.sf.net/p/zint/code
synced 2026-01-26 21:35:57 +00:00
CMakeLists.txt: check against c not c++ (CheckCXX -> CheckC etc)
BMP/EMF/PCX/TIF: use more portable packed attribute instead of pragma if not MSVC CHANNEL: pass ptr not struct to `channel_copy_precalc()`
This commit is contained in:
@@ -36,36 +36,36 @@ endif()
|
||||
|
||||
include(SetPaths.cmake)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
if(NOT MSVC) # Use default warnings if MSVC otherwise inundated
|
||||
check_cxx_compiler_flag("-Wall" CXX_COMPILER_FLAG_WALL)
|
||||
if(CXX_COMPILER_FLAG_WALL)
|
||||
check_c_compiler_flag("-Wall" C_COMPILER_FLAG_WALL)
|
||||
if(C_COMPILER_FLAG_WALL)
|
||||
add_compile_options("-Wall")
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag("-Wextra" CXX_COMPILER_FLAG_WEXTRA)
|
||||
if(CXX_COMPILER_FLAG_WEXTRA)
|
||||
check_c_compiler_flag("-Wextra" C_COMPILER_FLAG_WEXTRA)
|
||||
if(C_COMPILER_FLAG_WEXTRA)
|
||||
add_compile_options("-Wextra")
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag("-Wpedantic" CXX_COMPILER_FLAG_WPEDANTIC)
|
||||
if(CXX_COMPILER_FLAG_WPEDANTIC)
|
||||
check_c_compiler_flag("-Wpedantic" C_COMPILER_FLAG_WPEDANTIC)
|
||||
if(C_COMPILER_FLAG_WPEDANTIC)
|
||||
add_compile_options("-Wpedantic")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ZINT_DEBUG)
|
||||
check_cxx_compiler_flag("-g" CXX_COMPILER_FLAG_G)
|
||||
if(CXX_COMPILER_FLAG_G)
|
||||
check_c_compiler_flag("-g" C_COMPILER_FLAG_G)
|
||||
if(C_COMPILER_FLAG_G)
|
||||
add_compile_options("-g")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ZINT_NOOPT)
|
||||
check_cxx_compiler_flag("-O0" CXX_COMPILER_FLAG_O0)
|
||||
if(CXX_COMPILER_FLAG_O0)
|
||||
check_c_compiler_flag("-O0" C_COMPILER_FLAG_O0)
|
||||
if(C_COMPILER_FLAG_O0)
|
||||
add_compile_options("-O0")
|
||||
endif()
|
||||
endif()
|
||||
@@ -82,19 +82,19 @@ if(ZINT_SANITIZE)
|
||||
set(SANITIZERS address undefined)
|
||||
foreach(sanitizer IN ITEMS ${SANITIZERS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES -fsanitize=${sanitizer})
|
||||
check_cxx_compiler_flag(-fsanitize=${sanitizer} CXX_COMPILER_FLAG_FSANITIZE_${sanitizer})
|
||||
if(CXX_COMPILER_FLAG_FSANITIZE_${sanitizer})
|
||||
check_c_compiler_flag(-fsanitize=${sanitizer} C_COMPILER_FLAG_FSANITIZE_${sanitizer})
|
||||
if(C_COMPILER_FLAG_FSANITIZE_${sanitizer})
|
||||
add_compile_options(-fsanitize=${sanitizer})
|
||||
link_libraries(-fsanitize=${sanitizer})
|
||||
endif()
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
endforeach()
|
||||
|
||||
if(NOT ZINT_DEBUG AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if(NOT ZINT_DEBUG AND CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
# Gives warning on MainWindow::setupUI() and retries (& takes forever) if var-tracking-assignments enabled
|
||||
add_compile_options(-fno-var-tracking-assignments)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# Recent clangs added deprecation warnings for `sprintf()` that are only triggered on sanitize - suppress
|
||||
add_compile_options(-Wno-deprecated-declarations)
|
||||
endif()
|
||||
@@ -107,14 +107,14 @@ endif()
|
||||
|
||||
if(ZINT_COVERAGE)
|
||||
set(CMAKE_REQUIRED_LIBRARIES -fprofile-arcs)
|
||||
check_cxx_compiler_flag(--coverage CXX_COMPILER_FLAG_COVERAGE)
|
||||
check_c_compiler_flag(--coverage C_COMPILER_FLAG_COVERAGE)
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
if(CXX_COMPILER_FLAG_COVERAGE)
|
||||
if(C_COMPILER_FLAG_COVERAGE)
|
||||
add_compile_options(--coverage)
|
||||
link_libraries(-fprofile-arcs)
|
||||
|
||||
check_cxx_compiler_flag(-O0 CXX_COMPILER_FLAG_O0)
|
||||
if(CXX_COMPILER_FLAG_O0)
|
||||
check_c_compiler_flag(-O0 C_COMPILER_FLAG_O0)
|
||||
if(C_COMPILER_FLAG_O0)
|
||||
add_compile_options(-O0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user