mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-09 02:31:21 +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)
|
project(test)
|
||||||
|
|
||||||
option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF)
|
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)
|
add_executable(hello_world hello_world.cpp)
|
||||||
|
|
||||||
@ -13,5 +17,6 @@ foreach(LANG ${LANGS})
|
|||||||
test_${LANG} PRIVATE
|
test_${LANG} PRIVATE
|
||||||
$<$<STREQUAL:"${LANG}","c">:IS_C>
|
$<$<STREQUAL:"${LANG}","c">:IS_C>
|
||||||
$<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>
|
$<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>
|
||||||
|
$<$<BOOL:${CHECK_SURPASS_WARNING}>:CHECK_SURPASS_WARNING>
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#ifdef CHECK_SURPASS_WARNING
|
||||||
|
int unused;
|
||||||
|
#endif
|
||||||
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
||||||
PRINT("compiler is not clang");
|
PRINT("compiler is not clang");
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user