[CMake] Renaming output of EXECUTABLE

Reggie Burnett reggie at bytefx.com
Thu Dec 1 10:24:08 EST 2005


Thanks Darko.  I'm very new to cmake so even some of the simple things
currently escape me.  Can I also use a variable for the target?  

ADD_EXECUTABLE(${EXENAME} ${SRCS})

Reggie

> -----Original Message-----
> From: Darko Miletic [mailto:darko at uvcms.com]
> Sent: Thursday, December 01, 2005 9:18 AM
> To: Reggie Burnett
> Cc: 'Gregor Berginc'; cmake at cmake.org
> Subject: Re: [CMake] Renaming output of EXECUTABLE
> 
> 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