What's the CMake syntax to set and use variables?

前端 未结 3 1492
情话喂你
情话喂你 2020-11-22 11:51

I\'m asking this as a reminder to myself the next time I use CMake. It never sticks, and Google results aren\'t great.

What\'s the syntax to set and use variables in

3条回答
  •  伪装坚强ぢ
    2020-11-22 12:35

    Here are a couple basic examples to get started quick and dirty.

    One item variable

    Set variable:

    SET(INSTALL_ETC_DIR "etc")
    

    Use variable:

    SET(INSTALL_ETC_CROND_DIR "${INSTALL_ETC_DIR}/cron.d")
    

    Multi-item variable (ie. list)

    Set variable:

    SET(PROGRAM_SRCS
            program.c
            program_utils.c
            a_lib.c
            b_lib.c
            config.c
            )
    

    Use variable:

    add_executable(program "${PROGRAM_SRCS}")
    

    CMake docs on variables

提交回复
热议问题