How to split strings across multiple lines in CMake? - cmake

I usually have a policy in my project, to never create lines in text files that exceed a line length of 80, so they are easily editable in all kinds of editors (you know the deal). But with CMake I get the problem that I do not know how to split a simple string into multiple lines to avoid one huge line. Consider this basic code:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")
It already exceeds the 80 column limit. So how do I break a line in CMake into multiple lines without getting to verbose (multiple list(APPEND ...) or the like)?

Update for CMake 3.0 and newer :
line continuation is possible with \. see the latest cmake docs
message("\
This is the first line of a quoted argument. \
In fact it is the only line but since it is long \
the source code uses line continuation.\
")
Availability of CMake versions:
Debian Wheezy (2013): 2.8.9
Debian Wheezy-backports: 2.8.11
Debian Jessy (2015): 3.0.2
Ubuntu 14.04 (LTS): 2.8.12
Ubuntu 15.04 : 3.0.2
Mac OSX : cmake-3 available through Homebrew, Macports and Fink
Windows: cmake-3 available through Chocolatey

CMake 3.0 and newer
Use the string(CONCAT) command:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
string(CONCAT MYPROJ_VERSION "${MYPROJ_VERSION_MAJOR}"
".${MYPROJ_VERSION_MINOR}"
".${MYPROJ_VERSION_PATCH}"
"-${MYPROJ_VERSION_EXTRA}")
Although CMake 3.0 and newer support line continuation of quoted arguments, you cannot indent the second or subsequent lines without getting the indentation whitespace included in your string.
CMake 2.8 and older
You can use a list. Each element of the list can be put on a new line:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION_LIST "${MYPROJ_VERSION_MAJOR}"
".${MYPROJ_VERSION_MINOR}"
".${MYPROJ_VERSION_PATCH}"
"-${MYPROJ_VERSION_EXTRA}")
A list used without quotes is concatenated without white-space:
message(STATUS "Version: " ${MYPROJ_VERSION_LIST})
-- Version: 1.0.0-rc1
If you really need a string, you can convert the list to a string first:
string(REPLACE ";" "" MYPROJ_VERSION "${MYPROJ_VERSION_LIST}")
message(STATUS "Version: ${MYPROJ_VERSION}")
-- Version: 1.0.0-rc1
Any semicolons in your original strings will be seen as list element separators, and removed. They must be escaped:
set(MY_LIST "Hello World "
"with a \;semicolon")

For those who were brought here from How do I split a CMake generator expression to multiple lines? I would like to add some notes.
The line continuation method will not work, CMake cannot parse a generator list made with whitespace (indentation) and line continuation.
While the string(CONCAT) solution will provide a generator expression that can be evaluated, the evaluated expression will be surrounded by quotes if the result contains a space.
For each individual option to be added a separate generator list must be constructed, so stacking options like I have done in the following will cause the build to fail:
string(CONCAT WARNING_OPTIONS "$<"
"$<OR:"
"$<CXX_COMPILER_ID:MSVC>,"
"$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>"
">:"
"/D_CRT_SECURE_NO_WARNINGS "
">$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang,GNU>,"
"$<NOT:$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>>"
">:"
"-Wall -Werror "
">$<"
"$<CXX_COMPILER_ID:GNU>:"
"-Wno-multichar -Wno-sign-compare "
">")
add_compile_options(${WARNING_OPTIONS})
This is because the resulting options are passed to the compiler in quotes
/usr/lib64/ccache/c++ -DGTEST_CREATE_SHARED_LIBRARY=1 -Dgtest_EXPORTS -I../ThirdParty/googletest/googletest/include -I../ThirdParty/googletest/googletest -std=c++11 -fno-rtti -fno-exceptions -fPIC -std=c++11 -fno-rtti -fno-exceptions -Wall -Wshadow -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers "-Wall -Werror -Wno-multichar -Wno-sign-compare " -fdiagnostics-color -MD -MT ThirdParty/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -MF ThirdParty/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o.d -o ThirdParty/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -c ../ThirdParty/googletest/googletest/src/gtest-all.cc
c++: error: unrecognized command line option ‘-Wall -Werror -Wno-multichar -Wno-sign-compare ’
To evaluate lengthy generator expressions represented using the string(CONCAT) solution, each generator expression must evaluate to a single option with no spaces:
string(CONCAT WALL "$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang,GNU>,"
"$<NOT:$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>>"
">:"
"-Wall"
">")
string(CONCAT WERROR "$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang,GNU>,"
"$<NOT:$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>>"
">:"
"-Werror"
">")
message(STATUS "Warning Options: " ${WALL} ${WERROR})
add_compile_options(${WALL} ${WERROR})
This may be unrelated to the question I am posting an answer to, unfortunately the question I am answering is wrongfully marked as a duplicate of this question.
Generator lists are not handled and parsed the same way as strings are, and because of this, there are additional measures one must take to split a generator list across multiple lines.

It's still a little verbose, but if the 80 char limit really bugs you then you could repeatedly append to the same variable:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION "${MYPROJ_VERSION_MAJOR}.")
set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_MINOR}.")
set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_PATCH}-")
set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_EXTRA}")
message(STATUS "version: ${MYPROJ_VERSION}")
Gives output:
$ cmake ~/project/tmp
-- version: 1.0.0-rc1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rsanderson/build/temp

The example in the original question is only about a relatively short string. For longer strings (including the examples given in other answers), a bracket argument could be better. From the documentation:
An opening bracket is written [ followed by zero or more = followed by [. The corresponding closing bracket is written ] followed by the same number of = followed by ]. Brackets do not nest. A unique length may always be chosen for the opening and closing brackets to contain closing brackets of other lengths.
[...]
For example:
message([=[
This is the first line in a bracket argument with bracket length 1.
No \-escape sequences or ${variable} references are evaluated.
This is always one argument even though it contains a ; character.
The text does not end on a closing bracket of length 0 like ]].
It does end in a closing bracket of length 1.
]=])

There is no way to split a string literal across multiple lines in CMakeLists.txt files or in CMake scripts. If you include a newline within a string, there will be a literal newline in the string itself.
# Don't do this, it won't work, MYPROJ_VERSION will contain newline characters:
set(MYPROJ_VERSION "${VERSION_MAJOR}.
${VERSION_MINOR}.${VERSION_PATCH}-
${VERSION_EXTRA}")
However, CMake uses whitespace to separate arguments, so you can change a space that's an argument separator into a newline anywhere you like, without changing the behavior.
You could re-phrase this longer line:
set(MYPROJ_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")
as these two shorter lines:
set(MYPROJ_VERSION
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")
They are entirely equivalent.

To maintain good indentation in your code it's straightforward enough just to do
message("These strings " "will all be "
"concatenated. Don't forget "
"your trailing spaces!")
Or form a string directly with
string(CONCAT MYSTR "This and " "that "
"and me too!")
as in Douglas' answer who has more details. However I thought this might just summarise the essential point.

Related

Cmake Error:STRING sub-command REPLACE requires at least four arguments

Cmake version:3.20.0
platform: macOS 11.1
When I tried to compiler a library with Cmake, I got the following error:
CMake Error at CMakeLists.txt:45 (STRING):
STRING sub-command REPLACE requires at least four arguments.
The corresponding code is shown below:
STRING(REPLACE "'" "\"" HYMLS_REVISION ${rev})
In there, I want to replace ' with " . I don't find any error. It should be valid.
Could anyone help with this?
Use quotes around ${rev} variable
STRING(REPLACE "'" "\"" HYMLS_REVISION "${rev}")

Compiler option containing doublequotes and space breaks compilation

I need to add a compiler option that contains doublequotes and space to a target in my project. I use target_compile_options to add an option.
When I add the option as I would do it on a command line CMake escapes " with \ and adds extra " (I assume the second is because of whitespace), thus breaking the compilation.
CMakeLists.txt command:
target_compile_options(myTarget -Woption="PARAM VALUE" -otherOption)
Output:
compiler.exe "-Woption=\"PARAM VALUE\"" -otherOption -o myTarget.o -c myTarget.ext
Desired output:
compiler.exe -Woption="PARAM VALUE" -otherOption -o myTarget.o -c myTarget.ext
I assume I have two problems. One is escaping doublequotes and the second one is escaping whitespace.
Question
Is it possible to add an option containing doublequotes and whitespace to compiler options? If so can somebody point me to a right direction on how to do it?
Notes
I use a cross compiler thus I made the example generic but in case it plays a role this is how the target is compiled:
set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> <FLAGS> <INCLUDES> -o <OBJECT> -c <SOURCE>")
cmake version 3.12
Build platform: Windows

How do I split a CMake generator expression to multiple lines? [duplicate]

I usually have a policy in my project, to never create lines in text files that exceed a line length of 80, so they are easily editable in all kinds of editors (you know the deal). But with CMake I get the problem that I do not know how to split a simple string into multiple lines to avoid one huge line. Consider this basic code:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")
It already exceeds the 80 column limit. So how do I break a line in CMake into multiple lines without getting to verbose (multiple list(APPEND ...) or the like)?
Update for CMake 3.0 and newer :
line continuation is possible with \. see the latest cmake docs
message("\
This is the first line of a quoted argument. \
In fact it is the only line but since it is long \
the source code uses line continuation.\
")
Availability of CMake versions:
Debian Wheezy (2013): 2.8.9
Debian Wheezy-backports: 2.8.11
Debian Jessy (2015): 3.0.2
Ubuntu 14.04 (LTS): 2.8.12
Ubuntu 15.04 : 3.0.2
Mac OSX : cmake-3 available through Homebrew, Macports and Fink
Windows: cmake-3 available through Chocolatey
CMake 3.0 and newer
Use the string(CONCAT) command:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
string(CONCAT MYPROJ_VERSION "${MYPROJ_VERSION_MAJOR}"
".${MYPROJ_VERSION_MINOR}"
".${MYPROJ_VERSION_PATCH}"
"-${MYPROJ_VERSION_EXTRA}")
Although CMake 3.0 and newer support line continuation of quoted arguments, you cannot indent the second or subsequent lines without getting the indentation whitespace included in your string.
CMake 2.8 and older
You can use a list. Each element of the list can be put on a new line:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION_LIST "${MYPROJ_VERSION_MAJOR}"
".${MYPROJ_VERSION_MINOR}"
".${MYPROJ_VERSION_PATCH}"
"-${MYPROJ_VERSION_EXTRA}")
A list used without quotes is concatenated without white-space:
message(STATUS "Version: " ${MYPROJ_VERSION_LIST})
-- Version: 1.0.0-rc1
If you really need a string, you can convert the list to a string first:
string(REPLACE ";" "" MYPROJ_VERSION "${MYPROJ_VERSION_LIST}")
message(STATUS "Version: ${MYPROJ_VERSION}")
-- Version: 1.0.0-rc1
Any semicolons in your original strings will be seen as list element separators, and removed. They must be escaped:
set(MY_LIST "Hello World "
"with a \;semicolon")
For those who were brought here from How do I split a CMake generator expression to multiple lines? I would like to add some notes.
The line continuation method will not work, CMake cannot parse a generator list made with whitespace (indentation) and line continuation.
While the string(CONCAT) solution will provide a generator expression that can be evaluated, the evaluated expression will be surrounded by quotes if the result contains a space.
For each individual option to be added a separate generator list must be constructed, so stacking options like I have done in the following will cause the build to fail:
string(CONCAT WARNING_OPTIONS "$<"
"$<OR:"
"$<CXX_COMPILER_ID:MSVC>,"
"$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>"
">:"
"/D_CRT_SECURE_NO_WARNINGS "
">$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang,GNU>,"
"$<NOT:$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>>"
">:"
"-Wall -Werror "
">$<"
"$<CXX_COMPILER_ID:GNU>:"
"-Wno-multichar -Wno-sign-compare "
">")
add_compile_options(${WARNING_OPTIONS})
This is because the resulting options are passed to the compiler in quotes
/usr/lib64/ccache/c++ -DGTEST_CREATE_SHARED_LIBRARY=1 -Dgtest_EXPORTS -I../ThirdParty/googletest/googletest/include -I../ThirdParty/googletest/googletest -std=c++11 -fno-rtti -fno-exceptions -fPIC -std=c++11 -fno-rtti -fno-exceptions -Wall -Wshadow -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers "-Wall -Werror -Wno-multichar -Wno-sign-compare " -fdiagnostics-color -MD -MT ThirdParty/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -MF ThirdParty/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o.d -o ThirdParty/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -c ../ThirdParty/googletest/googletest/src/gtest-all.cc
c++: error: unrecognized command line option ‘-Wall -Werror -Wno-multichar -Wno-sign-compare ’
To evaluate lengthy generator expressions represented using the string(CONCAT) solution, each generator expression must evaluate to a single option with no spaces:
string(CONCAT WALL "$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang,GNU>,"
"$<NOT:$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>>"
">:"
"-Wall"
">")
string(CONCAT WERROR "$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang,GNU>,"
"$<NOT:$<STREQUAL:${CMAKE_CXX_SIMULATE_ID},MSVC>>"
">:"
"-Werror"
">")
message(STATUS "Warning Options: " ${WALL} ${WERROR})
add_compile_options(${WALL} ${WERROR})
This may be unrelated to the question I am posting an answer to, unfortunately the question I am answering is wrongfully marked as a duplicate of this question.
Generator lists are not handled and parsed the same way as strings are, and because of this, there are additional measures one must take to split a generator list across multiple lines.
It's still a little verbose, but if the 80 char limit really bugs you then you could repeatedly append to the same variable:
set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION "${MYPROJ_VERSION_MAJOR}.")
set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_MINOR}.")
set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_PATCH}-")
set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_EXTRA}")
message(STATUS "version: ${MYPROJ_VERSION}")
Gives output:
$ cmake ~/project/tmp
-- version: 1.0.0-rc1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rsanderson/build/temp
The example in the original question is only about a relatively short string. For longer strings (including the examples given in other answers), a bracket argument could be better. From the documentation:
An opening bracket is written [ followed by zero or more = followed by [. The corresponding closing bracket is written ] followed by the same number of = followed by ]. Brackets do not nest. A unique length may always be chosen for the opening and closing brackets to contain closing brackets of other lengths.
[...]
For example:
message([=[
This is the first line in a bracket argument with bracket length 1.
No \-escape sequences or ${variable} references are evaluated.
This is always one argument even though it contains a ; character.
The text does not end on a closing bracket of length 0 like ]].
It does end in a closing bracket of length 1.
]=])
There is no way to split a string literal across multiple lines in CMakeLists.txt files or in CMake scripts. If you include a newline within a string, there will be a literal newline in the string itself.
# Don't do this, it won't work, MYPROJ_VERSION will contain newline characters:
set(MYPROJ_VERSION "${VERSION_MAJOR}.
${VERSION_MINOR}.${VERSION_PATCH}-
${VERSION_EXTRA}")
However, CMake uses whitespace to separate arguments, so you can change a space that's an argument separator into a newline anywhere you like, without changing the behavior.
You could re-phrase this longer line:
set(MYPROJ_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")
as these two shorter lines:
set(MYPROJ_VERSION
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")
They are entirely equivalent.
To maintain good indentation in your code it's straightforward enough just to do
message("These strings " "will all be "
"concatenated. Don't forget "
"your trailing spaces!")
Or form a string directly with
string(CONCAT MYSTR "This and " "that "
"and me too!")
as in Douglas' answer who has more details. However I thought this might just summarise the essential point.

How to preserve single quotes in a CMake cached variable?

I have a variable
SET(CODE_COVERAGE_EXCLUSION_LIST
""
CACHE STRING "List of resources to exclude from code coverage analysis")
It must contain a list of expressions such as : 'tests/*' '/usr/*'
When trying to set the default value to the above expressions, the single quotes are removed.
How to preserve them ?
Moreover, when I try to pass the exclusion list like this
cmake -DCODE_COVERAGE_EXCLUSION_LIST="'tests/*' '/usr/*'" ..
The initial and final single quotes are lost. How to preserve them as well ?
Finally, the same question applies when using cmake-gui.
EDIT : I tried to use backslash to escape the quotes :
SET(CODE_COVERAGE_EXCLUSION_LIST
" \'tests/*\' \'/usr/*\'"
CACHE STRING "List of resources to exclude from code coverage analysis : ")
It gave me the following error :
Syntax error in cmake code at
xxx.cmake:106
when parsing string
\'tests/*\' \'/usr/*\'
Invalid escape sequence \'
EDIT2 : code of the add_custom_target (and not add_custom_command, my bad)
ADD_CUSTOM_TARGET(${_targetname}
# Cleanup lcov
${LCOV_PATH} --directory . --zerocounters
# Run tests
COMMAND ${_testrunner} ${ARGV3}
# Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' ${CODE_COVERAGE_EXCLUSION_LIST} --output-file ${_outputname}.info.cleaned
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
)
Turning my comments into an answer
First - taking the question why you need those quotes aside - I could reproduce your problem and found several possible solutions:
Adding spaces at the begin and end of your cached variable
cmake -DCODE_COVERAGE_EXCLUSION_LIST=" 'tests/*' '/usr/*' " ..
Using "escaped" double quotes instead of single quotes
cmake -DCODE_COVERAGE_EXCLUSION_LIST:STRING="\"tests/*\" \"/usr/\"" ..
Using your set(... CACHE ...) example by setting policy CMP0053 switch introduced with CMake 3.1:
cmake_policy(SET CMP0053 NEW)
set(CODE_COVERAGE_EXCLUSION_LIST
"\'tests/*\' \'/usr/*\'"
CACHE STRING "List of resources to exclude from code coverage analysis : ")
But when setting this in the code I could also just do
set(CODE_COVERAGE_EXCLUSION_LIST
"'tests/*' '/usr/*'"
CACHE STRING "List of resources to exclude from code coverage analysis : ")
The quoting issue seems only to be a problem when called from command line
Then - if I do assume you may not need the quotes - you could pass the paths as a list:
A semicolon separated CMake list is expanded to parameters again (with spaces as delimiter) when used in a COMMAND
cmake -DCODE_COVERAGE_EXCLUSION_LIST:STRING="tests/*;/usr/*" ..
with
add_custom_target(
...
COMMAND ${LCOV_PATH} --remove ${_outputname}.info ${CODE_COVERAGE_EXCLUSION_LIST} --output-file ${_outputname}.info.cleaned
)
would give something like
.../lcov --remove output.info tests/* /usr/* --output-file output.info.cleaned
I also tried to add the VERBATIM option, because "all arguments to the commands will be escaped properly for the build tool so that the invoked command receives each argument unchanged". But in this case, it didn't change anything.
References
add_custom_target()
CMake Language: Escape Sequences
0015200: Odd quoting issue when mixing single, double and escaped quotes to COMMAND

CMake error with string sub-command STRIP "requires two arguments"

I am trying to compile a library with CMake. This library uses CMake with the pods build system.
During configuring I get the following error:
CMake Error at cmake/pods.cmake:257 (string):
string sub-command STRIP requires two arguments.
In the specific file pods.cmake the command looks like this:
execute_process(COMMAND
${PKG_CONFIG_EXECUTABLE} --cflags-only-I ${ARGN}
OUTPUT_VARIABLE _pods_pkg_include_flags)
string(STRIP ${_pods_pkg_include_flags} _pods_pkg_include_flags)
which looks fine to me. Any ideas why this error occurs? I don't understand why cmake complains that it needs two arguments for the STRIP command when it clearly has two.
Note: I use cmake 2.8.12.2, but according to the documentation this should be valid.
While your CMake file does syntactically contain two arguments, ${_pods_pkg_include_flags} can be empty. If so, it is not an argument semantically and never reaches string(), which then sees just one. If it's possible for a string to be empty (and you want to treat it as an empty string in such case instead of skipping it), quote it:
string(STRIP "${_pods_pkg_include_flags}" _pods_pkg_include_flags)