string: add APPEND subcommand

This commit is contained in:
Daniel Pfeifer
2015-07-06 22:28:04 +02:00
committed by Brad King
parent 7e86f567ac
commit 2b18cdcaba
9 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
set(out)
string(APPEND out)
if(DEFINED out)
message(FATAL_ERROR "\"string(APPEND out)\" set out to \"${out}\"")
endif()
set(out "")
string(APPEND out)
if(NOT out STREQUAL "")
message(FATAL_ERROR "\"string(APPEND out)\" set out to \"${out}\"")
endif()
set(out x)
string(APPEND out)
if(NOT out STREQUAL "x")
message(FATAL_ERROR "\"string(APPEND out)\" set out to \"${out}\"")
endif()
set(out)
string(APPEND out a)
if(NOT out STREQUAL "a")
message(FATAL_ERROR "\"string(APPEND out a)\" set out to \"${out}\"")
endif()
set(out "")
string(APPEND out a)
if(NOT out STREQUAL "a")
message(FATAL_ERROR "\"string(APPEND out a)\" set out to \"${out}\"")
endif()
set(out x)
string(APPEND out a)
if(NOT out STREQUAL "xa")
message(FATAL_ERROR "\"string(APPEND out a)\" set out to \"${out}\"")
endif()
set(out x)
string(APPEND out a "b")
if(NOT out STREQUAL "xab")
message(FATAL_ERROR "\"string(APPEND out a \"b\")\" set out to \"${out}\"")
endif()
set(b)
set(out x)
string(APPEND out ${b})
if(NOT out STREQUAL "x")
message(FATAL_ERROR "\"string(APPEND out \${b})\" set out to \"${out}\"")
endif()
set(b b)
set(out x)
string(APPEND out a "${b}" [[
${c}]])
if(NOT out STREQUAL "xab\${c}")
message(FATAL_ERROR "\"string(APPEND out a \"\${b}\" [[\${c}]])\" set out to \"${out}\"")
endif()

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,4 @@
CMake Error at AppendNoArgs.cmake:1 \(string\):
string sub-command APPEND requires at least one argument.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -0,0 +1 @@
string(APPEND)

View File

@@ -1,5 +1,8 @@
include(RunCMake)
run_cmake(Append)
run_cmake(AppendNoArgs)
run_cmake(Concat)
run_cmake(ConcatNoArgs)