Hi,

On Sun, Oct 28, 2012 at 10:09 PM, Rui Maciel <[email protected]> wrote:
> I'm developing a software package which consists of a GUI application and a
> command line program.  Both programs share common libraries, and essentially
> they only differ in which UI components each program uses.
>
> I would like to use CMake to handle the build project of this package, but
> as I never used CMake to pull this off I don't even know if it is possible.
> So, does anyone have any experience using CMake to set a project with
> multiple executables sharing commong libraries?  If it is possible what's
> the best way to pull this off?

Having this is as simple as:

add_library( mysharedlib SHARED ${LIB_SRCS} )

add_executable( mycliapp ${CLI_SRCS} )
target_link_libraries( mycliapp mysharedlib )

add_executable( myguiapp ${CLI_SRCS})
target_link_libraries( myguiapp mysharedlib )

# This installs the library to CMAKE_INSTALL_PREFIX/lib and the
binaries to CMAKE_INSTALL_PREFIX/bin on *nix, see the cmake manual for
more details
install( TARGETS mysharedlib mycliapp myguiapp
           LIBRARY DESTINATION lib/
           RUNTIME DESTINATION bin/
         )

On Unix you might want to look into the RPATH options offered by
cmake, so your executables can easily find the shared library when its
installed in the users home directory or so, but under the same
base-directory.

Andreas
--

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

Reply via email to