conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
958 stars 1.76k forks source link

[request] swig/4.1.1 transition to CMakeLists.txt instead of autotools #16557

Open jmarrec opened 1 year ago

jmarrec commented 1 year ago

Package Name/Version

swig/4.1.1

Changelog

https://github.com/swig/swig/pull/2509

Context about the new update

https://github.com/conan-io/conan-center-index/issues/15324#issuecomment-1468079165

I fixed #15324 in #16554 but I'm also opening a PR to upstream some changes to the newly added (in swig 4.1.0) CMakeLists.txt in so we can hopefully transition to using a cmake generator instead of autotools.

jmarrec commented 1 year ago

One thing I'm not clear about is how to handle older versions that do not have a CMakeLists.txt. Keep two subfolders with two recipes?

The config variables to pass to the CMakeLists are going to be -DSWIG_LIB_RELATIVE_TO_EXE:BOOL=ON -DSWIG_LIB_RELATIVE_PATH:STRING=bin/swiglib and that should probably just be it: pcre2 will be found via find_package (PCRE2 REQUIRED) so that should work as is, and we can remove a lot of things (winflexbison, automake, etc are no longer needed).

jmarrec commented 1 year ago

I've started trying to use CMakeLists.txt on https://github.com/jmarrec/conan-center-index/tree/swig/cmakelists. I'm having trouble getting find_package(SWIG) to work in the test_package.

EstebanDugueperoux2 commented 1 year ago

Hi @jmarrec ,

I'm interested by your contribution. If I understand correctly, swig use cmake from 4.1.0 release? Then I think the simpler could be to remove 4.0.x releases, non? What is your trouble with test_package? Is it not better to declare swig as tool_requires?

Regards.

jmarrec commented 1 year ago

Hello @EstebanDugueperoux2 . Yes SWIG added a CMakeLists.txt option in 4.1.0. Beforehand, it only had autotools to build.

My main issue is with the test_package is that I don't know what I'm doing to be honest. conan 2.x is new to me.

CMake has a built-in FindSWIG module, which basically just locates an executable called swig or swig4.0.

I'm trying to upstream a change to SWIG to allow specifying the location of the swiglib directory (which is a directory that contains static text files): https://github.com/swig/swig/pull/2509

When you build SWIG via cmake, it produces the swig executable. When you install, it installs the exe and copies the in-source swiglib directory to the appropriate location relative to this exe (and when you call swig.exe -swiglib it computes that location relative to the current directory the executable is actually in, via dladdr on unix). This directory https://github.com/swig/swig/tree/master/Lib is just installed as is: https://github.com/swig/swig/blob/2171115d380c899e7fd54224142ff2540632ef1e/CMakeLists.txt#L126

I'm having trouble putting the recipe together so it does find the conan-build .exe in the test_package via FindSWIG module.