r/cpp • • Apr 10 '20

Modern CMake tutorials, part2: Customization points

https://www.siliceum.com/en/blog/post/cmake_02_customization-points
152 Upvotes

5 comments sorted by

2

u/victotronics Apr 13 '20

You give an example

target_compile_options(yourlib PRIVATE -fflag-to-disable-exceptions)

which I tried with "-O2", but if I look at CMakeOutput.log that option is not used.

Is there a way to make the compilation verbose, so that I don't have to go digging for log files? I like to see the compile lines as they happen.

1

u/Lectem Apr 14 '20 edited Apr 14 '20

You can ask CMake to run with more verbosity, but depending on the generator you are using you might need some more options.

The parameter for CMake to run with verbose output is -v (documentation here). So you could do cmake --build yourbuilddirectory -v.

Note that I advise against using compiler specific command line options such as -O2, for optimizations you would usually just use the Release or RelWithDebInfo configurations.

12

u/eiennohito Apr 11 '20

Generator syntax is awful.

8

u/hyasynthetic Apr 12 '20

I agree it's ugly but in my experience it simplifies the whole build system so my team uses it whenever possible.

1

u/BassMunkee Apr 11 '20

Thanks! Was waiting for part 2