[CMake] Building shared library from collection?
Hilton Medeiros
medeiros.hilton at gmail.com
Tue Feb 9 12:11:31 EST 2010
Personally, I prefer a sole CMakeLists.txt for small/medium size
projects. You should not have problems linking your project, this
would be my approach:
list(APPEND LINK_MODULES PATHLIB/libA.a PATHLIB/libB.a PATHLIB/libC.a)
target_link_libraries(super_lib ${LINK_MODULES})
Note that you should use CMake defined paths in 'PATHLIB', e.g.,
${PROJECT_BINARY_DIR}/libA.a
I'm assuming they are static libraries since you said 'modules'.
Also, consider generating the html documentation from your cmake for use
as reference: 'cmake --help-html >cmake.html' on the command line.
Cheers,
Hilton
On Tue, 09 Feb 2010 15:03:45 +0000
John Brydon <john-comp at blueyonder.co.uk> wrote:
> Hi folks,
>
> first post here as just delving into the world of cmake.
>
> My first question is about the structure of my project. It is like so:
>
> <Project Folder>
> '-> <Module A>
> '-> <Module B>
> '-> <Module C>
>
> From reading the CMake book it appears I've got 3 options for
> building. 1) Single makefile at top that lists all the sources with
> their subdirectories.
> 2) Have each subdirectory build a library that can then be linked at
> then end.
> 3) Mixture of 1 and 2.
>
> I choose 3 as I wish to have each module as a library and then link
> the 3 libraries together to make up the project.
> Firstly, does this seem feasible i.e. is my understanding of the book
> correct? Secondly, I managed to build each of
> the libraries separately but I am unsure of the syntax of how to link
> them together to create the 'super' library.
>
> Any help or pointers in the right direction would be great.
>
> Cheers,
>
> John.
>
> _______________________________________________
> 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
More information about the CMake
mailing list