Skip to content

Commit 88c9089

Browse files
committed
update md
1 parent 2627c32 commit 88c9089

5 files changed

Lines changed: 254 additions & 128 deletions

File tree

CMakeLists.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+

README.ko.md

Lines changed: 74 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,79 @@
1-
# C++ 프로젝트용 .gitignore
2-
3-
[English](README.md)
4-
5-
---
6-
7-
`.gitignore` 파일은 다양한 IDE, 에디터, 빌드 시스템을 포괄하는 **C++ 프로젝트 전용 종합 무시 목록**입니다.
8-
9-
## 포함된 환경
10-
11-
- **IDE / 에디터**:
12-
- Visual Studio 2019/2022
13-
- Visual Studio Code (VSCode)
14-
- CLion / JetBrains IDE
15-
- Qt Creator
16-
- Eclipse CDT
17-
- Xcode
18-
- Neovim / Vim
19-
- Emacs
20-
- Sublime Text
21-
- Atom
22-
- Code::Blocks
23-
- CodeLite
24-
- KDevelop
25-
- NetBeans (C/C++)
26-
- Geany
27-
- Dev-C++
28-
- JetBrains Fleet
29-
- Kate
30-
31-
- **빌드 시스템**:
32-
- CMake
33-
- Ninja
34-
- Meson
35-
- SCons
36-
37-
- **패키지 관리자**:
38-
- Conan
39-
- vcpkg
40-
- Hunter
41-
- CPM.cmake
42-
43-
- **언어 서버**:
44-
- clangd
45-
- ccls
46-
- gtags / ctags
47-
48-
## 목적
49-
50-
`.gitignore`의 목적은 다음과 같습니다:
51-
- 빌드 과정에서 생성되는 임시 산출물을 저장소에서 제거
52-
- 로컬 IDE/에디터 설정 파일을 커밋하지 않도록 방지
53-
- 사용자/PC별로 달라지는 캐시 및 로그 파일 제외
54-
55-
## 사용 방법
56-
57-
C++ 프로젝트의 루트 디렉터리에 `.gitignore` 파일을 배치합니다:
58-
59-
```bash
60-
curl -o .gitignore https://example.com/path/to/.gitignore
1+
# Conan CMake 샘플
2+
3+
[English README](README.md)
4+
5+
이 프로젝트는 Conan과 CMake를 사용하여 Boost 의존성을 가진 간단한 C++ 애플리케이션을 빌드하는 방법을 보여줍니다.
6+
7+
## 프로젝트 구조
8+
9+
- `src/main.cpp`: Boost.Asio를 사용하는 최소 예제
10+
- `CMakeLists.txt`: CMake 빌드 설정
11+
- `conanfile.txt`: Conan 패키지 요구사항 및 생성기 설정
12+
13+
## 요구 사항
14+
15+
- CMake >= 3.21
16+
- Conan >= 2.x
17+
- C++17을 지원하는 컴파일러 (예: MSVC, GCC, Clang)
18+
19+
## 의존성
20+
21+
- Boost 1.83.0 (Conan을 통해 설치)
22+
23+
## 빌드 방법
24+
25+
### 1. Conan으로 의존성 설치
26+
27+
```sh
28+
conan install . -of build --build=missing
29+
```
30+
31+
또는, 특정 프로필(MSVC 등) 사용 시:
32+
33+
```sh
34+
conan install . -of build-msvc --build=missing -pr:h msvc_release -pr:b msvc_release
35+
```
36+
37+
### 2. CMake로 프로젝트 설정
38+
39+
```sh
40+
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake
41+
```
42+
43+
MSVC 프로필 사용 시:
44+
45+
```sh
46+
cmake -S . -B build-msvc -DCMAKE_TOOLCHAIN_FILE=build-msvc/conan_toolchain.cmake
47+
```
48+
49+
### 3. 빌드
50+
51+
```sh
52+
cmake --build build --config Release
53+
```
54+
55+
MSVC 프로필 사용 시:
56+
57+
```sh
58+
cmake --build build-msvc --config Release
59+
```
60+
61+
## 예제 실행 결과
62+
63+
빌드된 실행 파일을 실행하면 다음과 같은 메시지가 출력됩니다:
64+
65+
```
66+
Boost.Asio OK
6167
```
6268

63-
Git은 `.gitignore`에 명시된 패턴과 일치하는 파일/디렉터리를 자동으로 무시합니다.
69+
## 참고
6470

65-
## 참고 사항
71+
- Boost를 header-only로 사용하여 빌드 시간/용량을 줄이고 싶다면, `conanfile.txt`에서 아래 옵션을 주석 해제하여 사용하세요:
72+
```
73+
# boost/*:header_only=True
74+
```
75+
- CMake 설정은 환경에 따라 자동으로 올바른 Boost 타겟을 링크합니다.
6676

67-
- `.gitignore`에 포함되어 있어도 특정 파일을 강제로 추가하려면 `git add -f <file>` 명령을 사용하세요.
68-
- `Makefile`을 직접 관리하는 경우, `.gitignore``Makefile` 항목을 삭제하세요.
77+
## 라이선스
6978

79+
이 프로젝트는 MIT 라이선스를 따릅니다. 자세한 내용은 LICENSE 파일을 참고하세요.

README.md

Lines changed: 73 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,79 @@
1-
# C++ Project .gitignore
2-
3-
4-
[Korean](README.ko.md)
5-
6-
---
7-
8-
This `.gitignore` file is a **comprehensive ignore list** for C++ projects, covering a wide range of IDEs, editors, and build systems.
9-
10-
## Included Environments
11-
12-
- **IDEs / Editors**:
13-
- Visual Studio 2019/2022
14-
- Visual Studio Code (VSCode)
15-
- CLion / JetBrains IDEs
16-
- Qt Creator
17-
- Eclipse CDT
18-
- Xcode
19-
- Neovim / Vim
20-
- Emacs
21-
- Sublime Text
22-
- Atom
23-
- Code::Blocks
24-
- CodeLite
25-
- KDevelop
26-
- NetBeans (C/C++)
27-
- Geany
28-
- Dev-C++
29-
- JetBrains Fleet
30-
- Kate
31-
32-
- **Build systems**:
33-
- CMake
34-
- Ninja
35-
- Meson
36-
- SCons
37-
38-
- **Package managers**:
39-
- Conan
40-
- vcpkg
41-
- Hunter
42-
- CPM.cmake
43-
44-
- **Language servers**:
45-
- clangd
46-
- ccls
47-
- gtags / ctags
48-
49-
## Purpose
50-
51-
This `.gitignore` aims to:
52-
- Keep repositories clean from temporary build outputs.
53-
- Avoid committing local IDE/editor configuration files.
54-
- Exclude cache and log files that are machine/user-specific.
55-
56-
## Usage
57-
58-
Place the `.gitignore` file in the root of your C++ project:
59-
60-
```bash
61-
curl -o .gitignore https://example.com/path/to/.gitignore
1+
# Conan CMake Sample
2+
3+
[Korean README](README.ko.md)
4+
5+
This project demonstrates how to use Conan and CMake to build a simple C++ application with Boost dependencies.
6+
7+
## Project Structure
8+
9+
- `src/main.cpp`: Minimal example using Boost.Asio.
10+
- `CMakeLists.txt`: CMake build configuration.
11+
- `conanfile.txt`: Conan package requirements and generator settings.
12+
13+
## Requirements
14+
15+
- CMake >= 3.21
16+
- Conan >= 2.x
17+
- A C++17 compatible compiler (e.g., MSVC, GCC, Clang)
18+
19+
## Dependencies
20+
21+
- Boost 1.83.0 (via Conan)
22+
23+
## Building the Project
24+
25+
### 1. Install Dependencies with Conan
26+
27+
```sh
28+
conan install . -of build --build=missing
29+
```
30+
31+
Or, for a specific profile (e.g., MSVC):
32+
33+
```sh
34+
conan install . -of build-msvc --build=missing -pr:h msvc_release -pr:b msvc_release
6235
```
6336

