Tests: Split CustomTransitiveProperties argument checks into helper
This commit is contained in:
parent
99fee5720d
commit
d7f1a100d9
@ -91,6 +91,7 @@ target_compile_definitions(CustomTransitiveProperties PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements.
|
# Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements.
|
||||||
|
add_executable(check-args check-args.c)
|
||||||
set(out "${CMAKE_CURRENT_BINARY_DIR}/out-$<CONFIG>.txt")
|
set(out "${CMAKE_CURRENT_BINARY_DIR}/out-$<CONFIG>.txt")
|
||||||
file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced:
|
file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced:
|
||||||
iface1 CUSTOM_A: '$<TARGET_PROPERTY:iface1,CUSTOM_A>'
|
iface1 CUSTOM_A: '$<TARGET_PROPERTY:iface1,CUSTOM_A>'
|
||||||
@ -129,6 +130,7 @@ main INTERFACE_CUSTOM_W: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE
|
|||||||
add_custom_target(check ALL VERBATIM
|
add_custom_target(check ALL VERBATIM
|
||||||
COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIG> -Dout=${out} -P${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
|
COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIG> -Dout=${out} -P${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
|
||||||
COMMAND CustomTransitiveProperties
|
COMMAND CustomTransitiveProperties
|
||||||
|
COMMAND check-args
|
||||||
"$<TARGET_PROPERTY:static1,CUSTOM_A>" "CUSTOM_A_STATIC1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_STATIC1"
|
"$<TARGET_PROPERTY:static1,CUSTOM_A>" "CUSTOM_A_STATIC1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_STATIC1"
|
||||||
"$<TARGET_PROPERTY:static1,CUSTOM_B>" "CUSTOM_B_STATIC1;CUSTOM_B_IFACE1"
|
"$<TARGET_PROPERTY:static1,CUSTOM_B>" "CUSTOM_B_STATIC1;CUSTOM_B_IFACE1"
|
||||||
"$<TARGET_PROPERTY:static1,CUSTOM_U>" "CUSTOM_U_STATIC1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1"
|
"$<TARGET_PROPERTY:static1,CUSTOM_U>" "CUSTOM_U_STATIC1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1"
|
||||||
|
16
Tests/CustomTransitiveProperties/check-args.c
Normal file
16
Tests/CustomTransitiveProperties/check-args.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
int i;
|
||||||
|
for (i = 2; i < argc; i += 2) {
|
||||||
|
if (strcmp(argv[i - 1], argv[i]) != 0) {
|
||||||
|
fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, argv[i],
|
||||||
|
argv[i - 1]);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
@ -1,6 +1,3 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef CUSTOM_A_IFACE1
|
#ifdef CUSTOM_A_IFACE1
|
||||||
# error "CUSTOM_A_IFACE1 incorrectly defined"
|
# error "CUSTOM_A_IFACE1 incorrectly defined"
|
||||||
#endif
|
#endif
|
||||||
@ -117,21 +114,7 @@
|
|||||||
extern int static1(void);
|
extern int static1(void);
|
||||||
extern int object1(void);
|
extern int object1(void);
|
||||||
|
|
||||||
int check_args(int argc, char** argv)
|
int main(void)
|
||||||
{
|
{
|
||||||
int result = 0;
|
return static1() + object1();
|
||||||
int i;
|
|
||||||
for (i = 2; i < argc; i += 2) {
|
|
||||||
if (strcmp(argv[i - 1], argv[i]) != 0) {
|
|
||||||
fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, argv[i],
|
|
||||||
argv[i - 1]);
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
return static1() + object1() + check_args(argc, argv);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user