Skip to content

Commit d9e8f6b

Browse files
committed
Add cmake-conan to simplify build process
1 parent ac0ed7e commit d9e8f6b

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,31 @@ cmake_minimum_required(VERSION 3.19)
22
project(developer_joyofenergy_cpp)
33

44
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
5+
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
6+
57
set(CMAKE_CXX_STANDARD 17)
68

9+
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
10+
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
11+
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.17.0/conan.cmake"
12+
"${CMAKE_BINARY_DIR}/conan.cmake")
13+
endif()
14+
15+
include(${CMAKE_BINARY_DIR}/conan.cmake)
16+
17+
conan_cmake_configure(REQUIRES boost/1.76.0
18+
REQUIRES gtest/1.11.0
19+
REQUIRES nlohmann_json/3.9.1
20+
OPTIONS boost:header_only=True
21+
GENERATORS cmake_find_package)
22+
23+
conan_cmake_autodetect(settings)
24+
25+
conan_cmake_install(PATH_OR_REFERENCE .
26+
BUILD missing
27+
REMOTE conancenter
28+
SETTINGS ${settings})
29+
730
add_subdirectory(rest)
831
add_executable(app main.cpp)
932
target_link_libraries(app PRIVATE rest)

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The project makes use of Conan.
6464

6565
## Useful Conan commands
6666

67-
The project makes use of Conan to help you out carrying some common tasks such as building
67+
The project makes use of [Conan](https://conan.io/) to help you out carrying some common tasks such as building
6868
the project or running it.
6969

7070
### Build the project
@@ -73,9 +73,8 @@ Compiles the project, runs the test and then creates an executable file.
7373

7474
```console
7575
$ mkdir build && cd build
76-
$ conan install .. --build missing
77-
$ cmake ..
78-
$ cmake --build .
76+
$ cmake .. -DCMAKE_BUILD_TYPE=Release
77+
$ cmake --build . --config Release
7978
```
8079

8180

@@ -94,6 +93,10 @@ There are two types of tests, the unit tests and the functional tests. These can
9493
```console
9594
$ ./app <address> <kPort> <concurrency>
9695
```
96+
or Windows
97+
```console
98+
build> .\Release\app.exe <address> <kPort> <concurrency>
99+
```
97100

98101
## API
99102

conanfile.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)