Generic rule from makefile to CMake

后端 未结 2 444
迷失自我
迷失自我 2020-11-29 08:34

I am trying to \"translate\" the flowing vanilla makefile lines into CMake syntax.

SRCS = $(wildcard *.foo)
OBJS = $(SRCS:.foo=.bar)

my_rule: $(OBJS)

%.bar         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 09:31

    Your attempt is correct, and it hardly can be significantly improved.

    This is just how CMake works: each of its "rules" is concrete; you cannot create a "template rule". The reason for that is platform independence: not every build systems supports "templates" for rules.

    On the other side, CMake supports creation of the "rules" within functions/macros. So typing repeated parts can be easily reduced.

提交回复
热议问题