|
| 1 | +cmake_minimum_required(VERSION 3.21) |
| 2 | +project(my_project CXX) |
| 3 | + |
| 4 | +set(CMAKE_CXX_STANDARD 17) |
| 5 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 6 | + |
| 7 | + |
| 8 | +add_executable(hello |
| 9 | + src/main.cpp |
| 10 | +) |
| 11 | + |
| 12 | +# Find the Boost Config generated by Conan CMakeDeps. |
| 13 | +find_package(Boost REQUIRED CONFIG) |
| 14 | + |
| 15 | +# The target name provided by the Conan/Boost package may vary depending on the environment. |
| 16 | +# The safest way is to try them in order as below. |
| 17 | +if(TARGET Boost::headers) |
| 18 | + target_link_libraries(hello PRIVATE Boost::headers) |
| 19 | +elseif(TARGET Boost::boost) |
| 20 | + target_link_libraries(hello PRIVATE Boost::boost) |
| 21 | +else() |
| 22 | + message(FATAL_ERROR "Boost target not found. Expected Boost::headers or Boost::boost.") |
| 23 | +endif() |
| 24 | + |
| 25 | +target_link_libraries(hello PRIVATE Boost::system) |
| 26 | + |
| 27 | +if(WIN32) |
| 28 | + target_link_libraries(hello PRIVATE ws2_32) |
| 29 | +endif() |
| 30 | + |
| 31 | + |
| 32 | +################################## |
| 33 | +# Build commands (msvc) |
| 34 | +################################## |
| 35 | +# |
| 36 | +# Build commands when using C:\Users\<user>\.conan2\profiles\msvc_release |
| 37 | +# rmdir /s /q build-msvc # Clear cache |
| 38 | +# conan install . -of build-msvc --build=missing -pr:h msvc_release -pr:b msvc_release |
| 39 | +# cmake -S . -B build-msvc -DCMAKE_TOOLCHAIN_FILE=build-msvc\conan_toolchain.cmake |
| 40 | +# cmake --build build-msvc --config Release |
| 41 | +# |
| 42 | +# |
| 43 | +# Example configuration for C:\Users\<user>\.conan2\profiles\msvc_release |
| 44 | +# [settings] |
| 45 | +# os=Windows |
| 46 | +# arch=x86_64 |
| 47 | +# build_type=Release |
| 48 | +# compiler=msvc |
| 49 | +# compiler.version=194 # Check cl.exe version. Take the first two digits (19.40) and convert to integer → 194, VS 2019 (16.x) v142 : 192 , VS 2022 (17.0~17.4) v143 : 193 , VS 2022 (17.5~17.9) v143 : 194 |
| 50 | +# compiler.runtime=dynamic |
| 51 | +# compiler.runtime_type=Release |
| 52 | +# compiler.cppstd=17 |
| 53 | +# |
| 54 | +################################## |
| 55 | +# Build commands (mingw) |
| 56 | +################################## |
| 57 | +# |
| 58 | +# Build commands when using C:\Users\<user>\.conan2\profiles\mingw_gcc |
| 59 | +# rmdir /s /q build-mingw # Clear cache |
| 60 | +# conan install . -of build-mingw --build=missing -pr:h mingw_gcc -pr:b mingw_gcc -o boost/*:without_stacktrace=True -o boost/*:without_python=True -v debug |
| 61 | +# Exclude boost modules that cause issues during build (stacktrace, etc.) |
| 62 | +# cmake -S . -B build-mingw -G Ninja -DCMAKE_TOOLCHAIN_FILE=build-mingw\conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release |
| 63 | +# cmake --build build-mingw |
| 64 | +# |
| 65 | +# |
| 66 | +# Example configuration C:\Users\<user>\.conan2\profiles\mingw_gcc |
| 67 | +# [settings] |
| 68 | +# os=Windows |
| 69 | +# arch=x86_64 |
| 70 | +# build_type=Release |
| 71 | +# compiler=gcc |
| 72 | +# compiler.version=13 # Check version with g++ --version |
| 73 | +# compiler.libcxx=libstdc++11 |
| 74 | +# compiler.cppstd=17 |
| 75 | +# |
| 76 | +# [conf] |
| 77 | +# tools.cmake.cmaketoolchain:generator=Ninja |
| 78 | +# tools.build:compiler_executables={"c":"C:/Qt/Tools/mingw1310_64/bin/gcc.exe","cpp":"C:/Qt/Tools/mingw1310_64/bin/g++.exe"} |
| 79 | +# |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
0 commit comments