[CMake] Renaming output of EXECUTABLE

Darko Miletic darko at uvcms.com
Thu Dec 1 10:18:08 EST 2005


Reggie Burnett wrote:
> Gregor
>
> Thanks for the reply.  I was thinking of this approach as well but wasn't
> sure how to implement.  I'll use your suggestion for now.  I'm still
> wondering about dynamic source lists.

This is quite simple. Define a variable for the source files like this:

SET (SRCS
     src1.cpp
     src2.cpp
     srcx.cpp
)

Later in the script you can do something like this:
SET (BUILDWITHFILE1 1)

IF (BUILDWITHFILE1)
SET (SRCS ${SRCS} file1.cpp )
ELSE (BUILDWITHFILE1)
SET (SRCS ${SRCS} file2.cpp )
ENDIF (BUILDWITHFILE1)

or like this:
IF    (CMAKE_BUILD_TYPE MATCHES Debug)
  SET(SRCS ${SRCS} debug.cpp)
ELSE  (CMAKE_BUILD_TYPE MATCHES Debug)
  SET(SRCS ${SRCS} release.cpp)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)

and then just use the variable

ADD_LIBRARY(mylib STATIC ${SRCS})



More information about the CMake mailing list