AcademySoftwareFoundation / AcademySoftwareFoundation/Imath
Alembic Windows compilation Python3.9.10 `called with non-existent target "Imath::PyImath_Python3_9".`
- Dominant language
- C++
- Stars
- 488
- Forks
- 161
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 3
Description
# Compilation issue on windows
## TLDR:
> CMake Error at python/PyAlembic/Tests/CMakeLists.txt:49 (GET_TARGET_PROPERTY):
> get_target_property() called with non-existent target
> "Imath::PyImath_Python3_9".
## How to reproduce
### Requierements:
- python 3.9.10
- Boost source code (tested with 1.85.0 and 1.81.0, same behavior)
- Imath Source code (3.1.11)
- Alembic source code (1.8.5)
- CMake
- MSVC 14.39.33519
### Compile boost with python binding
You can use b2 or cmake, i have tested with both, but in this example i will detail with cmake, more simple to explain.
So in `/`:
```sh
cmake -S . -B ./build -DBOOST_ENABLE_PYTHON=ON -DPython_ROOT_DIR=C:/python39 -DCMAKE_INSTALL_PREFIX=E:/compile_alembic/boost-1.85.0/install_prefix
cmake --build .\build\ --config Release --target install
```
### Compile IMath
In `/`
```sh
cmake -S . -B ./build -DPYTHON=ON -DCMAKE_INSTALL_PREFIX=E:/compile_alembic/Imath-3.1.11/install -DCMAKE_BUILD_TYPE=Release -DBoost_ROOT=E:/compile_alembic/boost-1.85.0/install_prefix -DPython_EXECUTABLE=C:/Python39/python.exe -DPython3_EXECUTABLE=C:/Python39/python.exe -DBoost_NO_BOOST_CMAKE=OFF
cmake --build .\build\ --config Release --target install
```
### Compile Alembic
```sh
cmake -S . -B ./build/ -DImath_ROOT=E:/compile_alembic/Imath-3.1.11/install -DUSE_PYALEMBIC=ON -DCMAKE_INSTALL_PREFIX=E:/compile_alembic/alembic-1.8.5/install -DBoost_INCLUDE_DIR=E:/compile_alembic/boost-1.85.0/install_prefix/includes/boost-1.85.0 -DCMAKE_BUILD_TYPE=Release
```
And now you should see this error:
```sh
CMake Error at python/PyAlembic/Tests/CMakeLists.txt:49 (GET_TARGET_PROPERTY):
get_target_property() called with non-existent target
"Imath::PyImath_Python3_9".
```
## Things tried
- Recompile boost using b2 then recompile imath
- Recompile boost v1.81.0 using b2 then recompile imath
- Recompile boost v1.81.0 using b2 and theses arguments `release link=shared --python=3.9 --build-type=complete --prefix=.\prefix_install --threading=multi` then recompile imath
- Edit the .cmake file in `/lib/cmake/Imath/ImathTargets-release.cmake` To check if you have the `Imath::PyImath_Python3_9` target, but we don't. , so i have tried to create-it manually, like this
```cmake
set_property(TARGET Imath::PyImath_Python3_9 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Imath::PyImath_Python3_9 PROPERTIES
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/PyImath_Python3_9-3_1.lib"
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/PyImath_Python3_9-3_1.dll"
)
```
Then i also add this in `ImathTargets.cmake`
```cmake
...
add_library(Imath::PyImath_Python3_9 INTERFACE IMPORTED)
set_target_properties(Imath::PyImath_Python3_9 PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "IMATH_DLL"
INTERFACE_COMPILE_FEATURES "cxx_std_11"
INTERFACE_COMPILE_OPTIONS "/EHsc"
INTERFACE_INCLUDE_DIRECTORIES "E:/compile_alembic/boost-1.85.0/install_prefix/includes/boost-1.85.0"
INTERFACE_LINK_LIBRARIES "Imath::ImathConfig"
)
...
```
Everything i tried above, didn't work and when i try to compile without python binding it's works...
I don't know if it's normal or not, but i have searched for this `Imath::PyImath_Python3_9` target, and i didn't find it in any of targets .cmake file under `/lib/cmake/Imath/`, that's why i'm posting this issue here instead of on alembic google group.
Maybe i made something wrong, i'm a beginner with all this compilation pipeline stuff, using Imath and alembic, don't hesistate to share with me some feedbacks or idea.
Thank you
Contributor guide
Research direction
Start at python/PyAlembic/Tests/CMakeLists.txt:49 and inspect the installed Imath target files under /lib/cmake/Imath/. Reproduce the CMake configuration with Windows Python 3.9.10, Boost, Imath 3.1.11, and Alembic 1.8.5; done means the PyAlembic build no longer requests the nonexistent Imath::PyImath_Python3_9 target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100