It should be a CMake list, which is delineated by semicolons.

add_compile_options($<$<COMPILE_LANGUAGE:C>-Wall;-Wextra>)

I am writing this from a phone so untested, but that has worked for me in
the past.

-Stephen


On Sat, Jun 2, 2018, 3:47 PM Neil Carlson <neil.n.carl...@gmail.com> wrote:

> I'm attempting to use a generator expression to conditionally add compile
> options. No problem if it is a single option, but I can't figure out how to
> manage multiple options (in a single command).
>
> For example, this works:
> add_compile_options($<$<COMPILE_LANGUAGE:C>-Wall>)
>
> As does this:
> add_compile_options(-Wall -Wextra)
>
> But not this:
> add_compile_options($<$<COMPILE_LANGUAGE:C>-Wall -Wextra>)
>
> Nor this:
> add_compile_options($<$<COMPILE_LANGUAGE:C>"-Wall -Wextra">)
>
> Or any other variation I could think of.  Either the space breaks the
> generator expression, or I get a quoted version of the options that the
> compiler sees as a single "option" it doesn't understand.
>
> Is there some way of doing this?
>
> PS: I'm trying to avoid using CMAKE_C_FLAGS. My understanding is that
> variable is meant for the end user's use.  Am I mistaken about that?
>
> --
>
> 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
>
-- 

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 via email to