Add c/CMakeLists.txt
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
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
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.
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.
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!
See https://github.com/tskit-dev/tskit-build-examples/pull/7
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?
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.)
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?
I'm assuming we're not merging this as it went to the example repo - please reopen if that isn't the case.