Reputation: 42188
In my CMake I have:
find_package(PythonInterp 3.6 REQUIRED)
This works fine when I execute cmake ., because I have python3.6 in /opt/local/bin. However, when CLion executes the same cmake, it is unable to find it. How can I make it aware?
I tried adding /opt/local/bin to PATH and adding a python interpreter setting, but nether worked for that.
Upvotes: 2
Views: 19012
Reputation: 724
I solved this issue by adding an extra parameter to cmake which is: Python3_EXECUTABLE
cmake -DPython3_EXECUTABLE=/path/to/bin/python3 ..
Upvotes: 6
Reputation: 1433
One thing to try is temporarily set CMAKE_PREFIX_PATH
with /usr/local
where python is installed in some platforms (happens in macOS).
+ set(CMAKE_PREFIX_PATH_bak ${CMAKE_PREFIX_PATH})
+ set(CMAKE_PREFIX_PATH "/usr/local")
find_package(PythonInterp)
+ set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH_bak})
Upvotes: 1
Reputation: 42188
I was able to figure it out. It is possible to add env variables to cmake execution: look for env
in here https://cmake.org/cmake/help/latest/manual/cmake.1.html
Knowing this it was easy to add it in clion: Settings/Preferences -> Build, Execution, Deployment -> CMake -> CMake Options
and add into that field env PATH=${PATH}:/opt/local/bin
.
Upvotes: 0