tskit icon indicating copy to clipboard operation
tskit copied to clipboard

Add c/CMakeLists.txt

Open lukashuebner opened this issue 2 years ago • 8 comments

I've been using this CMakeLists.txt using the following code in my code for a while now:

add_subdirectory("extern/tskit/c" "extern/tskit")
target_link_libraries(${MY_TARGET} INTERFACE tskit) # ${MY_TARGET} is header-only, thus INTERFACE

lukashuebner avatar Dec 13 '23 09:12 lukashuebner

Thanks @lukashuebner, this will be really helpful for CMake users!

I wonder if it belongs in the tsk-tbuild-example repo though? It would naturally fit into a CMakesubdirectory

https://github.com/tskit-dev/tskit-build-examples

jeromekelleher avatar Dec 13 '23 09:12 jeromekelleher

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.69%. Comparing base (77faade) to head (8b5cc64). Report is 58 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2880   +/-   ##
=======================================
  Coverage   89.69%   89.69%           
=======================================
  Files          30       30           
  Lines       30159    30159           
  Branches     5860     5860           
=======================================
  Hits        27052    27052           
  Misses       1778     1778           
  Partials     1329     1329           
Flag Coverage Δ
c-tests 86.09% <ø> (ø)
lwt-tests 80.78% <ø> (ø)
python-c-tests 67.89% <ø> (ø)
python-tests 98.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

codecov[bot] avatar Dec 13 '23 10:12 codecov[bot]

Imho, the right place would be in this repo. Otherwise the user would need to maintain a list of tskit's source files, dependencies and build settings themself, which would violate the encapsulation principle. If you prefer the tskit-build-examples repo, though, I can create a PR there.

lukashuebner avatar Dec 15 '23 15:12 lukashuebner

I see your point @lukashuebner, but I don't really want to get into maintaining multiple build-systems within tskit. We've chosen meson here as the libraries build system, and the specific point of the tskit-build-examples repo is to give examples of how to build applications using tskit using different build systems. As the dev docs say:

There are many different build systems and approaches to compiling code, and so it’s not possible to give definitive documentation on how tskit should be included in downstream projects. Please see the build examples repo for some examples of how to incorporate tskit into different project structures and build systems.

So, it would be great if you could add this to the build examples for other CMake users!

jeromekelleher avatar Dec 19 '23 09:12 jeromekelleher

See https://github.com/tskit-dev/tskit-build-examples/pull/7

lukashuebner avatar Dec 20 '23 12:12 lukashuebner

Great, thanks.

Out of interest, did you realise that we had this build-example repo? How was your experience of getting CMake running, and did you find the dev-docs useful?

jeromekelleher avatar Dec 20 '23 17:12 jeromekelleher

I created the CMakeLists.txt a few months back, so I'm not 100 % sure, but I think I didn't know the repo with the build examples existed. Getting CMake running was pretty straightforward though – your meson.build file is easy enough to read and translate to CMake. (I never used Meson and would consider myself an average CMake user.)

lukashuebner avatar Dec 20 '23 17:12 lukashuebner

Maybe we need to signpost this a bit more prominently, say in the README.md in the c directory?

Do you build your applications "in tree" here in the tskit source, or do you then install the headers and lib files to your file system somewhere?

jeromekelleher avatar Dec 20 '23 17:12 jeromekelleher

I'm assuming we're not merging this as it went to the example repo - please reopen if that isn't the case.

benjeffery avatar Sep 23 '24 10:09 benjeffery