On Tue, Apr 13, 2010 at 11:06 PM, Wim Dumon <[email protected]> wrote:
> Mike,
>
> Have you seen examples of projects that do that? I've looked at this
> in the past, but gave up because (1) some directives like PROJECT and
> CMAKE_MINIMUM_REQUIRED don't seem to be allowed in other places than
> the toplevel CMakeLists.txt

They are allowed in non-toplevel CMakeLists.txt. I use them all over
the place in my projects to allow building subprojects.

> (2) we now search for dependencies in the
> toplevel CMakeLists.txt, and reuse them at all other levels instead of
> looking for them again there.

You need to search for dependencies where they are needed, meaning:
- Search for a dependency only when it is needed, not before
- Search for a dependency always when it is needed, i. e. if you want
to allow Wt and Wt::Dbo to be built as separate projects, and both of
them depend on Boost, you need to search for Boost twice. Replacing
the current WtFindBlah.cmake-style finders with real finders
(find_package( Blah REQUIRED) + actual FindBlah.cmake would help
because that way CMake can better use the cache to reuse values
instead of searching for them again.

The easiest way to create a build system which can be built as
subprojects is to treat each subproject as a separate project, then
join them together with a (generally small) top-level CMakeLists.txt.
In this case, you would call CMake on the directory for the subproject
you want to build, i. e. cmake /path/to/wt/src/Wt/Dbo/

In projects where there are so many interdependencies that it is
impossible to have separate CMakeLists.txt and join them together with
a small top-level CMakeLists.txt, you can use another approach: have
OPTIONs to build the parts. For instance:

option( BUILD_WT ON )
option( BUILD_WTHTTP ON )
option( BUILD_WTFCGI ON )
option( BUILD_WTEXT ON )
option( BUILD_WTDBO ON )
option( BUILD_WTDBOSQLITE ON )
option( BUILD_WTDBOPOSTGRES ON )

then do add_subdirectory() of that part only if BUILD_thatpart is enabled:

if( BUILD_WTEXT ON )
  add_subdirectory( src/Wt/Ext )
endif( BUILD_WTEXT )

of course you'll also need to check for dependencies, i. e. it makes
no sense to build WtExt without Wt, so the above should be:

if( BUILD_WTEXT ON )
  add_subdirectorty( src/Wt )
  add_subdirectory( src/Wt/Ext )
endif( BUILD_WTEXT )

Some reorganization of the sources might be needed, I have not checked.

In this case, you would call CMake on the top-level directory (like we
do now) but with options: cmake  -DBUILD_WT:BOOL=OFF
-DBUILD_WTEXT:BOOL=OFF -DBUILD_WTHTTP:BOOL=OFF -DBUILD_WTFCGI:BOOL=OFF
-DBUILD_WTDBO:BOOL=ON -DBUILD_WTDBOSQLITE:BOOL=ON
-DBUILD_WTDBOSQLITE:BOOL=ON /path/to/wt

(depending on what defaults you choose for the OPTIONS, ON or OFF, you
need to do enable/disable more or less parts; instead of variables,
you can also select the BUILD_BLAH options with the CMake GUI)

The latter is the approach used by KDE. It is generally easier to
achieve than the former (independent projects joint together by a
top-level CMakeLists.txt).

> Suggestions to solve this are welcome...

I hope that helps.

>
> Best regards,
> Wim.
>
> 2010/4/13 Mike Teehan <[email protected]>:
>> Ideally, you could do "mkdir dbobuild; cd dbobuild; ccmake ../src/Wt/Dbo/" 
>> but
>> my initial impression is that Wt's cmake files aren't setup for that.
>>
>> Mike
>>
>> On Tuesday 13 April 2010 09:13:16 am omer katz wrote:
>>> Isn't there an easy option to code a CMake script to do just that?
>>> I suggest you to look into that.
>>>
>>> 2010/4/13 mobi phil <[email protected]>
>>>
>>> >> Thx Mr. phil :) , it's not a bad idea but I hoped that someone had made
>>> >> it before :p
>>> >> I'll follow the advice of Mr. Dumon
>>> >> thank you for your quick responses
>>> >>
>>> >> Best regards,
>>> >>
>>> >>
>>> >> Sami
>>> >
>>> > Mister Sami, ,)
>>> >
>>> > No need to say that you will follow Mr. Dumon's advice, as he will not
>>> > give you any premium...  However life will pay you premium if you try to
>>> > go deeper a bit to understand things... Indeed why would you build 100's
>>> > of files if you need only 3 (especially if you need to do that often).
>>> > However it is obvious that nobody will change WT build system for you for
>>> > this reason :)
>>> >
>>> >
>>> >
>>> > --
>>> > rgrds,
>>> > mobi phil
>>> >
>>> > being mobile, but including technology
>>> > http://mobiphil.com
>>> >
>>> >
>>> > -------------------------------------------------------------------------
>>> >----- Download Intel&#174; Parallel Studio Eval
>>> > Try the new software tools for yourself. Speed compiling, find bugs
>>> > proactively, and fine-tune applications for parallel performance.
>>> > See why Intel Parallel Studio got high marks during beta.
>>> > http://p.sf.net/sfu/intel-sw-dev
>>> > _______________________________________________
>>> > witty-interest mailing list
>>> > [email protected]
>>> > https://lists.sourceforge.net/lists/listinfo/witty-interest
>>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>



-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to