Skip to content

Commit

Permalink
separating lib code from the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
doleron committed Feb 15, 2021
1 parent ed79e68 commit 43f5043
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ find_package (Threads)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11 -pthread")

add_library(${PROJECT_NAME}
src/tcp_client.cpp
src/tcp_server.cpp
src/client.cpp)

option(SERVER_EXAMPLE "Build SERVER" ON)

if(SERVER_EXAMPLE)
Expand All @@ -14,13 +19,9 @@ if(SERVER_EXAMPLE)
-DSERVER_EXAMPLE
)

add_executable(tcp_server
server_example.cpp
src/tcp_client.cpp
src/tcp_server.cpp
src/client.cpp)
add_executable(tcp_server server_example.cpp)

target_link_libraries (tcp_server ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (tcp_server ${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})

endif()

Expand All @@ -32,12 +33,8 @@ if(CLIENT_EXAMPLE)
-DCLIENT_EXAMPLE
)

add_executable(tcp_client
client_example.cpp
src/tcp_client.cpp
src/tcp_server.cpp
src/client.cpp)
add_executable(tcp_client client_example.cpp)

target_link_libraries (tcp_client ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (tcp_client ${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})

endif()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ make
```
The commands above generate two files: `tcp_client` and `tcp_server`.

To run, open a terminal, move to the `build` folder and execute:
To run them, open a terminal, move to the `build` folder and execute:
```
./tcp_server
```
Expand Down

0 comments on commit 43f5043

Please sign in to comment.