tpaviot / oce

OpenCASCADE Community Edition (OCE): a community driven fork of the Open CASCADE library.
http://groups.google.com/group/oce-dev
GNU Lesser General Public License v2.1
820 stars 284 forks source link

OCE-libraries-release.cmake 3rd party libs are referenced to local build dir, not install dir #592

Open sanderboer opened 8 years ago

sanderboer commented 8 years ago

Hi,

In $OCE_INSTALL/cmake/OCE-libraries-release.cmake 3rd party references are referred to the local build dir.

This can be found in the OCE-0.17-MINGW32 release:

D:/Devel/freetype-2.3.5-1-bin/bin/freetype6.dll in for instance:

set_target_properties(TKOpenGl PROPERTIES
  IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/Win32/lib/libTKOpenGl.dll.a"
  IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "TKernel;TKService;TKV3d;glu32;opengl32;D:/Devel/freetype-2.3.5-1-bin/bin/freetype6.dll;vfw32"
  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/Win32/bin/libTKOpenGl.dll"
  )

I replaced: D:/Devel/freetype-2.3.5-1-bin/bin/ with: ${_IMPORT_PREFIX}/Win32/lib/

and all was well.

I recompiled oce-git master this week with msys-ming-w64 on windows 10 and this behavior was still present.

kind regards, Sander

ghost commented 8 years ago

I can confirm this, however not sure where to look to fix.

tpaviot commented 8 years ago

The files oce-libraries.cmake and oce-libraries-release.cmake are automatically generated by cmake.

Every third pat library for manually specified paths at cmake configuration time will be exported as is. I don't know if it's possible to set a relative path.

Warmyone commented 4 years ago

Im not sure if it is helpful for the issue but CMake does have generator-expressions. $<INSTALL_INTERFACE:...> and $<BUILD_INTERFACE:...> could be useful.

Instead of

target_link_libraries(${TOOLKIT} optimized ${lib})

, which to my knowledge contains freetype, it could be

target_link_libraries(${TOOLKIT} optimized
   $<BUILD_INTERFACE:${lib}>
   $<INSTALL_INTERFACE:%relativePath%>
)

The relative path would need to be composed platform dependent or the libs would need to be copied into a common location instead of e.g. Win64/lib. Here is a more detailed description of the feature.

Warmyone commented 4 years ago

On another project I ran into this bug again, so here is my attempt to fix it (https://github.com/tpaviot/oce/compare/OCE-0.18.3...Warmyone:OCE-0.18.3_relative-cmake-install-paths). I don't know the proper way to contribute, so should I just create a request from my fork? As a side effect the changes will make the OCE binaries portable (at least my locale build was) and one could also provide prebuild binaries.

There is a related issue (https://gitlab.kitware.com/cmake/cmake/-/issues/17756) at CMake. I also posted my fix there and asked for better alternatives and for further discussion stated the pitfalls I know of. The solution is based on generator-expressions and configure_package_config_file.

Changes: