Strange CMake error. Not possible to link against VSG

335 views
Skip to first unread message

rollastre prostrit

unread,
Aug 11, 2022, 3:12:57 AM8/11/22
to VulkanSceneGraph Developer Discussion Group
I am getting more and more this error which I am unable to understand and fix.

CMake Error at /lib/cmake/vsg/vsgTargets.cmake:61 (set_target_properties):
 The link interface of target "vsg::vsg" contains:                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                              
   Vulkan::Vulkan                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                              
 but the target was not found.  Possible reasons include:                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                              
   * There is a typo in the target name.                                                                                                                                                                                                                                      
   * A find_package call is missing for an IMPORTED target.                                                                                                                                                                                                                   
   * An ALIAS target is missing.                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              
Call Stack (most recent call first):                                                                                                                                                                                                                                           
  /lib/cmake/vsg/vsgConfig.cmake:22 (include)                                                                                                                                      
 CMakeLists.txt:200 (find_package)  


This error happens when I try to build  an application linking to VSG (i.e. not the VSG code itself). I have this lines in the CMakeLists.txt file

196:   # find vulkan
197: find_package(Vulkan REQUIRED)
198: message("Vulkan was found")
199: # find the vsg
200: find_package(vsg REQUIRED)
201:   find_package(RAPIDJSON REQUIRED)          

As error happens in line 200, Vulkan was found (I even see the "Vulkan was found" message in CMake's output). So the question here is why linking to vsg::vsg complains about Vulkan::Vulkan not being found? Anyone can help me how to fix or workaround this?

Thanks in advance

Robert Osfield

unread,
Aug 11, 2022, 3:40:15 AM8/11/22
to vsg-...@googlegroups.com
Hi Rollastre,

You haven't provide enough info to guess what the problem might be.

What OS and build tools are you using?

Which version of Vulkan do you have installed?

Which VSG projects have you built and installed?

Do they all build and install OK?

Have you run the vsgExamples?

Cheers,
Robert


rollastre prostrit

unread,
Aug 11, 2022, 7:22:28 AM8/11/22
to vsg-...@googlegroups.com

HI Robert, thanks. Please find more info inlined. Hopefully there is something revealing in it.

On 11/08/2022 09:40, Robert Osfield wrote:
Hi Rollastre,

You haven't provide enough info to guess what the problem might be.

What OS and build tools are you using?

I've seen this in all OSes I tried so far (Linux, Windows, Mac, and in this case Android). So, this seems to be a general thing. I wonder if it is a bug, actually.

I build with CMake. The only thing that might be somehow not standard is that I use conan to satisfy dependencies. I have conan recipes for both Vulkan and VSG which work fine and build (apparently at least). When I run this, 


cmake .. -DCMAKE_BUILD_TYPE="Debug"  \
         -DCMAKE_SYSTEM_NAME="Android"  \
         -DANDROID_PLATFORM_LEVEL=26  \
         -DANDROID_STL="c++_shared"  \
         -DANDROID_ABI=armeabi-v7a  \
         -DANDROID_NDK_RELEASE=25.0.8775105  \
         -DANDROID_NDK=/opt/android/AndroidSdk/ndk/25.0.8775105  \
         -DCMAKE_INSTALL_PREFIX=$PWD/install  \
         -DGRADLEW=/opt/Qt/5.14.1/Src/qtwebengine/src/3rdparty/chromium/third_party/flatbuffers/src/android/gradlew  \
         -DCMAKE_ANDROID_SDK=/opt/android/AndroidSdk/  \
         -DJRE_HOME=/opt/android/android-studio/jre/  \
         -DVulkan_INCLUDE_DIR=/opt/android/AndroidSdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/vulkan \
         -DVulkan_LIBRARY=/opt/android/AndroidSdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/26/libvulkan.so \

this is the output I get
-- Android: Targeting API '19' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 14.0.6
-- The CXX compiler identification is Clang 14.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/android/AndroidSdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/android/AndroidSdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Vulkan was found
-- Reading 'vsg_...' macros from /home/asdf/.conan/data/VSG/1.0.0/iq/stable/package/1664ab4246b84981441010297bbba701e9349bba/lib/cmake/vsg/vsgMacros.cmake - look there for documentation
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE   
Vsg was found
-- Found RAPIDJSON: /home/asdf/.conan/data/rapidjson/1.1.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include   
-- Found components for RapidJSON
-- RAPIDJSON_ROOT_DIR  = /home/asdf/.conan/data/rapidjson/1.1.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
-- RAPIDJSON_INCLUDES  = /home/asdf/.conan/data/rapidjson/1.1.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include
RapidJSON was found
INFO: PACKAGE_NAME is not set, using default com.iconiqlabs
INFO: MAIN_LIB_NAME not set, using default APP_NAME (which becomes libsimple_app_gui.so)
-- Configuring done
CMake Error at /home/asdf/.conan/data/VSG/1.0.0/iq/stable/package/1664ab4246b84981441010297bbba701e9349bba/lib/cmake/vsg/vsgTargets.cmake:61 (set_target_properties):
 The link interface of target "vsg::vsg" contains                  
   Vulkan::Vulkan                                                                                                                             
 but the target was not found.  Possible reasons include:                   
   * There is a typo in the target name.
   * A find_package call is missing for an IMPORTED target.
   * An ALIAS target is missing.                                                                                                                                                                                                            
Call Stack (most recent call first):                                                                                                                                                                                                        
 /home/asdf/.conan/data/VSG/1.0.0/iq/stable/package/1664ab4246b84981441010297bbba701e9349bba/lib/cmake/vsg/vsgConfig.cmake:22 (include)                                                                                                    
 CMakeLists.txt:206 (find_package)                                   
                                                                                                                                                                       Well, I might be wrong, but I'd say that CMake is able to find vulkan and VSG (and other unrelated 2 dependencies: RapidJSON and GTest). You can see here that RapidJSON, VSG and Vulkan are found and the that Configure step goes through. That is, "Vulkan was found", "VSG was found" and "RapidJSON was found" which correspond to
# find vulkan
find_package(Vulkan REQUIRED)
message("Vulkan was found")
# find the vsg
find_package(vsg REQUIRED)
message("Vsg was found")
find_package(RAPIDJSON REQUIRED)
message("RapidJSON was found")


in the CMakeLists.txt file

However, what puzzles me is that Generation step fails in a line that succeded in Configuration step (find_package(vsg REQUIRED)). 


Which version of Vulkan do you have installed?

In this case, the one coming from the Android NDK 25 (I am not sure which one it is). But, again, experience this in 1.2.182.0 and now in version 1.3.216.0 when in other OSs

Which VSG projects have you built and installed?

Just VSG. I.e. no vsgExamples, no vsgXChange, and the like.

Do they all build and install OK?

I'd say so, yes.

Have you run the vsgExamples?

No, not really.

Cheers,
Robert


--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BVJNKjC9jHwgkYfvbUjF6G03jU%2BFjmPe80dSJFxA4Yc_g%40mail.gmail.com.

Robert Osfield

unread,
Aug 11, 2022, 11:59:12 AM8/11/22
to vsg-...@googlegroups.com
Hi Rorollastre,

I have zero knowledge and experience with conan so will have to defer to you and others about how one integrates it with CMake.

On the VSG side it uses CMake config support for defining details about the VulkanSceneGraph library and headers, perhaps conan and CMake config scripts aren't playing nice with each other.  It may be best to look at CMake config/conan discussions online to see if there is anything relevant to getting it to integrate better.

This may be useful but might not be helpful at all, but over the past week I've been trying to improve the VSG and associated VSG libs to work properly as part of CMake build that pulls in the required VSG components via git submodule or via CMake FetchContent.  I have created BuildFlexibility branches of the VSG, osg2vsg, vsgXchange, vsgImGui, vsgQt, vsgExamples and vsgFramework.

vsgFramework pulls in all the main VSG component libraries so is a good place to start. 

I would add in all the links here but I am struggling to type due injuring my right wrist at the weekend, so for now just head over vsg-dev on github and browse the BuildFGlexibilty branches to see what cganges I had to make.

I mention all this as there is a chance that there may be some overlap with coaxing CMake to allow projects to built in many different ways, and handling the passing on of library settings between projects.

Cheers,
Robert

Gareth Francis

unread,
Aug 11, 2022, 2:00:27 PM8/11/22
to vsg-...@googlegroups.com
Hi Rollastre,

Specifically for android - You shouldn't need to specify the vulkan include / lib directories, rather using toolchain files is likely the standard/recommended approach:

cmake . -DCMAKE_TOOLCHAIN_FILE=$(dirname $(which ndk-build))/build/cmake/android.toolchain.cmake -DANDROID_ABI=ameabi-v7a -DANDROID_PLATFORM=32 -DBUILD_SHARED_LIBS=ON
As Vulkan is included in the NDK, that toolchain file should configure everything you need, and provide the FindVulkan.cmake (allowing package search to work). The toolchain file has various options for STL variant, platform/compilers, etc.

I haven't touched Conan in a while, but expect it can provide a similar toolchain file. That would be in line with other cmake-integrated package managers.
I've personally built vsg against a vcpkg install (Windows & Linux), which installs packages to a local sysroot, and provides a toolchain file for cmake to use - Given that, calls to find_package search the vcpkg install tree rather than the system (vcpkg is tightly integrated into cmake, I believe conan had similar concept when I last looked).

What may be happening is that you've provided the vulkan location, but for some reason it's only created a 'vulkan' target, rather than the new style 'Vulkan::Vulkan' cmake target. I've seen similar issues when using an outdated CMake, or one with a broken FindVulkan.cmake or similar (though I haven't seen this with vulkan specifically).

On either a Linux or Android build, it's worth trying the toolchain file approach, or if you've got a minimal test case on Linux I could try and reproduce this (I've been meaning to learn Conan at some point).

(Hope you heal quickly Rob)

Thanks
Gareth


--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.


--
----
Gareth Francis
www.gfrancisdev.co.uk
Reply all
Reply to author
Forward
0 new messages