CMake - choosing build type in downstream application #628
Unanswered
rolandhill
asked this question in
Q&A
Replies: 1 comment
-
Hi Roland,
I've never used a vsg::vsgd, only ever used vsg::vsg working on the
assumption that the CMake will figure out the details for release and
debug. However, I'm just working under Linux and explicitly build for
release or debug so may well not translate to Windows VisualStudio build.
What happens when you just use vsg::vsg?
Cheers,
Robert.q
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
Straight up, my CMake skills basically consist of cut-and-paste and replacing names, so I apologise in advance if I've done something dumb.
I'm writing an application using vsg/vsgXchange etc. I've written (ie. cut-and-paste) my own cmake file and I'm using VSCode. I've built and installed both debug and release versions of VSG and want to link to the correct version by selecting the appropriate build variant in Code and pressing F7. I would have thought this was all pretty standard.
In my cmake file I search for VSG using
set(VSG_MIN_VERSION 1.0.0)
find_package(vsg ${VSG_MIN_VERSION})
then link using
target_link_libraries(si
debug vsg::vsgd
optimized vsg::vsg
)
which Google says is the right way to do it.
If I switch to Release build in Code then it builds without error and appears to be the correct build type.
If I switch to Debug in Code then I get the following error when cmake runs
[main] Configuring folder: si
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/roland/Source/si/si -B/home/roland/Source/si/si/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Found glslang: /home/roland/Source/vulkanSDK/1.3.216.0/x86_64/lib/libglslang.a
[cmake] -- Reading 'vsg_...' macros from /usr/local/lib/cmake/vsg/vsgMacros.cmake - look there for documentation
[cmake] -- Found Vulkan: /home/roland/Source/vulkanSDK/1.3.216.0/x86_64/lib/libvulkan.so
[cmake] -- Found Vulkan: /home/roland/Source/vulkanSDK/1.3.216.0/x86_64/lib/libvulkan.so (Required is at least version "1.1.70.0")
[cmake] -- Found glslang: /home/roland/Source/vulkanSDK/1.3.216.0/x86_64/lib/libglslang.a
[cmake] -- Found glslang: /home/roland/Source/vulkanSDK/1.3.216.0/x86_64/lib/libglslang.a
[cmake] -- Configuring done
[cmake] CMake Error at CMakeLists.txt:156 (add_executable):
[cmake] Target "si" links to target "vsg::vsgd" but the target was not found.
[cmake] Perhaps a find_package() call is missing for an IMPORTED target, or an
[cmake] ALIAS target is missing?
[cmake]
[cmake]
[cmake] -- Generating done
[cmake] CMake Generate step failed. Build files cannot be regenerated correctly.
[proc] The command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/roland/Source/si/si -B/home/roland/Source/si/si/build -G "Unix Makefiles" exited with code: 1 and signal: null
I've checked and /usr/local/lib/libvsgd.a exists.
I previously only built the debug version of VSG and used the simpler link line
target_link_libraries(si
vsg::vsg
)
and it all worked, so it is just a problem of picking between the two vsg builds.
I've been through the files in /usr/local/lib/cmake/vsg/ and can see how it's supposed to work. It looks like vsgTargets-debug.cmake is being included. I can't see where vsg:vsgd target is defined though and it looks like vsg:vsg might be redefined in this file.
Am I doing something wrong or could this be a bug in the cmake files?
Thanks in advance,
Roland
Beta Was this translation helpful? Give feedback.
All reactions