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

Make snowhouse a CMake library #38

Merged
merged 1 commit into from
Jan 9, 2019
Merged

Conversation

HauserV
Copy link
Contributor

@HauserV HauserV commented Oct 5, 2018

Adds CMake library target for snowhouse enabling importing the library to user CMake targets. Example follows.

shell$ git clone https://github.com/banditcpp/snowhouse.git

# CMakeLists.txt
add_subdirectory(snowhouse)
add_executable(app main.cpp)
target_link_libraries(app snowhouse)

Notes:

  • the header files were moved to include/ dictionary to enable including the headers only
  • building&running of tests is disabled by default to avoid cluttering users' target list

Copy link
Member

@sbeyer sbeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

If I get your point right, your changes make it easier for users to use Snowhouse as a library: although it is already easy because it's header only; user's shouldn't even care if it's header-only or not, they should just use target_link_libraries and all the magic is done... Is that the point?

[Monologue start] I think the CMake configuration was basically intended for the tests (thus the defaults) and not for potential Snowhouse users. I have never considered before to change this... But if it simplifies things for users that way, let's do it, and I'd also be okay with that default changes. On the other hand, I know that CMake offers installation magic to use with find_library()... wouldn't that even be easier for the user? I am not sure. One is for having a system-wide installation and the other is for shipping snowhouse with your code... Probably your change is a start and the installation stuff is a nice-to-have feature. Both ways could be used by users complementarily... [Monologue end]

Besides my review commits in the diff, your pull request is missing documentation changes. If it is now easy to use snowhouse as a library, the users should get to know it.

Edit: I am very sorry, I was only looking at the diff of the first commit, not at the diff of the whole pull request. I am very tired at the moment and should have deferred the comments.

@@ -6,7 +6,7 @@
#ifndef SNOWHOUSE_COLLECTIONOPERATOR_H
#define SNOWHOUSE_COLLECTIONOPERATOR_H

#include "../constraintoperator.h"
#include "../../operators/constraintoperator.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hu? What has happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the refactoring tool had a slight hiccup there. Both of those paths are equivalent. Sorry.

CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated
@@ -55,3 +62,4 @@ if (SNOWHOUSE_BUILD_TESTS AND SNOWHOUSE_RUN_TESTS)
elseif (SNOWHOUSE_RUN_TESTS)
message(WARNING "Unable to run snowhouse tests - set:\n option(SNOWHOUSE_BUILD_TESTS, \"Build the Snowhouse tests\" ON)\nand clear your CMakeCache.txt")
endif()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not completely sure what am I supposed not to do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding an empty line :-)

CMakeLists.txt Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@sbeyer
Copy link
Member

sbeyer commented Oct 5, 2018

By the way I'm wondering if the move of the files is a breaking change (because existing build configurations (i.e., include paths) must be changed)... That would mean Snowhouse has to advance to version 4.0.0. This is funny because it rather feels like a minor change leading to 3.1.0... What do you think? ;-)

@HauserV
Copy link
Contributor Author

HauserV commented Oct 5, 2018

Sorry for the late replay, you've caught me on the way home from work...

It depends on the way people actually include the library... I think that there is a way how to avoid bumping the version: since all paths in the #includes are relative to the snowhouse folder (now include/snowhouse) we could simply add a symlink pointing to that directory.

@HauserV
Copy link
Contributor Author

HauserV commented Oct 5, 2018

To answer the first set of questions. Yep, making it easier to use the library in CMake projects was exactly my goal. I had to do these changes manually to make the library work with my current build setup seamlessly and so I thought that others might benefit from it as well. Find_library seems a little bit too complex because you have to deal with the paths to the library and since there is no make install or similar step, it might be quite difficult to write one that would be universal. Investing time into writing proper exported targets and CMake install steps would be more useful (but I am not sure whether it's actually worth it).

@HauserV HauserV force-pushed the master branch 2 times, most recently from cab1ce9 to 8f23480 Compare October 5, 2018 20:45
@sbeyer
Copy link
Member

sbeyer commented Oct 5, 2018

To answer the first set of questions. Yep, making it easier to use the library in CMake projects was exactly my goal. I had to do these changes manually to make the library work with my current build setup seamlessly and so I thought that others might benefit from it as well.

The way I had thought about it before is that you do not add it to the CMake setup at all, you simply use the headers-only branch version as a submodule in the right location and hence you don't need any additional include paths.

However, I can imagine that this is not the best choice for everyone. So it's nice to have this alternative.

You wrote on the breaking change issue:

It depends on the way people actually include the library... I think that there is a way how to avoid bumping the version: since all paths in the #includes are relative to the snowhouse folder (now include/snowhouse) we could simply add a symlink pointing to that directory.

That's a solution I have also considered, however, a symlink is not portable (please remove it again). I'd rather bump the version. (Btw you don't have to make any changes regarding version or anything; that's my task. I just wanted an opinion.)

You wrote on exported targets and find_library:

(but I am not sure whether it's actually worth it)

Yes, I also doubt that.

I once did that for another project, a more complex library, and it seems there is a lot that you can miss and do wrong... so let's keep it simple.

@sbeyer
Copy link
Member

sbeyer commented Oct 5, 2018

a symlink is not portable (please remove it again)

While at it, it would be nice if you do a git rebase -i master your changes and squash (fixup) the "Fix odd #include, remove dangling newline" commit into the first commit. And while at it, please also reword the "set RUN_TESTS[…]" commit title to "Run tests on Travis CI again". Both these changes make the history clearer for me ;-)

@HauserV
Copy link
Contributor Author

HauserV commented Oct 5, 2018

The way I had thought about it before is that you do not add it to the CMake setup at all, you simply use the headers-only branch version as a submodule in the right location and hence you don't need any additional include paths.

Well, the difference here is that I acrtually want CMake to manage the paths for me so that I don't have to care where I had put the library: in your case I would have to include the snowhouse which is located in ../../third_party_libs_dir/snowhouse or something like that while in this case I can just say that I want snowhouse and if the actual path changes because I move it elsewhere, CMake fixes that itself.

That's a solution I have also considered, however, a symlink is not portable (please remove it again). I'd rather bump the version. (Btw you don't have to make any changes regarding version or anything; that's my task. I just wanted an opinion.)

Really? I use them in git projects regularly. I have actually created the link in Windows and pushed the repo from Linux (WSL) and it worked well in both but hey, you're the maintainer. Will remove it.

README.md Outdated
target_link_libraries(app snowhouse)
```


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I have very strong relational issues with empty lines. ;-) Please remove one of them.

This moves headers into a new include/ directory
and turns off default running/building of tests.
Document the CMake-based installation.
Support for CMake < 3.0.0 is retained.
@sbeyer sbeyer merged commit b25c70f into banditcpp:master Jan 9, 2019
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.

2 participants