Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add c/CMakeLists.txt #2880

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukashuebner
Copy link

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 lukashuebner marked this pull request as draft December 13, 2023 09:23
@jeromekelleher
Copy link
Member

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

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Merging #2880 (8b5cc64) into main (77faade) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           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.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77faade...8b5cc64. Read the comment docs.

@lukashuebner
Copy link
Author

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.

@jeromekelleher
Copy link
Member

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!

@lukashuebner
Copy link
Author

@jeromekelleher
Copy link
Member

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?

@lukashuebner
Copy link
Author

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.)

@jeromekelleher
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants