1

I would like to run a custom command on CMake with the same flags it passes the C++ compiler and linker. Is that possible?

I tried using get_target_property() with various properties but nothing I found provided the full set of flags.

haggai_e
  • 4,689
  • 1
  • 24
  • 37
  • Reading just the ${CMAKE_CXX_FLAGS} and ${CMAKE_EXE_LINKER_FLAGS} doesn't work in your case? Which flags are missing? – fedepad Jan 09 '17 at 18:26
  • These variables don't help because they were overridden by target specific commands like `target_link_libraries()` and `target_compiler_features()`. – haggai_e Jan 09 '17 at 18:38
  • 2
    Can you describe more of your intended use case? This is something only the generator can output (see [here](http://stackoverflow.com/questions/33828855/is-cmake-set-variable-recursive)), so there is something like [`CMAKE_EXPORT_COMPILE_COMMANDS`](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). Or maybe something similar to [this](http://stackoverflow.com/questions/34165365/retrieve-all-link-flags-in-cmake) might help. – Florian Jan 09 '17 at 21:18
  • I'm using Vivado HLS on my code to convert C++ to verilog, and its compiler gets more or less the same parameters as GCC. – haggai_e Jan 10 '17 at 04:39

0 Answers0