Skip to content

Showcase for VisualStudio 2022 cmake conan project with cross-compiling on wsl1.

Notifications You must be signed in to change notification settings

steinerthomas/vs-cmake-conan-wsl-template

Repository files navigation

Project structure

This is a template project for a VisualStudio 2022 CMake project which is using conan v1 for dependecies and packaging a library. It is possible to build for linux WSL1, run and debug tests on WSL1 or a remote 32-bit machine (cross build and debug).

dependencies

libxml2 and gtest

conan-cmake submodule

conan-cmake is used

conan version

pip install conan==1.61.0 https://pypi.org/project/conan/1.61.0/

conan configuration

located in the .conan folder

Goal

2-step migration to conan v2.

  1. Migrate recipe to conan v2 and build with conan v1
  2. Build with conan v2

Building

Building with Visual Studio 2022 and WSL1

Build and run tests under WSL

  • Select Connection/Target System: WSL:Debian
  • Select Configuration: wsl-debug
  • Select Startup Item (target): MyLib_ut (bin\MyLib_ut)
  • Debug (hit F5)
    • Test will be executed on WSL with gbd

Build and run tests on a remote machine with 32-bit

  • Select Connection/Target System: WSL:Debian
  • Select Configuration: remote-debug
  • Select Startup Item (target): MyLib_ut (X Debug)
    • described in launch.vs.json file
  • Debug (hit F5)
    • All extecutables and libs get copied to the target machine
    • Test will be executed on target machine with gbd

Package/Build with conan v1

conan profile detect conan config install .conan

Build for WSL

CONAN_RUN_TESTS=True conan create . mylib/1.0.0@steiner/testing -u -pr:h default -s build_type=RelWithDebInfo -pr:b=default

Cross build to 32 bit

Install the toolchain: resources/toolchains/engel-toolchain-cube3210-i686_1.26.0+rc1_amd64.deb This toolchain was generated by crosstool-ng (https://crosstool-ng.github.io/) The toolchain is available in: /opt/x-tools/i686-cube3210-linux-gnu/toolchain.cmake

conan create . mylib/1.0.0@steiner/testing -u -pr:h cube3210 -s build_type=RelWithDebInfo -pr:b=default

Showcase cross build (g++-i686-linux-gnu)

For the showcase a toolchain.cmake was created, which uses the debian i686 cross compiler apt install g++-i686-linux-gnu.

cp toolchain.cmake /tmp/
conan create . mylib/1.0.0@steiner/testing -u -pr:h showcase -s build_type=RelWithDebInfo -pr:b=default

About

Showcase for VisualStudio 2022 cmake conan project with cross-compiling on wsl1.

Resources

Stars

Watchers

Forks

Packages

No packages published