google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.97k stars 2.1k forks source link

cmake: BUILD_DEPS does not include a BUILD_SWIG option #4298

Open SYury opened 2 months ago

SYury commented 2 months ago

What language and solver does this apply to? CMake build

Describe the problem you are trying to solve. I'm building OR-Tools Python package from source on an Ubuntu machine:

cmake -S. -Bbuild -DBUILD_DEPS:BOOL=ON -DBUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release

I don't have the rights to install packages from apt, so I build the dependencies from source.

Everything is ok when I build the C++ library without Python, but when I build the Python package it fails with Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR). Apparently, BUILD_DEPS does not include SWIG.

Describe the solution you'd like Fetch and build SWIG from source when both BUILD_DEPS and BUILD_PYTHON are on.

lperron commented 2 months ago

Unsure.

There are other things you need to install anyway, python-dev for instance, that are not installed by default.

So I am not convinced this will enable sudo-less builds

Mizux commented 2 months ago

seems SWIG has a cmake based build ref: https://github.com/swig/swig/blob/master/CMakeLists.txt

Need to add it to the todo list for 2042 or beyond ^^;

note: may need to try to add it to https://mizux.dev/python-native to fast iterate on the dev then bakcport to or-tools once ready

ps: BUILD_PYTHON set BUILD_DEPS to ON by default, so don't need to specify both ;) aka by default we prefer to provide a standalone wrapper package (note: we also build every deps as statis lib to avoid to ship dozen of .so + windows don't support RUNPATH..) https://github.com/google/or-tools/blob/528badffd9b9576c8dc283749a2b06c600519a4a/CMakeLists.txt#L161-L167 also https://github.com/google/or-tools/blob/528badffd9b9576c8dc283749a2b06c600519a4a/CMakeLists.txt#L49-L53