64-
Git will automatically ignore files and directories matching the patterns.
37+
### 2. Configure the Project with CMake
38+
39+
```sh
40+
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake
41+
```
42+
43+
Or for MSVC profile:
44+
45+
```sh
46+
cmake -S . -B build-msvc -DCMAKE_TOOLCHAIN_FILE=build-msvc/conan_toolchain.cmake
47+
```
48+
49+
### 3. Build
50+
51+
```sh
52+
cmake --build build --config Release
53+
```
54+
55+
Or for MSVC profile:
56+
57+
```sh
58+
cmake --build build-msvc --config Release
59+
```
60+
61+
## Example Output
62+
63+
When you run the resulting executable, you should see:
64+
65+
```
66+
Boost.Asio OK
67+
```
6568

6669
## Notes
6770

68-
- If you need to track some files listed in `.gitignore`, use `git add -f <file>` to force-add them.
69-
- If you are manually managing `Makefile`, remove the `Makefile` entry in this `.gitignore`.
71+
- To use Boost as header-only (to reduce build time/size), uncomment and use the following option in `conanfile.txt`:
72+
```
73+
# boost/*:header_only=True
74+
```
75+
- The CMake configuration automatically links the correct Boost target depending on your environment.
76+
77+
## License
7078

79+
This project is licensed under the MIT License. See the LICENSE file for details.

conanfile.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[requires]
2+
boost/1.83.0
3+
4+
[generators]
5+
CMakeDeps
6+
CMakeToolchain
7+
8+
# [options]
9+
# If needed, e.g., if you want to use boost as header-only (to reduce build time/size)
10+
# boost/*:header_only=True
11+

src/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <boost/asio.hpp>
2+
#include <iostream>
3+
4+
int main()
5+
{
6+
boost::asio::io_context io;
7+
std::cout << "Boost.Asio OK\n";
8+
return 0;
9+
}

0 commit comments

Comments
 (0)