Question about a simple macro.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about a simple macro.

Steven Truppe
Hi everyone,

i'm a c,c++,asm and a few other languages, but i still have troubles
with macros and their arguments.

As a simple example i would like to have a macro that list(APPEND the
two passed arguments), here the code i tried:

https://wandbox.org/permlink/WQZGty9PQaOz3422.


Let's forget about the list(APPEND) line, i just need an example that
prints me out the first and the second argument and i'm not able to get
it right. Would someone please explain to me how i can do this right ?
I've read the book but that didn't helped me completely.

I hope someone here is so nice to me to explain to me how i can write
the bsMergeFlags macro and explains me what i'm doing wrong and how to
correct it.

I played around alot but can't get it right.


best regards!


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about a simple macro.

Steven Truppe
Do i need cmake_parse_arguments ??

On 09.06.19 07:01, Steven Truppe wrote:

> Hi everyone,
>
> i'm a c,c++,asm and a few other languages, but i still have troubles
> with macros and their arguments.
>
> As a simple example i would like to have a macro that list(APPEND the
> two passed arguments), here the code i tried:
>
> https://wandbox.org/permlink/WQZGty9PQaOz3422.
>
>
> Let's forget about the list(APPEND) line, i just need an example that
> prints me out the first and the second argument and i'm not able to get
> it right. Would someone please explain to me how i can do this right ?
> I've read the book but that didn't helped me completely.
>
> I hope someone here is so nice to me to explain to me how i can write
> the bsMergeFlags macro and explains me what i'm doing wrong and how to
> correct it.
>
> I played around alot but can't get it right.
>
>
> best regards!
>
>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about a simple macro.

Steven Truppe
ARGV1 gives me the first list entry of my first arguments, but i don't
know how i can access the hole list.


best regards!

On 09.06.19 07:20, Steven Truppe wrote:

> Do i need cmake_parse_arguments ??
>
> On 09.06.19 07:01, Steven Truppe wrote:
>> Hi everyone,
>>
>> i'm a c,c++,asm and a few other languages, but i still have troubles
>> with macros and their arguments.
>>
>> As a simple example i would like to have a macro that list(APPEND the
>> two passed arguments), here the code i tried:
>>
>> https://wandbox.org/permlink/WQZGty9PQaOz3422.
>>
>>
>> Let's forget about the list(APPEND) line, i just need an example that
>> prints me out the first and the second argument and i'm not able to get
>> it right. Would someone please explain to me how i can do this right ?
>> I've read the book but that didn't helped me completely.
>>
>> I hope someone here is so nice to me to explain to me how i can write
>> the bsMergeFlags macro and explains me what i'm doing wrong and how to
>> correct it.
>>
>> I played around alot but can't get it right.
>>
>>
>> best regards!
>>
>>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about a simple macro.

Steven Truppe

OK, i don't realy understand why it does work but i got it working:

include(CMakePrintHelpers)
macro(bsMergeFlags flags_to_add flags)
    set(flags_to_add ${flags_to_add} ${ARGN} )
    cmake_print_variables(flags_to_add)

    message(STATUS "bsMergeFlags ${flags_to_add}")
    list(APPEND flags ${tmp})
    message(STATUS "------------")
endmacro()

Now my problem is that the content of flags_to_add is correct when i use cmake_print_variables but not when i try to use it in a message() call.


I think i do miss some very important part when it comes to variables - i'm now studying the hole chapter again, hopefully i understand it then.


I hope you guys can help me.


best regards!


On 09.06.19 08:26, Steven Truppe wrote:
ARGV1 gives me the first list entry of my first arguments, but i don't
know how i can access the hole list.


best regards!

On 09.06.19 07:20, Steven Truppe wrote:
Do i need cmake_parse_arguments ??

On 09.06.19 07:01, Steven Truppe wrote:
Hi everyone,

i'm a c,c++,asm and a few other languages, but i still have troubles
with macros and their arguments.

As a simple example i would like to have a macro that list(APPEND the
two passed arguments), here the code i tried:

https://wandbox.org/permlink/WQZGty9PQaOz3422.


