[CMake] Checking the influence of variable names on passing compilation parameters

SF Markus Elfring elfring at users.sourceforge.net
Sun Sep 15 10:43:11 EDT 2013


Hello,

I would like to build some C++ software with the tool "CMake 2.8.11.2-108.1" on
my openSUSE systen.

I have macro calls like the following in a CMake script of a subdirectory.

...
message(STATUS "{T} XFLAG: |${XFLAG}|")
foreach(X
        client
...
        unix_server_stream)
   set(T "${X}_cpp")
   add_executable("${T}" "${X}.cpp")
   set_target_properties("${T}" PROPERTIES COMPILE_FLAGS "${XFLAG}" OUTPUT_NAME
"${X}")
   target_link_libraries("${T}" ${LIB})
endforeach(X)
...


The CMake GUI shows the expected log:

C++11 support activated.
{T} XFLAG: |-std=c++11|
Configuring done
Generating done


But I get surprised by the message like "error: 'std::unique_ptr' has not been
declared" after I called the program "make". The verbose build mode shows that
the needed parameter was not passed by the corresponding command.
How are the chances to find out where and why the desired compilation parameter
gets lost?


If I rename the used variable to "FLAGS", the software generation succeeds.
I would appreciate if my approach will also work with longer variable names
which can be found more easily and better understood.

Regards,
Markus


More information about the CMake mailing list