[CMake] CMake & subdirectories
Dan Tihelka
dtihelka at kky.zcu.cz
Thu Nov 10 09:56:12 EST 2005
Hi all,
I have just started to use the CMake, and I have already ordered the
book. However, until the book will come, I need to solve the following
problem.
I have a library (let us call it MyLibrary), which I need to build using
CMake -- the library was created several years ago, but it was built
under MSVC only. Now I need to build it for Linux, and possibly other
unix platforms.
The source code of the library is organized as follows:
src (contains only global *.h)
|
+ IO (contains *h as well as *.cpp)
|
+ Math (contains *h as well as *.cpp)
|
+ many others, even more recursive.
OK, I made the following files:
CMakeLists.txt:
PROJECT(MyLibrary)
INCLUDE_DIRECTORIES( ... )
SUBDIRS(src)
src/CMakeLists.txt::
SUBDIRS(IO Math --and other recursive directories --- )
src/IO/CMakeLists.txt::
SET(SRC --- all .cpp files listed here)
ADD_LIBRARY(MyLibrary${SRC})
src/Math/CMakeLists.txt::
SET(SRC --- all .cpp files listed here)
ADD_LIBRARY(MyLibrary${SRC})
and similarly for all the other directories. When a directory contains
other subdirectories, SUBDIRS() is also listed in the CMakeLists, just
after the ADD_LIBRARY.
But, there is the problem. all seems to be OK, but libMyLibrary.a is
created in each subdirectory, containing only sources from that
subdirectory. However, I need one library in src/ directory, containing
sources from all the subdirectories. What is wrong on my definitions?
Did I forget something?
Thank you very much for your help,
Dan
P.S. Unfortunately, the source cannot be just copied into one directory,
as it is under CVS control.
More information about the CMake
mailing list