nlopt icon indicating copy to clipboard operation
nlopt copied to clipboard

Fix/cmake guile

Open pavanakumar opened this issue 2 years ago • 4 comments
trafficstars

FindGuile.cmake does not seem to work everywhere. The pkg-config approach to guile is quite robust and is available in most platforms. This is a cleaned up CMake script for NLopt Guile wrapper.

pavanakumar avatar Feb 03 '23 22:02 pavanakumar

on what platform does it not work ? maybe we dont watn to force require pkgconfig anyways this should stay in findguile

jschueller avatar Feb 04 '23 08:02 jschueller

on what platform does it not work ?

This is failing on my Mac 11.7 (BigSur) and I installed guile using homebrew

maybe we dont watn to force require pkgconfig anyways this should stay in findguile

I do not agree with requiring pkg-config because if you look at the FindGuile.cmake,

if (GUILE_CONFIG_EXECUTABLE)
  execute_process (COMMAND ${GUILE_CONFIG_EXECUTABLE} info prefix
                    OUTPUT_VARIABLE GUILE_ROOT_DIR
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
...

It is using the GUILE_CONFIG_EXECUTABLE=guile-config command that in turn is a wrapper over pkg-config. On certain platforms the execute_command puts extra quotes around OUTPUT_VARIABLE and that is still an unresolved issue with CMake in my experience. Directly using pkg-config from the CMake packages is much safer and is better supported within CMake.

I do agree that this should be inside FindGuile.cmake. Will make these changes and squash it into a single commit and update the pull request.

pavanakumar avatar Feb 04 '23 09:02 pavanakumar

It is using the GUILE_CONFIG_EXECUTABLE=guile-config command that in turn is a wrapper over pkg-config.

No, guile-config is not a wrapper around pkg-config. It is installed as a part of guile itself (e.g. if you build Guile from source and do make install, and in fact is written in Scheme. It's the documented "official" way to find out how to link against guile.

Using guile-config will fail if you haven't installed it into your PATH, but then you should either set your PATH appropriately or pass GUILE_CONFIG_EXECUTABLE=/path/to/guile-config to cmake.

stevengj avatar Feb 06 '23 16:02 stevengj

It is using the GUILE_CONFIG_EXECUTABLE=guile-config command that in turn is a wrapper over pkg-config.

No, guile-config is not a wrapper around pkg-config. It is installed as a part of guile itself (e.g. if you build Guile from source and do make install, and in fact is written in Scheme. It's the documented "official" way to find out how to link against guile.

It does look like a wrapper over the pkg-config on my platform (written in scheme).

prompt> guile-config info --cflags 
error: (“/opt/homebrew/opt/pkg-config/bin/pkg-config” “--variable=--cflags” “guile-3.0”) exited with non-zero error code 127

And please read line 28 of the guile-config.in you sent me it reads as follows

;;; This script has been deprecated. Just use pkg-config.

Using guile-config will fail if you haven't installed it into your PATH, but then you should either set your PATH appropriately or pass GUILE_CONFIG_EXECUTABLE=/path/to/guile-config to cmake.

This doesn't help

pavanakumar avatar Feb 09 '23 09:02 pavanakumar