Thanks a lot, Mizux!
I tried many ways to build my Python extension (cython), but still have problem that finally I have _opt.so (that corresponds to my extension) and I also have separate libortools.so, libortools.so.9 etc. provided by presence of FetcchContent() of ortools. During importing of my extension "import opt" I get "ImportError: libortools.so.9: cannot open shared object file: No such file or directory.
What I want to do is to build my extension _opt.so statically linked with libortools (2nd way is to provide both .so files _opt.so and libortools.so to final users of my extension but I didn't find how to do this except of setting of LD_LIBRARY_PATH which looks not promising )
My final CMakeLists.txt looks as follow. If you have some quick hint in mind I will appreciate if you can share it.
Playing with BUILD_SHARED_LIBS (you can see it in comments did not help).
include(FetchContent)
FetchContent_Declare(
or-tools
GIT_REPOSITORY
https://github.com/google/or-tools.git GIT_TAG master
)
FetchContent_MakeAvailable(or-tools)
set(BUILD_DEPS ON)
set(BUILD_SAMPLES OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_Protobuf ON)
#set(BUILD_SHARED_LIBS OFF)
# provide ortools C/C++ header files to my extension
include_directories(./ ${or-tools_SOURCE_DIR} ${absl_SOURCE_DIR})
add_cython_target(_opt CXX)
add_library(_opt MODULE ${_opt})
target_link_libraries(_opt ortools::ortools)
python_extension_module(_opt)
install(TARGETS _opt LIBRARY DESTINATION opt)
There is also something like 3rd possible way.
I can specify ortools pypi package as a dependency, so during installation of my package the e library _opt.so will be build and installed (so I will use only c/c++ header files from ortools, do not know ho achieve this in cmake with FetchContent() of ortools since I may need not only clone ortools source code but maybe do some extra-steps like generation of protobuf headers...) and I can somehow guess to _opt.so that libortools.so is located in the installation directory of ortools pypi package.
I think this way is also good, it needs to preserve equality of version of ortools used in FetchContent() and version of ortools pypi package.
But: I do not know how to guess to my _opt.so that libortools.so is located in .libs subfolder (as I remember) of the ortools installation folder.
Another cons - I think ortools pypi package has no SCIP on board (?) and I need SCIP.