2003-06-03 18:34:15 +04:00
|
|
|
#
|
|
|
|
# Wrapping
|
|
|
|
#
|
2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2012-08-13 21:47:32 +04:00
|
|
|
project (CustomCommand)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_subdirectory(GeneratedHeader)
|
2006-01-09 22:40:31 +03:00
|
|
|
|
2003-06-03 18:34:15 +04:00
|
|
|
#
|
|
|
|
# Lib and exe path
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT DEFINED bin_dir)
|
|
|
|
set(bin_dir "bin")
|
|
|
|
endif()
|
2010-09-12 13:01:35 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set (LIBRARY_OUTPUT_PATH
|
2010-09-12 13:01:35 +04:00
|
|
|
${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL
|
2003-06-30 18:12:24 +04:00
|
|
|
"Single output directory for building all libraries.")
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set (EXECUTABLE_OUTPUT_PATH
|
2010-09-12 13:01:35 +04:00
|
|
|
${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL
|
2003-06-30 18:12:24 +04:00
|
|
|
"Single output directory for building all executables.")
|
2003-06-03 18:34:15 +04:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
#
|
|
|
|
# First test using a compiled generator to create a .c file
|
|
|
|
#
|
|
|
|
################################################################
|
|
|
|
# add the executable that will generate the file
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(generator generator.cxx)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_target_property(generator_PATH generator LOCATION)
|
|
|
|
message("Location ${generator_PATH}")
|
2004-04-27 20:03:17 +04:00
|
|
|
|
2003-06-03 18:34:15 +04:00
|
|
|
################################################################
|
|
|
|
#
|
|
|
|
# Test using a wrapper to wrap a header file
|
|
|
|
#
|
|
|
|
################################################################
|
|
|
|
# add the executable that will generate the file
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(wrapper wrapper.cxx)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2006-04-11 19:06:19 +04:00
|
|
|
OUTPUT ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c
|
2003-06-30 18:12:24 +04:00
|
|
|
DEPENDS wrapper
|
|
|
|
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/wrapped.h
|
|
|
|
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/wrapper
|
2006-04-11 19:06:19 +04:00
|
|
|
${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c
|
2008-06-04 20:10:59 +04:00
|
|
|
${CMAKE_CFG_INTDIR} # this argument tests passing of the configuration
|
|
|
|
VERBATIM # passing of configuration should work in this mode
|
2003-06-30 18:12:24 +04:00
|
|
|
)
|
|
|
|
|
2003-06-03 18:34:15 +04:00
|
|
|
################################################################
|
|
|
|
#
|
|
|
|
# Test creating files from a custom target
|
|
|
|
#
|
|
|
|
################################################################
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}//doc1.dvi # test 2 slashes
|
2012-08-13 21:42:58 +04:00
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/doc1.tex
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E copy ${PROJECT_SOURCE_DIR}/doc1.tex
|
2003-06-30 18:12:24 +04:00
|
|
|
${PROJECT_BINARY_DIR}/doc1.dvi
|
|
|
|
)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h
|
2005-04-26 19:55:20 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1.dvi to doc1temp.h."
|
2005-02-22 20:04:02 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.dvi
|
|
|
|
${PROJECT_BINARY_DIR}/doc1temp.h
|
2006-10-04 23:24:26 +04:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h APPEND
|
2006-10-04 23:24:26 +04:00
|
|
|
DEPENDS ${PROJECT_BINARY_DIR}/doc1.dvi
|
2005-04-26 19:55:20 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1temp.h to doc1.h."
|
2005-02-22 20:04:02 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1temp.h
|
|
|
|
${PROJECT_BINARY_DIR}/doc1.h
|
2005-04-26 19:55:20 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Removing doc1temp.h."
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/doc1temp.h
|
2003-06-30 18:12:24 +04:00
|
|
|
)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2005-08-17 19:48:05 +04:00
|
|
|
# Add custom command to generate foo.h.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/foo.h
|
2005-08-17 19:48:05 +04:00
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/foo.h.in
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Copying foo.h.in to foo.h."
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/foo.h.in
|
|
|
|
${PROJECT_BINARY_DIR}/foo.h
|
|
|
|
)
|
|
|
|
|
|
|
|
# Add the location of foo.h to the include path.
|
2012-08-13 21:47:32 +04:00
|
|
|
include_directories(${PROJECT_BINARY_DIR})
|
2005-08-17 19:48:05 +04:00
|
|
|
|
2008-08-05 21:27:14 +04:00
|
|
|
# Test generation of a file to the build tree without full path. As
|
|
|
|
# of CMake 2.6 custom command outputs specified by relative path go in
|
|
|
|
# the build tree.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2008-08-05 21:27:14 +04:00
|
|
|
OUTPUT doc1.txt
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Example Document Target" > doc1.txt
|
|
|
|
DEPENDS doc1.tex
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2005-04-26 19:55:20 +04:00
|
|
|
# Add a custom target to drive generation of doc1.h.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_target(TDocument ALL
|
2005-04-26 19:55:20 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1.h to doc2.h."
|
2005-02-22 20:04:02 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.h
|
|
|
|
${PROJECT_BINARY_DIR}/doc2.h
|
2011-03-30 17:52:07 +04:00
|
|
|
DEPENDS doc1.txt ${PROJECT_BINARY_DIR}//doc1.h # test 2 slashes
|
2006-10-05 02:10:30 +04:00
|
|
|
COMMENT "Running top-level TDocument commands"
|
2008-10-09 19:01:23 +04:00
|
|
|
SOURCES doc1.tex
|
2005-02-22 20:04:02 +03:00
|
|
|
)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2005-04-26 19:55:20 +04:00
|
|
|
# Setup a pre- and post-build pair that will fail if not run in the
|
|
|
|
# proper order.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2005-04-26 19:55:20 +04:00
|
|
|
TARGET TDocument PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Writing doc1pre.txt."
|
2005-04-27 17:12:41 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/doc1.tex ${PROJECT_BINARY_DIR}/doc1pre.txt
|
2007-12-18 17:50:08 +03:00
|
|
|
COMMENT "Running TDocument pre-build commands"
|
2005-04-26 19:55:20 +04:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2005-04-26 19:55:20 +04:00
|
|
|
TARGET TDocument POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1pre.txt to doc2post.txt."
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1pre.txt
|
|
|
|
${PROJECT_BINARY_DIR}/doc2post.txt
|
2007-12-18 17:50:08 +03:00
|
|
|
COMMENT "Running TDocument post-build commands"
|
2005-04-26 19:55:20 +04:00
|
|
|
)
|
|
|
|
|
2013-04-04 01:03:43 +04:00
|
|
|
# Setup a custom target that will fail if the POST_BUILD custom command
|
|
|
|
# isn't run before it.
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT doc3post.txt
|
|
|
|
DEPENDS ${PROJECT_BINARY_DIR}/doc2post.txt
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo " Copying doc2pre.txt to doc3post.txt."
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc2post.txt
|
|
|
|
${PROJECT_BINARY_DIR}/doc3post.txt
|
|
|
|
COMMENT "Running TDocument post-build dependent custom command"
|
|
|
|
)
|
|
|
|
add_custom_target(doc3Post ALL DEPENDS doc3post.txt)
|
|
|
|
add_dependencies(doc3Post TDocument)
|
|
|
|
|
2003-06-03 18:34:15 +04:00
|
|
|
################################################################
|
|
|
|
#
|
|
|
|
# Test using a multistep generated file
|
|
|
|
#
|
|
|
|
################################################################
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/foo.pre
|
2003-06-30 18:12:24 +04:00
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/foo.in
|
2010-12-09 01:05:23 +03:00
|
|
|
TDocument # Ensure doc1.h generates before this target
|
2012-08-13 21:42:58 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E copy ${PROJECT_SOURCE_DIR}/foo.in
|
2003-06-30 18:12:24 +04:00
|
|
|
${PROJECT_BINARY_DIR}/foo.pre
|
|
|
|
)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/foo.c
|
2012-08-13 21:42:58 +04:00
|
|
|
DEPENDS ${PROJECT_BINARY_DIR}/foo.pre
|
2003-06-30 18:12:24 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E copy ${PROJECT_BINARY_DIR}/foo.pre
|
|
|
|
${PROJECT_BINARY_DIR}/foo.c
|
|
|
|
)
|
2003-06-03 18:34:15 +04:00
|
|
|
|
2006-06-01 21:01:31 +04:00
|
|
|
# Add custom command to generate not_included.h, which is a header
|
|
|
|
# file that is not included by any source in this project. This will
|
|
|
|
# test whether all custom command outputs explicitly listed as sources
|
|
|
|
# get generated even if they are not needed by an object file.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/not_included.h
|
2006-06-01 21:01:31 +04:00
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/foo.h.in
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/foo.h.in
|
|
|
|
${PROJECT_BINARY_DIR}/not_included.h
|
|
|
|
)
|
|
|
|
|
|
|
|
# Tell the executable where to find not_included.h.
|
2012-08-13 21:47:32 +04:00
|
|
|
configure_file(
|
2006-06-01 21:01:31 +04:00
|
|
|
${PROJECT_SOURCE_DIR}/config.h.in
|
|
|
|
${PROJECT_BINARY_DIR}/config.h
|
2013-11-13 12:50:56 +04:00
|
|
|
@ONLY
|
2006-06-01 21:01:31 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
# add the executable
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(CustomCommand
|
2006-03-24 20:20:46 +03:00
|
|
|
${PROJECT_BINARY_DIR}/foo.h
|
2003-06-03 18:34:15 +04:00
|
|
|
${PROJECT_BINARY_DIR}/foo.c
|
|
|
|
${PROJECT_BINARY_DIR}/wrapped.c
|
2006-04-11 19:06:19 +04:00
|
|
|
${PROJECT_BINARY_DIR}/wrapped_help.c
|
2003-06-03 18:34:15 +04:00
|
|
|
${PROJECT_BINARY_DIR}/generated.c
|
2006-06-01 21:01:31 +04:00
|
|
|
${PROJECT_BINARY_DIR}/not_included.h
|
2008-04-29 23:34:49 +04:00
|
|
|
gen_redirect.c # default location for custom commands is in build tree
|
2003-06-03 18:34:15 +04:00
|
|
|
)
|
|
|
|
|
2007-06-11 21:22:17 +04:00
|
|
|
# Add the rule to create generated.c at build time. This is placed
|
|
|
|
# here to test adding the generation rule after referencing the
|
|
|
|
# generated source in a target.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c
|
2007-06-11 21:22:17 +04:00
|
|
|
DEPENDS generator
|
|
|
|
COMMAND ${generator_PATH}
|
|
|
|
ARGS ${PROJECT_BINARY_DIR}/generated.c
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
target_link_libraries(CustomCommand GeneratedHeader)
|
2006-01-09 22:40:31 +03:00
|
|
|
|
2007-05-09 16:25:45 +04:00
|
|
|
##############################################################################
|
|
|
|
# Test for using just the target name as executable in the COMMAND
|
|
|
|
# section. Has to be recognized and replaced by CMake with the output
|
|
|
|
# actual location of the executable.
|
2012-08-13 21:42:58 +04:00
|
|
|
# Additionally the generator is created in an extra subdir after the
|
2012-08-13 21:47:32 +04:00
|
|
|
# add_custom_command() is used.
|
2007-05-09 16:25:45 +04:00
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
# Test the same for add_custom_target()
|
2007-05-09 16:25:45 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx
|
2007-05-09 16:25:45 +04:00
|
|
|
COMMAND generator_extern ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(CustomCommandUsingTargetTest main.cxx ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx )
|
2007-05-09 16:25:45 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_target(RunTarget
|
2007-05-09 16:25:45 +04:00
|
|
|
COMMAND generator_extern ${CMAKE_CURRENT_BINARY_DIR}/run_target.cxx
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(TARGET CustomCommandUsingTargetTest POST_BUILD
|
2007-05-09 16:25:45 +04:00
|
|
|
COMMAND dummy_generator ${CMAKE_CURRENT_BINARY_DIR}/generated_dummy.cxx)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_subdirectory(GeneratorInExtraDir)
|
2007-05-09 16:25:45 +04:00
|
|
|
|
2008-04-29 23:34:49 +04:00
|
|
|
##############################################################################
|
|
|
|
# Test shell operators in custom commands.
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(tcat tcat.cxx)
|
2008-04-29 23:34:49 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(OUTPUT gen_redirect.c
|
2008-04-29 23:34:49 +04:00
|
|
|
DEPENDS tcat gen_redirect_in.c
|
|
|
|
COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c
|
|
|
|
VERBATIM
|
|
|
|
)
|
2007-05-09 16:25:45 +04:00
|
|
|
|
2006-09-22 00:11:25 +04:00
|
|
|
##############################################################################
|
|
|
|
# Test non-trivial command line arguments in custom commands.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(EXPECTED_ARGUMENTS)
|
|
|
|
set(CHECK_ARGS)
|
|
|
|
if(NOT MSVC71)
|
|
|
|
set(CHECK_ARGS -DPATH=c:/posix/path)
|
|
|
|
endif()
|
|
|
|
set(CHECK_ARGS
|
2010-09-20 21:20:15 +04:00
|
|
|
${CHECK_ARGS}
|
2006-09-22 00:11:25 +04:00
|
|
|
c:/posix/path
|
|
|
|
c:\\windows\\path
|
|
|
|
'single-quotes'
|
|
|
|
single'quote
|
|
|
|
\"double-quotes\"
|
|
|
|
"\\;semi-colons\\;"
|
|
|
|
"semi\\;colon"
|
2006-09-28 19:30:49 +04:00
|
|
|
`back-ticks`
|
|
|
|
back`tick
|
|
|
|
"(parens)"
|
|
|
|
"(lparen"
|
|
|
|
"rparen)"
|
2007-05-17 18:53:18 +04:00
|
|
|
{curly}
|
|
|
|
{lcurly}
|
|
|
|
rcurly}
|
2008-04-30 23:58:45 +04:00
|
|
|
<angle>
|
|
|
|
<langle
|
|
|
|
rangle>
|
2007-05-17 18:53:18 +04:00
|
|
|
[square]
|
|
|
|
[lsquare # these have funny behavior due to special cases for
|
|
|
|
rsquare] # windows registry value names in list expansion
|
2006-09-28 19:30:49 +04:00
|
|
|
$dollar-signs$
|
|
|
|
dollar$sign
|
2008-04-30 23:58:45 +04:00
|
|
|
&ersands&x # Borland make does not like trailing ampersand
|
2007-05-17 18:53:18 +04:00
|
|
|
one&ersand
|
2006-10-04 22:37:42 +04:00
|
|
|
@two-ats@
|
2006-09-28 19:30:49 +04:00
|
|
|
one@at
|
2007-05-17 18:53:18 +04:00
|
|
|
~two-tilda~
|
|
|
|
one~tilda
|
|
|
|
^two-carrots^
|
|
|
|
one^carrot
|
|
|
|
%two-percents%
|
|
|
|
one%percent
|
|
|
|
!two-exclamations!
|
|
|
|
one!exclamation
|
|
|
|
?two-questions?
|
|
|
|
one?question
|
|
|
|
*two-stars*
|
|
|
|
one*star
|
|
|
|
=two+equals=
|
|
|
|
one=equals
|
|
|
|
_two-underscores_
|
|
|
|
one_underscore
|
|
|
|
,two-commas,
|
|
|
|
one,comma
|
|
|
|
.two-periods.
|
|
|
|
one.period
|
|
|
|
|two-pipes|
|
|
|
|
one|pipe
|
2007-05-17 22:03:31 +04:00
|
|
|
|nopipe
|
2006-10-25 19:23:23 +04:00
|
|
|
"#two-pounds#"
|
|
|
|
"one#pound"
|
2007-05-17 22:03:31 +04:00
|
|
|
"#nocomment"
|
2006-09-22 00:11:25 +04:00
|
|
|
"c:/posix/path/with space"
|
|
|
|
"c:\\windows\\path\\with space"
|
|
|
|
"'single quotes with space'"
|
|
|
|
"single'quote with space"
|
|
|
|
"\"double-quotes with space\""
|
2007-05-18 17:33:59 +04:00
|
|
|
"\\;semi-colons w s\\;"
|
|
|
|
"semi\\;colon w s"
|
|
|
|
"`back-ticks` w s"
|
|
|
|
"back`tick w s"
|
|
|
|
"(parens) w s"
|
|
|
|
"(lparen w s"
|
|
|
|
"rparen) w s"
|
|
|
|
"{curly} w s"
|
|
|
|
"{lcurly w s"
|
|
|
|
"rcurly} w s"
|
2008-04-30 23:58:45 +04:00
|
|
|
"<angle> w s"
|
|
|
|
"<langle w s"
|
|
|
|
"rangle> w s"
|
2007-05-18 17:33:59 +04:00
|
|
|
"[square] w s"
|
|
|
|
"[lsquare w s" # these have funny behavior due to special cases for
|
|
|
|
"rsquare] w s" # windows registry value names in list expansion
|
|
|
|
"$dollar-signs$ w s"
|
|
|
|
"dollar$sign w s"
|
|
|
|
"&ersands& w s"
|
|
|
|
"one&ersand w s"
|
|
|
|
"@two-ats@ w s"
|
|
|
|
"one@at w s"
|
|
|
|
"~two-tilda~ w s"
|
|
|
|
"one~tilda w s"
|
|
|
|
"^two-carrots^ w s"
|
|
|
|
"one^carrot w s"
|
|
|
|
"%two-percents% w s"
|
|
|
|
"one%percent w s"
|
|
|
|
"!two-exclamations! w s"
|
|
|
|
"one!exclamation w s"
|
|
|
|
"*two-stars* w s"
|
|
|
|
"one*star w s"
|
|
|
|
"=two+equals= w s"
|
|
|
|
"one=equals w s"
|
|
|
|
"_two-underscores_ w s"
|
|
|
|
"one_underscore w s"
|
|
|
|
"?two-questions? w s"
|
|
|
|
"one?question w s"
|
|
|
|
",two-commas, w s"
|
|
|
|
"one,comma w s"
|
|
|
|
".two-periods. w s"
|
|
|
|
"one.period w s"
|
|
|
|
"|two-pipes| w s"
|
|
|
|
"one|pipe w s"
|
|
|
|
"#two-pounds# w s"
|
|
|
|
"one#pound w s"
|
2008-04-29 23:34:49 +04:00
|
|
|
~ ` ! @ \# $ % ^ & _ - + = : "\;" \" ' , . ? "(" ")" { } []
|
2006-09-22 00:11:25 +04:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT MINGW)
|
2007-05-17 22:32:14 +04:00
|
|
|
# * # MinGW programs on windows always expands the wildcard!
|
|
|
|
# / # MSys make converts a leading slash to the mingw home directory
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND CHECK_ARGS * /)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-04-30 23:58:45 +04:00
|
|
|
|
|
|
|
# The windows command shell does not support a double quote by itself:
|
|
|
|
# double\"quote
|
|
|
|
# without messing up quoting of arguments following it.
|
|
|
|
|
|
|
|
# Make tools need help with escaping a single backslash
|
|
|
|
# \
|
|
|
|
# at the end of a command because they think it is a continuation
|
|
|
|
# character.
|
|
|
|
|
|
|
|
# We now have special cases for shell operators:
|
|
|
|
# | < > << >> &> 2>&1 1>&2
|
|
|
|
# to allow custom commands to perform redirection.
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(arg ${CHECK_ARGS} "")
|
|
|
|
set(ARG "${arg}")
|
|
|
|
string(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}")
|
|
|
|
string(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}")
|
|
|
|
set(EXPECTED_ARGUMENTS
|
2006-09-22 00:11:25 +04:00
|
|
|
"${EXPECTED_ARGUMENTS} \"${ARG}\",
|
|
|
|
")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in
|
2006-09-22 00:11:25 +04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c
|
2013-11-13 12:50:56 +04:00
|
|
|
@ONLY)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(check_command_line
|
2006-09-22 00:11:25 +04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(output_name "check_command_line")
|
|
|
|
set_property(TARGET check_command_line
|
2010-09-12 13:01:35 +04:00
|
|
|
PROPERTY OUTPUT_NAME ${output_name})
|
2012-08-13 21:47:32 +04:00
|
|
|
# set_target_properties(check_command_line PROPERTIES
|
2007-05-18 17:18:09 +04:00
|
|
|
# COMPILE_FLAGS -DCHECK_COMMAND_LINE_VERBOSE)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2006-09-28 19:30:49 +04:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/command_line_check
|
2007-05-01 22:12:56 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake
|
2010-09-12 13:01:35 +04:00
|
|
|
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name}
|
2008-12-18 21:36:58 +03:00
|
|
|
${CHECK_ARGS} ""
|
2006-09-28 19:30:49 +04:00
|
|
|
VERBATIM
|
2006-10-05 02:57:59 +04:00
|
|
|
COMMENT "Checking custom command line escapes (single'quote)"
|
2006-09-28 19:30:49 +04:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/command_line_check
|
2006-10-02 18:17:22 +04:00
|
|
|
PROPERTIES SYMBOLIC 1)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_target(do_check_command_line ALL
|
2006-09-28 19:30:49 +04:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes"
|
2010-09-12 13:01:35 +04:00
|
|
|
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name}
|
2008-12-18 21:36:58 +03:00
|
|
|
${CHECK_ARGS} ""
|
2006-09-28 19:30:49 +04:00
|
|
|
VERBATIM
|
2006-10-05 02:57:59 +04:00
|
|
|
COMMENT "Checking custom target command line escapes ($dollar-signs$)"
|
2006-09-22 00:11:25 +04:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_dependencies(do_check_command_line check_command_line)
|
2007-05-01 22:12:56 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_target(pre_check_command_line
|
2007-05-01 22:12:56 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_dependencies(do_check_command_line pre_check_command_line)
|
2009-09-25 21:23:19 +04:00
|
|
|
|
|
|
|
# <SameNameTest>
|
|
|
|
#
|
|
|
|
# Add a custom target called "SameName" -- then add a custom command in a
|
|
|
|
# different target whose output is a full-path file called "SameName" -- then
|
|
|
|
# add a second custom target that depends on the full-path file ".../SameName"
|
|
|
|
#
|
|
|
|
# At first, this reproduces a bug reported by a customer. After fixing it,
|
|
|
|
# having this test here makes sure it stays fixed moving forward.
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2009-09-25 21:23:19 +04:00
|
|
|
OUTPUT SameName1.txt
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E touch SameName1.txt
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_target(SameName ALL
|
2009-09-25 21:23:19 +04:00
|
|
|
DEPENDS SameName1.txt
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_command(
|
2009-09-25 21:23:19 +04:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName
|
2009-09-25 21:36:08 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/subdir
|
2009-09-25 21:23:19 +04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
add_custom_target(DifferentName ALL
|
2009-09-25 21:23:19 +04:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName
|
|
|
|
)
|
|
|
|
#
|
|
|
|
# </SameNameTest>
|
2010-12-09 00:13:07 +03:00
|
|
|
|
|
|
|
# Per-config target name and generator expressions.
|
2012-08-13 21:47:32 +04:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../PerConfig PerConfig)
|
|
|
|
add_custom_command(
|
2010-12-09 00:13:07 +03:00
|
|
|
OUTPUT perconfig.out
|
|
|
|
COMMAND ${PerConfig_COMMAND}
|
|
|
|
DEPENDS ${PerConfig_DEPENDS}
|
|
|
|
VERBATIM
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
set_property(SOURCE perconfig.out PROPERTY SYMBOLIC 1)
|
|
|
|
add_custom_target(perconfig_target ALL
|
2010-12-09 00:13:07 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "perconfig=$<TARGET_FILE:perconfig>" "config=$<CONFIGURATION>"
|
|
|
|
DEPENDS perconfig.out)
|
2013-10-27 01:38:38 +04:00
|
|
|
|
|
|
|
# Test SOURCES in add_custom_target() with COMPILE_DEFINITIONS
|
|
|
|
# which previously caused a crash in the makefile generators.
|
|
|
|
add_custom_target(source_in_custom_target SOURCES source_in_custom_target.cpp)
|
|
|
|
set_property(SOURCE source_in_custom_target
|
|
|
|
PROPERTY COMPILE_DEFINITIONS "TEST"
|
|
|
|
)
|