Skip to content

[opencascade] fix #16252 #16513

Merged
ras0219-msft merged 19 commits intomicrosoft:masterfrom
Dejauxvue:master
Mar 22, 2021
Merged

[opencascade] fix #16252 #16513
ras0219-msft merged 19 commits intomicrosoft:masterfrom
Dejauxvue:master

Conversation

@Dejauxvue
Copy link
Copy Markdown
Contributor

@Dejauxvue Dejauxvue commented Mar 3, 2021

fix #16252 by exporting include directories with the targets and replacing internal includes from #include <...> to #include "..." post installation

tested on x64-windows

…h the targets and replacing internal includes from #include "..." to #include<...> post installation
@ghost
Copy link
Copy Markdown

ghost commented Mar 3, 2021

CLA assistant check
All CLA requirements met.

@NancyLi1013 NancyLi1013 added the category:port-bug The issue is with a library, which is something the port should already support label Mar 4, 2021
Dejauxvue and others added 3 commits March 4, 2021 08:23
Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>
Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>
Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>
@JackBoosY JackBoosY marked this pull request as ready for review March 5, 2021 10:07
@JackBoosY JackBoosY requested a review from NancyLi1013 March 5, 2021 10:07
@NancyLi1013 NancyLi1013 added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Mar 5, 2021
@NancyLi1013
Copy link
Copy Markdown
Contributor

Hi @Dejauxvue

Would you like to add a patch for this changes?

diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in
index 4937103b..cd35e07d 100644
--- a/adm/templates/OpenCASCADEConfig.cmake.in
+++ b/adm/templates/OpenCASCADEConfig.cmake.in
@@ -23,6 +23,7 @@ set (OpenCASCADE_DEVELOPMENT_VERSION "@OCC_VERSION_DEVELOPMENT@")
 # - in Windows style: $INSTALL_DIR/cmake
 get_filename_component (OpenCASCADE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
 get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
+get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
 if (OpenCASCADE_INSTALL_PREFIX MATCHES "/cmake$")
   get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
 endif()

Since it was removed by PR #15997, but it is still a problem in current version. So the patch is required.

@NancyLi1013 NancyLi1013 added requires:author-response and removed info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. labels Mar 9, 2021
@Dejauxvue
Copy link
Copy Markdown
Contributor Author

Hi @Dejauxvue

Would you like to add a patch for this changes?

diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in
index 4937103b..cd35e07d 100644
--- a/adm/templates/OpenCASCADEConfig.cmake.in
+++ b/adm/templates/OpenCASCADEConfig.cmake.in
@@ -23,6 +23,7 @@ set (OpenCASCADE_DEVELOPMENT_VERSION "@OCC_VERSION_DEVELOPMENT@")
 # - in Windows style: $INSTALL_DIR/cmake
 get_filename_component (OpenCASCADE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
 get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
+get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
 if (OpenCASCADE_INSTALL_PREFIX MATCHES "/cmake$")
   get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
 endif()

Since it was removed by PR #15997, but it is still a problem in current version. So the patch is required.

I tried applying the patch directly in a naive way and it doesn't seem to work.
So I tried to reproduce the changes, but I don't really understand what the patch does.
Does it add the line

get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)

directly after the same line? Does this even have any effect?

@sudo-liljoa
Copy link
Copy Markdown
Contributor

Hi @Dejauxvue
Would you like to add a patch for this changes?

diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in
index 4937103b..cd35e07d 100644
--- a/adm/templates/OpenCASCADEConfig.cmake.in
+++ b/adm/templates/OpenCASCADEConfig.cmake.in
@@ -23,6 +23,7 @@ set (OpenCASCADE_DEVELOPMENT_VERSION "@OCC_VERSION_DEVELOPMENT@")
 # - in Windows style: $INSTALL_DIR/cmake
 get_filename_component (OpenCASCADE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
 get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
+get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
 if (OpenCASCADE_INSTALL_PREFIX MATCHES "/cmake$")
   get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
 endif()

Since it was removed by PR #15997, but it is still a problem in current version. So the patch is required.

I tried applying the patch directly in a naive way and it doesn't seem to work.
So I tried to reproduce the changes, but I don't really understand what the patch does.
Does it add the line

get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)

directly after the same line? Does this even have any effect?

just to clear up, it basicly does a cd .. for the install prefix, causing it to install in the correct prefix path instead of the shared subfolder

Copy link
Copy Markdown
Contributor

@ras0219-msft ras0219-msft left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes! This all generally looks great.

However, I notice that the PR doesn't currently include the portfile changes to swap <>s with ""s that you mentioned here. They seem necessary for our MSBuild integration to work.

Could you explain why they aren't needed or add then to this PR?

@Dejauxvue
Copy link
Copy Markdown
Contributor Author

Dejauxvue commented Mar 11, 2021

@ras0219-msft
I had a conversation with @JackBoosY and they suggested that we should add a hint to MSBuild user that they should include the directory manually. (I don't know how to link to a conversation, but you can find it in this thread)

@Dejauxvue Dejauxvue requested a review from JackBoosY March 11, 2021 14:26
@JackBoosY
Copy link
Copy Markdown
Contributor

@ras0219-msft For such ports that export specific include paths in cmake, since we did not provide these paths to msbuild integration after building them, I think that manually adding these paths to the include path of the header file is the only solution.
Because there are too many relative paths included, it is difficult for us to fully consider the included code.

@Dejauxvue
Copy link
Copy Markdown
Contributor Author

shouldn't we then install the includes from opencascade directly to include instead of include/opencascade ?
If adding include/opencascade to the include paths anyways, I don't think, there's much benefit from encapsulating the headers in the include/opencascade subdirectory

@JackBoosY
Copy link
Copy Markdown
Contributor

@Dejauxvue We will have a internal discussion.

@JackBoosY
Copy link
Copy Markdown
Contributor

@Dejauxvue After some discussion, we think that your previous modification to the path in portfile.cmake is correct, please restore it. Sorry.

@Dejauxvue
Copy link
Copy Markdown
Contributor Author

@JackBoosY
No problem, I'll do it later or tomorrow.
Btw, is there a way, I can test installation of a package without rebuilding it every time?
It takes me about 1h each time to find a bug in the post-build portion of the port file

@JackBoosY
Copy link
Copy Markdown
Contributor

@Dejauxvue I wish too but not. Sorry.

….> to #include "...""

also refined regex to allow white spaces between # and 'include'
This reverts commit 4b36273.
Copy link
Copy Markdown
Contributor

@ras0219-msft ras0219-msft left a comment

Choose a reason for hiding this comment

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

This looks great to me, thanks for the hard work here!

Just to double check: you've tested this on x64-windows via CMake; have you tested it via MSBuild? Does it work "out of the box" or is the extra include path required for normal usage?

@Dejauxvue
Copy link
Copy Markdown
Contributor Author

Dejauxvue commented Mar 17, 2021

@ras0219-msft
Thank you for the heads-up!
There are indeed two things that should be adressed:

  • the exported include directory is include/opencascade for cmake. This means that a project configured by cmake needs to include occt headers by #include <gp.hxx>, while code being configured by importing vcpkg.targets into a Visual Studio project needs to include headers by #include <opencascade/gp.hxx>.
    I suggest to change the exported include directory to include instead of opencascade/include so that #include <opencascade/gp.hxx> is always the right way

  • Secondly, when configuring with CMake, The compilation works fine, however the linker does cannot resolve all symbols because some targets don't get exported. At this point, I don't know why this happens, but I'll look into it.

In Summary: MSBuild works; CMake uses different include conventions and not all targets get exported

Edit: I applied my suggested changes for the first issue. The second issue does not seem to be related to my changes, I think. As I did not change what targets get exported. Can someone confirm this?

Edit2: the second issue is probably not an issue, I just did not link my example to all opencascade targets

Edit3: can confirm that the cmake linker error was wrong usage; Tested MSBuild an CMake with the following source code and it compiles and links successfully
occt_test_cmake.zip

@JackBoosY JackBoosY added info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. and removed requires:author-response labels Mar 22, 2021
@ras0219-msft ras0219-msft merged commit c8021b4 into microsoft:master Mar 22, 2021
@ras0219-msft
Copy link
Copy Markdown
Contributor

Yep, this looks like the right solution to me, thanks for the continued improvement!

Just to note specifically in case it wasn't mentioned here: the CMake change adds the root include/ as well, so users can include via either method (prefix with opencascade/ or direct names).

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

Labels

category:port-bug The issue is with a library, which is something the port should already support info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opencascade "Cannot open include file: 'Standard.hxx'"

6 participants