[cmake-commits] king committed CMakeLists.txt 1.14 1.15
check_command_line.c.in NONE 1.1
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Sep 21 16:11:28 EDT 2006
Update of /cvsroot/CMake/CMake/Tests/CustomCommand
In directory public:/mounts/ram/cvs-serv22865
Modified Files:
CMakeLists.txt
Added Files:
check_command_line.c.in
Log Message:
ENH: Adding test for non-trivial custom command line arguments. This is for bug#3786.
--- NEW FILE: check_command_line.c.in ---
#include <stdio.h>
const char* expected_arguments[] =
{
@EXPECTED_ARGUMENTS@ 0
};
int main(int argc, const char* argv[])
{
const char** a = argv+1;
const char** e = expected_arguments;
(void)argc;
for(;*a && *e; ++a, ++e)
{
if(strcmp(*a, *e) != 0)
{
fprintf(stderr, "Argument [%s] does not match expected [%s].\n",
*a, *e);
return 1;
}
else
{
printf("[%s]\n", *a);
}
}
if(*a || *e)
{
fprintf(stderr, "Number of arguments does not match expected.\n");
return 1;
}
return 0;
}
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CustomCommand/CMakeLists.txt,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CMakeLists.txt 1 Jun 2006 17:01:31 -0000 1.14
+++ CMakeLists.txt 21 Sep 2006 20:11:25 -0000 1.15
@@ -164,3 +164,42 @@
# the CustomCommand executable really needs doc1.h
ADD_DEPENDENCIES(CustomCommand TDocument)
+##############################################################################
+# Test non-trivial command line arguments in custom commands.
+SET(EXPECTED_ARGUMENTS)
+SET(CHECK_ARGS
+ c:/posix/path
+ c:\\windows\\path
+ 'single-quotes'
+ single'quote
+ \"double-quotes\"
+ double\"quote
+ "\\;semi-colons\\;"
+ "semi\\;colon"
+ "c:/posix/path/with space"
+ "c:\\windows\\path\\with space"
+ "'single quotes with space'"
+ "single'quote with space"
+ "\"double-quotes with space\""
+ "double\"quote with space"
+ "\\;semi-colons with space\\;"
+ "semi\\;colon with space"
+ )
+FOREACH(arg ${CHECK_ARGS})
+ SET(ARG "${arg}")
+ STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}")
+ STRING(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}")
+ SET(EXPECTED_ARGUMENTS
+ "${EXPECTED_ARGUMENTS} \"${ARG}\",
+")
+ENDFOREACH(arg)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in
+ ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c
+ @ONLY IMMEDIATE)
+ADD_EXECUTABLE(check_command_line
+ ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c)
+ADD_CUSTOM_TARGET(do_check_command_line ALL
+ COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line
+ ${CHECK_ARGS}
+ )
+ADD_DEPENDENCIES(do_check_command_line check_command_line)
More information about the Cmake-commits
mailing list