Let's forget about the list(APPEND) line, i just need an example that
prints me out the first and the second argument and i'm not able to get
it right. Would someone please explain to me how i can do this right ?
I've read the book but that didn't helped me completely.

I hope someone here is so nice to me to explain to me how i can write
the bsMergeFlags macro and explains me what i'm doing wrong and how to
correct it.

I played around alot but can't get it right.


best regards!



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about a simple macro.

Steven Truppe

How on earth can i create a variables out of the string flags_to_add ???



On 09.06.19 08:41, Steven Truppe wrote:

OK, i don't realy understand why it does work but i got it working:

include(CMakePrintHelpers)
macro(bsMergeFlags flags_to_add flags)
    set(flags_to_add ${flags_to_add} ${ARGN} )
    cmake_print_variables(flags_to_add)

    message(STATUS "bsMergeFlags ${flags_to_add}")
    list(APPEND flags ${tmp})
    message(STATUS "------------")
endmacro()

Now my problem is that the content of flags_to_add is correct when i use cmake_print_variables but not when i try to use it in a message() call.


I think i do miss some very important part when it comes to variables - i'm now studying the hole chapter again, hopefully i understand it then.


I hope you guys can help me.


best regards!


On 09.06.19 08:26, Steven Truppe wrote:
ARGV1 gives me the first list entry of my first arguments, but i don't
know how i can access the hole list.


best regards!

On 09.06.19 07:20, Steven Truppe wrote:
Do i need cmake_parse_arguments ??

On 09.06.19 07:01, Steven Truppe wrote:
Hi everyone,

i'm a c,c++,asm and a few other languages, but i still have troubles
with macros and their arguments.

As a simple example i would like to have a macro that list(APPEND the
two passed arguments), here the code i tried:

https://wandbox.org/permlink/WQZGty9PQaOz3422.


Let's forget about the list(APPEND) line, i just need an example that
prints me out the first and the second argument and i'm not able to get
it right. Would someone please explain to me how i can do this right ?
I've read the book but that didn't helped me completely.

I hope someone here is so nice to me to explain to me how i can write
the bsMergeFlags macro and explains me what i'm doing wrong and how to
correct it.

I played around alot but can't get it right.


best regards!




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about a simple macro.

Steven Truppe

Problem solved - thanks anyway...

On 09.06.19 09:11, Steven Truppe wrote:

How on earth can i create a variables out of the string flags_to_add ???



On 09.06.19 08:41, Steven Truppe wrote:

OK, i don't realy understand why it does work but i got it working:

include(CMakePrintHelpers)
macro(bsMergeFlags flags_to_add flags)
    set(flags_to_add ${flags_to_add} ${ARGN} )
    cmake_print_variables(flags_to_add)

    message(STATUS "bsMergeFlags ${flags_to_add}")
    list(APPEND flags ${tmp})
    message(STATUS "------------")
endmacro()

Now my problem is that the content of flags_to_add is correct when i use cmake_print_variables but not when i try to use it in a message() call.


I think i do miss some very important part when it comes to variables - i'm now studying the hole chapter again, hopefully i understand it then.


I hope you guys can help me.


best regards!


On 09.06.19 08:26, Steven Truppe wrote:
ARGV1 gives me the first list entry of my first arguments, but i don't
know how i can access the hole list.


best regards!

On 09.06.19 07:20, Steven Truppe wrote:
Do i need cmake_parse_arguments ??

On 09.06.19 07:01, Steven Truppe wrote:
Hi everyone,

i'm a c,c++,asm and a few other languages, but i still have troubles
with macros and their arguments.

As a simple example i would like to have a macro that list(APPEND the
two passed arguments), here the code i tried:

https://wandbox.org/permlink/WQZGty9PQaOz3422.


Let's forget about the list(APPEND) line, i just need an example that
prints me out the first and the second argument and i'm not able to get
it right. Would someone please explain to me how i can do this right ?
I've read the book but that didn't helped me completely.

I hope someone here is so nice to me to explain to me how i can write
the bsMergeFlags macro and explains me what i'm doing wrong and how to
correct it.

I played around alot but can't get it right.


best regards!





--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake