mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-20 10:41:21 +00:00
add option to check if using clang for test_c
and test_cpp
targets
This commit is contained in:
parent
085f486acb
commit
1615d1b12a
@ -4,6 +4,8 @@ project(test)
|
|||||||
option(BUILD_C "build hello world in C Language" OFF)
|
option(BUILD_C "build hello world in C Language" OFF)
|
||||||
option(BUILD_CXX "build hello world in CXX Language" ON)
|
option(BUILD_CXX "build hello world in CXX Language" ON)
|
||||||
|
|
||||||
|
option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF)
|
||||||
|
|
||||||
if(BUILD_C)
|
if(BUILD_C)
|
||||||
add_executable(hello_world_c hello_world.c)
|
add_executable(hello_world_c hello_world.c)
|
||||||
endif()
|
endif()
|
||||||
@ -13,4 +15,7 @@ if(BUILD_CXX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(test_c EXCLUDE_FROM_ALL test.c)
|
add_executable(test_c EXCLUDE_FROM_ALL test.c)
|
||||||
|
target_compile_definitions(test_c PRIVATE $<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>)
|
||||||
|
|
||||||
add_executable(test_cpp EXCLUDE_FROM_ALL test.cpp)
|
add_executable(test_cpp EXCLUDE_FROM_ALL test.cpp)
|
||||||
|
target_compile_definitions(test_cpp PRIVATE $<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
||||||
|
printf("compiler is not clang\n");
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
printf("all ok\n");
|
printf("all ok\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
||||||
|
std::cout << "compiler is not clang" << std::endl;
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
std::cout << "all ok" << std::endl;
|
std::cout << "all ok" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user