Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows support #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,31 @@ cmake_minimum_required(VERSION 3.19)
project(developer_joyofenergy_cpp)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

set(CMAKE_CXX_STANDARD 17)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.17.0/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_configure(REQUIRES boost/1.76.0
REQUIRES gtest/1.11.0
REQUIRES nlohmann_json/3.9.1
OPTIONS boost:header_only=True
GENERATORS cmake_find_package)

conan_cmake_autodetect(settings)

conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conancenter
SETTINGS ${settings})

add_subdirectory(rest)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE rest)
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The project makes use of Conan.

## Useful Conan commands

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

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

```console
$ mkdir build && cd build
$ conan install .. --build missing
$ cmake ..
$ cmake --build .
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ cmake --build . --config Release
```


Expand All @@ -94,6 +93,10 @@ There are two types of tests, the unit tests and the functional tests. These can
```console
$ ./app <address> <kPort> <concurrency>
```
or Windows
```console
build> .\Release\app.exe <address> <kPort> <concurrency>
```

## API

Expand Down
11 changes: 0 additions & 11 deletions conanfile.txt

This file was deleted.

7 changes: 7 additions & 0 deletions rest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ add_subdirectory(controller)
add_library(rest)
target_sources(rest PRIVATE server.cpp)
target_include_directories(rest INTERFACE ..)

target_compile_definitions(rest PRIVATE BOOST_ALL_NO_LIB)

if(WIN32)
target_compile_definitions(rest PRIVATE _WIN32_WINNT=0x0601)
endif()

target_link_libraries(rest PUBLIC controller)
1 change: 1 addition & 0 deletions rest/domain/PricePlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <utility>
#include <vector>
#include <chrono>

class PricePlan {
// todo:
Expand Down
8 changes: 7 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
add_definitions(-DBOOST_ALL_NO_LIB)

if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0601)
endif()

add_executable(endpoint_test)
target_sources(endpoint_test PRIVATE ReadingTest.cpp)
find_package(GTest REQUIRED)
Expand All @@ -19,4 +25,4 @@ target_link_libraries(service_test PRIVATE GTest::gmock_main rest)
add_test(endpoint_test endpoint_test)
add_test(controller_test controller_test)
add_test(domain_test domain_test)
add_test(service_test service_test)
add_test(service_test service_test)