Skip to content

JayTwoLab/conan-msvc-linux_gcc-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conan Project Build Commands

Korean

Prerequisites

  • Windows: Visual Studio (2022 or higher), cmake, ninja
  • Linux: gcc (g++), cmake, ninja

Project Setup

  • Create a conanfile.txt file:
[requires]
boost/1.84.0

[options]
boost/*:shared=False

[generators]
CMakeToolchain
CMakeDeps
  • In this example, Boost version 1.84.0 is used.

Visual Studio 2022

  • Create Conan profile files in advance.

  • Create a settings file for release builds: C:\Users\<user>\.conan2\profiles\msvc_release (<user> is your user account)
[settings]
os=Windows
arch=x86_64
build_type=Release
compiler=msvc
compiler.version=194
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.cppstd=17

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
  • compiler.version
    • Visual Studio version + product version (MSVC Toolset), Conan compiler.version
      • Visual Studio 2026, 195
      • Visual Studio 2022 17.10~, 194
      • Visual Studio 2022 17.0~17.9, 193
      • Visual Studio 2019, 192
      • Visual Studio 2017, 191
      • Visual Studio 2015, 190
      • The top 3 digits of the version shown by the cl command: e.g., if 19.50.35725, use 195

  • Create a settings file for debug builds: C:\Users\<user>\.conan2\profiles\msvc_debug
[settings]
os=Windows
arch=x86_64
build_type=Debug
compiler=msvc
compiler.version=194
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.cppstd=17

[conf]
tools.cmake.cmaketoolchain:generator=Ninja


  • For Visual Studio Release build procedure:
# Run the following commands in the msvc command prompt.

cmake -E rm -rf build-msvc-release
# Deletes the build-msvc directory and all its contents, regardless of existence.

conan install . ^
 -pr:h %USERPROFILE%\.conan2\profiles\msvc_release ^
 -pr:b default ^
 -of build-msvc-release ^
 --build=missing
# conan install . : Uses conanfile.txt or conanfile.py in the current directory (.)
# -pr:h %USERPROFILE%\.conan2\profiles\msvc_release : Specify host profile
# -pr:b default : Use default if same as host
# -of build-msvc-release : Output Conan-generated files to build-msvc-release directory
# --build=missing : Build from source if not in local cache; skip if already cached.

cmake -S . ^
 -B build-msvc-release ^
 -DCMAKE_TOOLCHAIN_FILE=build-msvc\conan_toolchain.cmake ^
 -G "Visual Studio 17 2022"
# -S . : CMakeLists.txt is in the current directory (.)
# -B build-msvc : Generate CMake output in build-msvc
# -DCMAKE_TOOLCHAIN_FILE=build-msvc\conan_toolchain.cmake : 

cmake --build build-msvc-release --config Release
# --build build-msvc-release : Build the build-msvc-release path
# --config Release : If set to Release in the profile file (msvc_release), build as release.

  • For Visual Studio Debug build procedure:
cmake -E rm -rf build-msvc-debug

conan install . ^
  -pr:h %USERPROFILE%\.conan2\profiles\msvc_debug ^
  -pr:b default ^
  -of build-msvc-debug ^
  --build=missing

cmake -S . -B build-msvc-debug ^
  -DCMAKE_TOOLCHAIN_FILE=build-msvc-debug\conan_toolchain.cmake ^
  -G "Visual Studio 17 2022"

cmake --build build-msvc-debug --config Debug


Rocky Linux 8 x86_64

  • Create a settings file for release builds: /home/<user>/.conan2/profiles/linux_gcc_release
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=8
compiler.libcxx=libstdc++11
build_type=Release

[conf]
tools.cmake.cmaketoolchain:generator=Ninja

  • For gcc/linux Release build:
cmake -E rm -rf build-linux-gcc-release

conan install . \
 -pr:h ~/.conan2/profiles/linux_gcc_release \
 -pr:b default \
 -of build-linux-gcc-release \
 --build=b2* \
 --build=missing
# Build b2 as well in case of dependency issues with b2

cmake -S . \
 -B build-linux-gcc-release \
 -DCMAKE_TOOLCHAIN_FILE=build-linux-gcc/conan_toolchain.cmake \
 -G "Unix Makefiles" \
 -DCMAKE_BUILD_TYPE=Release

cmake --build build-linux-gcc-release --config Release

About

📦 conan build example (Visual Studio 2022, Rocky Linux 8)

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors