Skip to content

NiklasKroeger-AlliedVision/vmbc_training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dummy project to show how to set the CMake search path to find the Vimba X cmake helper files

Running the CMake configure step without passing additional info on where to find Vimba X will
likely fail wit a message similar to this:

```
D:\code\tmp\vmb_cmake_tests>cmake -S . -B build
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.35.32217.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:5 (find_package):
  By not providing "FindVmb.cmake" in CMAKE_MODULE_PATH this project has   
  asked CMake to find a package configuration file provided by "Vmb", but  
  CMake did not find one.

  Could not find a package configuration file provided by "Vmb" with any of
  the following names:

    VmbConfig.cmake
    vmb-config.cmake

  Add the installation prefix of "Vmb" to CMAKE_PREFIX_PATH or set "Vmb_DIR"
  to a directory containing one of the above files.  If "Vmb" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "D:/code/tmp/vmb_cmake_tests/build/CMakeFiles/CMakeOutput.log".
```

CMake needs additional info on where to look for `vmb-config.cmake`. This file is provided with
Vimba X in `%VIMBA_X_HOME%/api/lib/cmake/vmb` (Windows style environment variable expansion. On
Linux adjust as necessary to expand the `$VIMBA_X_HOME` environment variable). The CMake parameter
must be put into quotation marks as the path will contain whitespace characters!

```
D:\code\tmp\vmb_cmake_tests>cmake -S . -B build -D Vmb_DIR="%VIMBA_X_HOME%/api/lib/cmake/vmb"
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
CMake Warning at C:/Program Files/Allied Vision/Vimba X/api/lib/cmake/vmb/vmb-config-version.cmake:4 (message):
  CMAKE_LIBRARY_ARCHITECTURE not set, cannot check platform compatibility
Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


-- Configuring done
-- Generating done
-- Build files have been written to: D:/code/tmp/vmb_cmake_tests/build
```

The warning about CMAKE_LIBRARY_ARCHITECTURE not being set can likely be ignored.

An alternative way to provide CMake with the required path information is using CMakePresets.json
files to define a preset that will be used to configure and compile the project. This file includes
only a single configurePreset named "example" that demonstrates how to set the `Vmb_DIR` variable so
that CMake will correctly pick up the Vimba X installation on the system. Further configuration may
be added to these presets to configure the build process. it can for example make sense to have
different presets depending on the operating system or system architecture, but this is outside the
scope of this example.

```
D:\code\tmp\vmb_cmake_tests>cmake -S . -B build --preset example
Preset CMake variables:

  Vmb_DIR:PATH="C:\Program Files\Allied Vision\Vimba X/api/lib/cmake/vmb"

-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.35.32217.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning at C:/Program Files/Allied Vision/Vimba X/api/lib/cmake/vmb/vmb-config-version.cmake:4 (message):
  CMAKE_LIBRARY_ARCHITECTURE not set, cannot check platform compatibility
Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


-- Configuring done
-- Generating done
-- Build files have been written to: D:/code/tmp/vmb_cmake_tests/build
```

Be aware that in order to actually load the VmbC (and other) shared library from Vimba X, they still
need to be available in the PATH during runtime of the application. This can be achieved by e.g.
copying over the DLLs from `%VIMBA_X_HOME%/api/bin` to the binary directory of the application, or
adding that directory to the PATH before executing the application.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Contributors