artoolkitx icon indicating copy to clipboard operation
artoolkitx copied to clipboard

ARX.cmake in "1.0.5.1/artoolkitX.for.Windows.v1.0.zip" contains absolut path to pthreadVC2static.lib, which is not contained

Open Warmyone opened this issue 4 years ago • 5 comments

I downloaded "1.0.5.1/artoolkitX.for.Windows.v1.0.zip" as 1.0.6 does not have a windows download. Found "ARX.cmake" in a sub dir and therefore wanted to use cmake's find_package:

find_package(ARX CONFIGS ARX.cmake REQUIRED)

Configuring works but if I want to build I get this error:

ninja: error: 'D:/a/1/s/Source/depends/windows/lib/x64/pthreadVC2static.lib', needed by 'bin/***.exe', missing and no known rule to make it

I looked into "ARX.cmake" and found this line.

INTERFACE_LINK_LIBRARIES "opengl32;glu32;OpenGL32;D:/a/1/s/Source/depends/windows/lib/x64/pthreadVC2static.lib" 

When replacing "D:/a/1/s/Source/depends/windows/lib/x64/pthreadVC2static.lib" with "pthreadVC2static.lib" it will build but than fail to link to it. The lib is not contained in the .zip so I cannot do anything about that.

If i run build.sh in the sources the created "ARX.cmake" again contains an absolut path to the location in the source tree. Furthermore all created files are spread throughout the build dir and I cannot find install instructions anywhere which might use relative paths and copy the libs in the right place.

What is the expected way to fix? Or is there an other approach to use the sdk on windows without building it on each system?

Warmyone avatar Mar 29 '20 18:03 Warmyone

I Never build artoolkitx under Windows, because I have a Linux machine, for sure it is an error, maybe try to replace that line "D:/a/1/s/Source/depends/windows/lib/x64/pthreadVC2static.lib" with simply pthread. I have no other suggestions...

kalwalt avatar Mar 29 '20 18:03 kalwalt

If I am not mistaking pthread is Linux only. For the msvc on windows you need pthreadVC2. What seems to work is to download it from the sources https://github.com/artoolkitx/artoolkitx/raw/master/Source/depends/windows/lib/x64/pthreadVC2static.lib and exchange D:/a/1/s/Source/depends/windows/lib/x64/pthreadVC2static.lib with a path to the downloaded file. But I guess that is not the intended way to get the sdk for windows.

Warmyone avatar Mar 30 '20 12:03 Warmyone

Yes, you are right for sure this is not the intended way... Sorry, i can not help much on this issue! For sure @philip-lamb or @ThorstenBux may help you.

kalwalt avatar Mar 30 '20 12:03 kalwalt

Im not sure if it is helpful for the issue but CMake does have generator-expressions. $<INSTALL_INTERFACE:...> and $<BUILD_INTERFACE:...> could be useful.

Instead of

target_link_libraries(ARX
   PUBLIC ${PTHREAD_LIBRARIES}
...
)

it could be

install(FILES ${PTHREAD_LIBRARIES} DESTINATION ${ARX_INSTALL_LIBRARY_DIR})
target_link_libraries(ARX
   PUBLIC
      $<BUILD_INTERFACE:${PTHREAD_LIBRARIES}>
      $<INSTALL_INTERFACE:%relativePath%>
...
)

The relative path would need to be composed platform dependent, e.g. for windows it would could be ${ARX_INSTALL_LIBRARY_DIR}/pthreadVC2static.lib. Here is a more detailed description of the feature.

Warmyone avatar Mar 30 '20 16:03 Warmyone

pthreads is used on Windows too via the pthreads-win32 library, which is the one that's being linked here. It's provided in the project (see https://github.com/artoolkitx/artoolkitx/blob/master/Source/depends/windows/lib/x64/pthreadVC2static.lib) but having the full path to that library in the CMake module is obviously a bug.

What I'd suggest as a short-term workaround is to just copy the above library out of artoolkitx into your own link libs folder, and adjust the cmake module path. I'll have to investigate why the full path is being included.

philip-lamb avatar Mar 30 '20 23:03 philip-lamb