mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-21 11:01:20 +00:00
add option in test target to check if it could surpass a compiler warning
This commit is contained in:
parent
830ed408e9
commit
98b40bce3e
@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.0)
|
||||
project(test)
|
||||
|
||||
option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF)
|
||||
option(CHECK_SURPASS_WARNING "check if target could surpass a compiler warning" OFF)
|
||||
|
||||
set(CMAKE_C_FLAGS "-Werror -Wunused-variable ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_executable(hello_world hello_world.cpp)
|
||||
|
||||
@ -13,5 +17,6 @@ foreach(LANG ${LANGS})
|
||||
test_${LANG} PRIVATE
|
||||
$<$<STREQUAL:"${LANG}","c">:IS_C>
|
||||
$<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>
|
||||
$<$<BOOL:${CHECK_SURPASS_WARNING}>:CHECK_SURPASS_WARNING>
|
||||
)
|
||||
endforeach()
|
||||
|
@ -7,6 +7,9 @@
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
#ifdef CHECK_SURPASS_WARNING
|
||||
int unused;
|
||||
#endif
|
||||
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
||||
PRINT("compiler is not clang");
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user