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

Adapt options when built as sub-project #249

Closed
wants to merge 1 commit into from
Closed

Adapt options when built as sub-project #249

wants to merge 1 commit into from

Conversation

ClausKlein
Copy link

skipp tests and example build, install only

skipp tests and example build, install only
@d-frey
Copy link
Member

d-frey commented Dec 29, 2020

Shouldn't the test be based on https://stackoverflow.com/questions/25199677/how-to-detect-if-current-scope-has-a-parent-in-cmake? This should prevent problems on Windows due to paths being case-insensitive.

Also, AFAIK, the variable should be prefixed with PEGTL_ to avoid conflicts when used as subproject. And I'd like to avoid the word "master", as we will switch our main branch's name from "master" to "main" when GitHub finished adapting the infrastructure. How about PEGTL_HAS_PARENT or PEGTL_IS_MAIN_PROJECT?

Removing the arguments from endforeach() and endfunction() will not work with older versions of CMake, they were only made optional in CMake 3.14.

I'm unsure about the exact purpose of the part you labelled TODO, it was added by @pleroux0. Paul, is this still required in modern CMake? What exactly does it do and how would it interact with the proposed PR?

@ColinH ColinH changed the title addapt options if build as sub project Adapt options when built as sub-project Dec 29, 2020
@ClausKlein
Copy link
Author

see https://discourse.cmake.org/t/top-project-master-project-vocabulary/412/3

Im not sure about endforeach() and endfunction(). As far as I know, it is not needed sine 3.0.

@d-frey
Copy link
Member

d-frey commented Dec 29, 2020

For endforeach() I'm comparing https://cmake.org/cmake/help/v3.13/command/endforeach.html with https://cmake.org/cmake/help/v3.14/command/endforeach.html, likewise for endfunction().

The link you posted tells me that PARENT_DIRECTORY is the way to go. Are you reading it differently?

@ClausKlein
Copy link
Author

https://discourse.cmake.org/t/top-project-master-project-vocabulary/412/5

If have already seen 2 mechanisms to detect that:

  1. compare CMAKE_CURRENT_SOURCE_DIR and CMAKE_SOURCE_DIR
  2. compare CMAKE_PROJECT_NAME and PROJECT_NAME

I always use option 1. The second option technically isn’t guaranteed, since a project name isn’t required to be unique.
[/quote]

@d-frey
Copy link
Member

d-frey commented Dec 29, 2020

I've seen that. But that is only a part of what is written there. And quite frankly, just quoting back some part doesn't really explain your view.

You are leaving out the third option (the one I was talking about). That third option was added by Brad King, a core developer of CMake. The /5 comment doesn't really show any problem with it, just that the author had some problem which could very well be caused by something else as the author himself explains.

Also, in the link to SO that I posted above, option 3 is the accepted answer, the person that wrote it has a gold badge for CMake on SO.

And finally, I told you that your solution (option 1) could lead to problems on Windows as you need to compare case-insensitive. See also https://stackoverflow.com/a/42716588/2073257

@d-frey d-frey closed this in 2b37dc6 Dec 29, 2020
@ClausKlein
Copy link
Author

And finally, I told you that your solution (option 1) could lead to problems on Windows as you need to compare case-insensitive. See also https://stackoverflow.com/a/42716588/2073257

That is simply not true. On OSX, the filesystem is also not case sensitive. I never had problems with this.
If it were a Problem, the cmake would have problems too, then it create for every source dir a binary dir. In case of 2 dirs only different in case, there would be an Error!

It seems, you dit not see the main point of my patch: the different behaviour in case of a subproject.
You will use PEGTL as a submodule in json. but in this case, you have to change the options manually.

No one should make his project in this way.

@d-frey
Copy link
Member

d-frey commented Dec 29, 2020

I did see that. Isn't the commit which closes this doing just that?

@ClausKlein
Copy link
Author

@d-frey
Copy link
Member

d-frey commented Dec 29, 2020

Thanks, I removed the arguments now. FWIW, they should update the documentation.

@d-frey
Copy link
Member

d-frey commented Dec 29, 2020

It seems option 1 (what you suggested) actually works, while option 3 (the one I found and used) doesn't. I do not understand why option 3 does not work, but it is what it is. The problem seems to show up when I try and use the updated PEGTL in taoJSON. So, despite the arguments made on SO, let us hope that the case-sensitivity is not a problem anymore. I found some folks saying it was related to CMake converting some paths to lower-case, but this is (hopefully) fixed by now? We'll see.

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

Successfully merging this pull request may close these issues.

2 participants