Hi all I'm looking into compiling OpenOffice.org with CMake. Currently it uses dmake and a custom build tool. The basic structure is that every logical component (Writer, widget toolkit etc) has its own subdirectory. These are well separated.
The problem comes from the internal structure of these components. The most common case is that the component produces one product (usually a shared library) from source files scattered in several different subdirectories. As an example: dir1/foo.cxx dir1/foo2.cxx dir1/subdir/baz.cxx dir2/sub1/ggg.cxx dir2/sub2/rrr.cxx And so on and so on. Each subdirectory has a dmakefile that lists the source files to use. I have written a parser that converts these to CMake's syntax. Every component has a subdirectory called "util". This is where the final product is defined and built. What I want to know is what is the correct cross-platform way to do this in CMake. Here are some choices I came up with so far: 1) Build every subdir to a static library and link them to the final shared library. I think this fails, because the files do not get all the proper -FPIC switches and so on. 2) Build every subdir as a shared library and join them to the final lib. I tried this ages ago and turned out merging shared libraries (also static ones) was not possible. Probably still the case. 3) Write source files to a variable and then add_library(foo SHARED ${SOURCE_FILES}). But what should I write in SOURCE_FILES? Should it be "foo.cxx", "dir1/foo.cxx", or perhaps even "../dir1/foo.cxx" (since add_library is done in the util subdirectory)? Also, do I need to set the variable to cache, since changes in subdirectories must be visible in their parent and siblings? Preferably the variable should not be visible in other components. Sounds easy so far? Well, there is still one more thing. Every source file may be tagged with a special value, and those files must be compiled with special compiler switches (dealing with exceptions). If a file is not tagged, different compiler switches must be used. I can set COMPILE_DEFINITIONS easily, but can I make it drop existing switches? I can code logic to the converter script that calculates the the set difference between all source files and tagged ones. Then I can set COMPILE_DEFINITIONS for each of these separately, but I'd rather not if there is an easier way. :-) Anyway, that's what I have so far. Thanks for any help. _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake