Modern way to set compiler flags in cross-platform cmake project

前端 未结 4 1470
再見小時候
再見小時候 2020-11-28 07:05

I want to write a cmake file that sets different compiler options for clang++, g++ and MSVC in debug and release builds. What I\'m doing currently looks something like this:

4条回答
  •  無奈伤痛
    2020-11-28 07:35

    Another way is to use .rsp files.

    set(rsp_file "${CMAKE_CURRENT_BINARY_DIR}/my.rsp")
    configure_file(my.rsp.in ${rsp_file} @ONLY)
    target_compile_options(mytarget PUBLIC "@${rsp_file}")
    

    which might make the inclusion of multiple and esoteric options easier to manage.

提交回复
热议问题