Build cmake dependency

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Build cmake dependency

Pietro Paolini
Hi all,

I really cannot say I am an expert with CMake however I have been using
it for a while now, even though mainly by copying and pasting snippet
of code from the web therefore not understanding things properly.

I am working on a project which depends on a libary which is itself
built using CMake, I'd like my project to build the library itself
during its own build and I can successfully do that by adding the
folder to the root CMakeLists.txt of my current prject, however I
couldn't find a way to include its headers and link the shared object.

I had to resort to a bash script which compiles and installs the
dependency in a pre-defined location and add such location to my
project's CMake's setting file through the use of
include_directories()/link_directories(). It works but I'd like to get
CMake to do what I want and not having to find workaroun, I am pretty
confident I am missing something here, is there a better way to do that
?


Thanks,
Pietro


--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Build cmake dependency

Scott Bloom
You may want to move this to https://discourse.cmake.org/, as this mailing list is going away (note, Im not with the cmake org at all.. just a user..)

That said,typically, when a CMake based library is included into a larger cmake project, it will set some variables.  SUBLIB_DIR for instance..  so you would then, in the top project do something like

include_directories( ${SUBLIB_DIR }/include )

If it doesn't create the directory, I would do the following

set( SUBLIB_DIR ${CMAKE_SOURCE_DIR}/SubLibName )
add_subdirectory( ${SUBLIB_DIR} )

for the output of the library, you can in your executable target_link_libraries directly list the target project name

target_link_libraries( MyExe SubLib )

Scott

-----Original Message-----
From: CMake [mailto:[hidden email]] On Behalf Of Pietro Paolini
Sent: Friday, February 28, 2020 1:19 AM
To: [hidden email]
Subject: [CMake] Build cmake dependency

Hi all,

I really cannot say I am an expert with CMake however I have been using it for a while now, even though mainly by copying and pasting snippet of code from the web therefore not understanding things properly.

I am working on a project which depends on a libary which is itself built using CMake, I'd like my project to build the library itself during its own build and I can successfully do that by adding the folder to the root CMakeLists.txt of my current prject, however I couldn't find a way to include its headers and link the shared object.

I had to resort to a bash script which compiles and installs the dependency in a pre-defined location and add such location to my project's CMake's setting file through the use of include_directories()/link_directories(). It works but I'd like to get CMake to do what I want and not having to find workaroun, I am pretty confident I am missing something here, is there a better way to do that ?


Thanks,
Pietro


--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org