Making existing, compiled projects CMake aware

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

Making existing, compiled projects CMake aware

Saad Khattak
Hi,

I tried searching for an example project (perhaps already on github) to follow but my Google skills have failed me.

There are some projects that are already compiled and I would like to fork those projects and write a CMakeLists.txt file for them such that they can be added by other CMake projects easily.

For instance, for the library: https://github.com/ygpark/Everything-SDK, how would I write a CMakeLists.txt file such that:

=> the project has a CMake library named "Everything" (which is normally the result of add_library)
=> it's headers, lib and dll files specified in the target "Everything" properly
=> install() command to install the above for the target "Everything"
=> CMake generates the relevant "-config.cmake" file so that the library can be easily found using the find_library() command

If an example already exists using modern CMake techniques, a link to it would be wonderful.

Thanks,
Saad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Making existing, compiled projects CMake aware

Johannes Zarl-Zierl
Hello Saad,

On Dienstag, 14. November 2017 18:38:17 CET Saad Khattak wrote:
> There are some projects that are already compiled and I would like to fork
> those projects and write a CMakeLists.txt file for them such that they can
> be added by other CMake projects easily.

In my experience, looking at other projects and how they switched to CMake is
usually not very helpful. After all, you can only see the resulting
CMakeLists.txt but no steps how it was created.

What you can do instead, is to just write the CMakeLists.txt from scratch and
keep it simple (i.e. don't introduce complexity that you don't understand).

Before starting, it might be a good idea to update your knowledge about modern
C++. A good starting point is the "Modern CMake" talk by Daniel Pfeiffer,
especially the part about how to add and link to libraries:
https://youtu.be/bsXLMQ6WgIk?t=818

> For instance, for the library: https://github.com/ygpark/Everything-SDK,
> how would I write a CMakeLists.txt file such that:
>
> => the project has a CMake library named "Everything" (which is normally
> the result of add_library)

As you already said: use add_library.

> => it's headers, lib and dll files specified in the target "Everything"
> properly

This is also explained in the linked video. The official documentation is here:

https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.
7.html#transitive-usage-requirements

> => install() command to install the above for the target "Everything"
> => CMake generates the relevant "-config.cmake" file

This is documented here:

https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html

> so that the library
> can be easily found using the find_library() command

I guess you meant to write find_package(), not find_library()


HTH,
  Johannes

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Making existing, compiled projects CMake aware

Raymond Wan-2
Hi Johannes,


On Wed, Nov 15, 2017 at 8:50 PM, Johannes Zarl-Zierl
<[hidden email]> wrote:
> Before starting, it might be a good idea to update your knowledge about modern
> C++. A good starting point is the "Modern CMake" talk by Daniel Pfeiffer,
> especially the part about how to add and link to libraries:
> https://youtu.be/bsXLMQ6WgIk?t=818


I'm sorry to jump into this discussion but I was looking through this
video and it was very helpful!  Thank you for posting it; I was not
aware of it!

Unfortunately, I know CMake but I haven't actively used it for many
years and this video showed me that I'm very out of date.  I think
Daniel used the phrase about doing things that are "so version 2.8"...
That more or less describes me.  ;-(

Do you or anyone else on this list have suggestions on moving someone
like me to the latest CMake?  For example, a tutorial, for example.  I
noticed this:  https://cmake.org/cmake-tutorial/ and I wonder if this
tutorial uses recent CMake practices...  The "cmake_minimum_required
(VERSION 2.6)" at the top makes me wonder whether or not it is
up-to-date.

If not, can anyone suggest one?

I guess CMake 2.8 practices could still work but since it's been a
while for me, maybe I should start with recent practices and put what
I used to do behind me.  Any suggestions would be appreciated...thank
you!

Ray
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake