Discussion:
[CMake] how to add sources conditionally?
Prakash Punnoor
2005-11-18 19:17:06 UTC
Permalink
Hi,

I have new problem: I am trying something like this:

SET(SRC1 foo.c)
SET(SRC2 bar.c)

IF(COND1)
SET(SRCS "${SRCS} ${SRC1}")
ENDIF(COND1)

IF(COND2)
SET(SRCS "${SRCS} ${SRC2}")
ENDIF(COND2)

ADD_LIBRARY(test ${SRCS})

But this doesn't work. cmake doesn't get the paths fully expanded and
complains about not finding source files. What would be the correct way
to do something like above?

Thx,

Prakash
Miguel A. Figueroa-Villanueva
2005-11-18 19:20:19 UTC
Permalink
Post by Prakash Punnoor
IF(COND1)
SET(SRCS "${SRCS} ${SRC1}")
ENDIF(COND1)
I think you need to remove the double-quotes

SET(SRCS ${SRCS} ${SRC1})
Prakash Punnoor
2005-11-18 19:33:52 UTC
Permalink
Post by Miguel A. Figueroa-Villanueva
Post by Prakash Punnoor
IF(COND1)
SET(SRCS "${SRCS} ${SRC1}")
ENDIF(COND1)
I think you need to remove the double-quotes
SET(SRCS ${SRCS} ${SRC1})
Thanks! That was it, I seem to have gotten a bit confused...

bye,

Prakash

Loading...