mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-08 18:21:20 +00:00
merge file and configuration for test_c
and test_cpp
This commit is contained in:
parent
0971b49fe1
commit
ab9af67ec9
@ -5,8 +5,13 @@ option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF)
|
||||
|
||||
add_executable(hello_world hello_world.cpp)
|
||||
|
||||
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)
|
||||
target_compile_definitions(test_cpp PRIVATE $<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>)
|
||||
list(APPEND LANGS c cpp)
|
||||
foreach(LANG ${LANGS})
|
||||
configure_file(test.in ${CMAKE_CURRENT_BINARY_DIR}/test.${LANG})
|
||||
add_executable(test_${LANG} EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR}/test.${LANG})
|
||||
target_compile_definitions(
|
||||
test_${LANG} PRIVATE
|
||||
$<$<STREQUAL:"${LANG}","c">:IS_C>
|
||||
$<$<BOOL:${CHECK_USING_CLANG}>:CHECK_USING_CLANG>
|
||||
)
|
||||
endforeach()
|
||||
|
10
test/test.c
10
test/test.c
@ -1,10 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
||||
printf("compiler is not clang\n");
|
||||
return 1;
|
||||
#endif
|
||||
printf("all ok\n");
|
||||
return 0;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
return 0;
|
||||
}
|
16
test/test.in
Normal file
16
test/test.in
Normal file
@ -0,0 +1,16 @@
|
||||
#ifdef IS_C
|
||||
#include <stdio.h>
|
||||
#define PRINT(STR) printf(STR); printf("\n")
|
||||
#else
|
||||
#include <iostream>
|
||||
#define PRINT(STR) std::cout << STR << std::endl
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
#if defined(CHECK_USING_CLANG) && !defined(__clang__)
|
||||
PRINT("compiler is not clang");
|
||||
return 1;
|
||||
#endif
|
||||
PRINT("all ok");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user