[CMake] Supressing Make, but not Generators

Alexander Neundorf a.neundorf-work at gmx.net
Wed Mar 3 12:32:29 EST 2010


On Wednesday 03 March 2010, Michael Wild wrote:
> On 3. Mar, 2010, at 9:27 , Smith Jack (Ext. - UGIS - UniCredit Group) wrote:
> >> -----Original Message-----
> >> From: cmake-bounces at cmake.org
> >> [mailto:cmake-bounces at cmake.org] On Behalf Of Hendrik Sattler
> >> Sent: Wednesday, March 03, 2010 9:21 AM
> >> To: cmake at cmake.org
> >> Subject: Re: [CMake] Supressing Make, but not Generators
> >>
> >> Zitat von "Smith Jack (Ext. - UGIS - UniCredit Group)"
> >>
> >> <jack.smith.extern at unicreditgroup.de>:
> >>> It's worryingly quiet on this subject.
> >>
> >> So, just exclude the target that won't build from ALL.
> >
> > I'm afraid you've lost me there.  Do I do this within a CMakeLists.txt
> > file ?
> >
> > My current CMakeLists.txt relies upon ADD_SUBDIRECTORY(project_name) in
> > order to generate the build targets.
> >
> > How do I conditionally exclude project_name from ALL in this case ?
> >
> > Thanks,
> > Jack
>
> CMakeLists.txt:
> ###############
> project(super)
> if(UNIX)
>   set(BUILD_FOO)
> else()
>   # FOO only builds on UNIX
>   set(BUILD_FOO EXCLUDE_FROM_ALL)
> endif()
> add_subdirectory(foo)
>
> foo/CMakeLists.txt:
> ###################
> project(foo)
> add_executable(foo ${BUILD_FOO} src1.cpp src2.cpp)

You can also test CMAKE_GENERATOR and CMAKE_EXTRA_GENERATOR (contains the IDE 
for the makefile-based project generators like Eclipse) for the current 
generator.

Alex


More information about the CMake mailing list