On 04/07/2011 07:37 PM, Jiang Xu wrote: > Hi All, > > I am new to cmake, but I really like it after looking into it. > I am in the process to make some changes to our current make file system. > I wonder how can I archieve the following goal using cmake: > > 1. The root directory is features/ > 2. Under root directory, there is a set of subdirectories as: feature_1/, > feature_2/, ... feature_n/ > 3. Under each subdirectory, there is a CMakeList.txt to compile a static > library for each feature. For example, in CMakeList.txt under feature_1 > directory, it has a line to create static library target: > add_library(feature_1, STATIC, ${FEATURE_1_SRCS}) > 4. Under root directory, there is no source code, all it does is based on > user input (command line) to go into different sub-directories to build each > static libraries and try to link all of them into a shared library. > > It looks like add_library command must have any source code files in it. So > I don't know how to add a shared library target and all it does is to link > different static libraries, there is no source file. Can someone please help > me? > > Thanks in advance. > > John
This is not possible with CMake, cf. [1]. Instead, you'll have either to - build one shared library in each feature_* directory to link against, e.g. ADD_LIBRARY(feature_1 SHARED feature_1.c ...) in feature_1, or - build one shared library in the root directory with all the sources from the feature_* directories, e.g. ADD_LIBRARY(features SHARED feature_1/feature_1.c feature_2/feature_2.c ...) in features. Besides, object files for static libraries and object files for shared libraries are usually compiled with different flags, in particular with regard to -fPIC, so they might not be interchangeable without further ado. 'hope that helps. Regards, Michael > [1] > http://www.cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F _______________________________________________ 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