Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Clion compile with -O3

I’m writing a c++ program using CLion and I need to specify -O3 flag on the compiler, using set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" -O3) on the CMakeList file does not work.
Is there a way to do it?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use either add_compile_options(-O3) to add it globally or target_compile_options(YourTarget -O3) to add it locally to a specific target.


You could also do it by using CMAKE_CXX_FLAGS but that is a pretty old way of doing things in CMakeLists files, that’s how it would look like:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") or set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -O3).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading