Skip to content
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@
*.exe
*.out
*.app

# CMake results
/bin
/build64_debug
/build64_release
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tdd_intro/3rd_party/googletest"]
path = tdd_intro/3rd_party/googletest
url = https://github.com/google/googletest.git
11 changes: 11 additions & 0 deletions GetSubdirList.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MACRO(GETSUBDIRLIST result curdir)
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child}
AND NOT "CMakeFiles" STREQUAL ${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
ENDMACRO(GETSUBDIRLIST)
7 changes: 7 additions & 0 deletions build_debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake -Htdd_intro -Bbuild64_debug -G"Visual Studio 14 2015 Win64" || goto :eof
cmake --build build64_debug --target install --config Debug || echo build64_debug failed && goto :eof

:: to run tests
pushd build64_debug
ctest -VV -C Debug || echo Unit-tests failed && popd && goto :eof
popd
7 changes: 7 additions & 0 deletions build_release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake -Htdd_intro -Bbuild64_release -G"Visual Studio 14 2015 Win64" || goto :eof
cmake --build build64_release --target install --config Release || echo build64_release failed && goto :eof

:: to run tests
pushd build64_release
ctest -C Release || echo Unit-tests failed && popd && goto :eof
popd
1 change: 1 addition & 0 deletions tdd_intro/3rd_party/googletest
Submodule googletest added at f5edb4
33 changes: 33 additions & 0 deletions tdd_intro/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.0)
project(tdd-course-3)

# to run tests after build
enable_testing()

# to enable GETSUBDIRLIST macro
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/..")
include(GetSubdirList)

# turn on using solution folders for IDE
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Compiler flags
# /MT, /MTd - for static linkage
# /W4 - warning level 4
# /MP - to compile by several threads
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP")

# add gtest and gmock as subprojects
add_subdirectory(3rd_party/googletest EXCLUDE_FROM_ALL)

# organize targets in an IDE
set_target_properties(gtest gtest_main gmock_main PROPERTIES FOLDER 3rd-party/GTest)

include_directories(3rd_party/googletest/googletest/include)
include_directories(3rd_party/googletest/googlemock/include)

add_subdirectory(homework)
add_subdirectory(demo)
add_subdirectory(cleanroom)
5 changes: 5 additions & 0 deletions tdd_intro/cleanroom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.0)

# add subproject
add_subdirectory(chatclient)
set_target_properties(chatclient chatclient_test PROPERTIES FOLDER cleanroom)
30 changes: 30 additions & 0 deletions tdd_intro/cleanroom/chatclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.0)
project(chatclient)

add_library(
chatclient
igui.h
isocketwrapper.h
socketwrapper.h
socketwrapper.cpp
)
target_link_libraries(chatclient Ws2_32.lib Mswsock.lib AdvApi32.lib)

add_executable(
chatclient_test
mocks.h
socketwrappertest.cpp
test.cpp
)
target_link_libraries(chatclient_test chatclient gtest_main gmock_main)

add_test(
NAME chatclient_test
COMMAND chatclient_test
)

install(TARGETS
chatclient
chatclient_test
DESTINATION ${CMAKE_SOURCE_DIR}/../bin
)
23 changes: 23 additions & 0 deletions tdd_intro/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.0)

GETSUBDIRLIST(PROJECTS ${CMAKE_CURRENT_SOURCE_DIR})

foreach(PROJ ${PROJECTS})
project(${PROJ})

if(${PROJ} STREQUAL "01_bob")
# Steps.cpp contains compile errors
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот и нижний файл так же не лишены дублирования.
Но что бы от него(дублирования) избавиться нужно пофиксить compile errors в файле demo/01_bob/Steps.cpp

FILE(GLOB SOURCES_FILES ${PROJ}/test.cpp)
else()
FILE(GLOB SOURCES_FILES ${PROJ}/*.h ${PROJ}/*.cpp)
endif()

add_executable(${PROJ} ${SOURCES_FILES})
target_link_libraries(${PROJ} gtest_main gmock_main)

add_test(NAME ${PROJ} COMMAND ${PROJ})
endforeach()

set_target_properties(${PROJECTS} PROPERTIES FOLDER demo)

install(TARGETS ${PROJECTS} DESTINATION ${CMAKE_SOURCE_DIR}/../bin)
17 changes: 17 additions & 0 deletions tdd_intro/homework/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.0)

GETSUBDIRLIST(PROJECTS ${CMAKE_CURRENT_SOURCE_DIR})

foreach(PROJ ${PROJECTS})
project(${PROJ})

FILE(GLOB SOURCES_FILES ${PROJ}/*.h ${PROJ}/*.cpp)
add_executable(${PROJ} ${SOURCES_FILES})
target_link_libraries(${PROJ} gtest_main gmock_main)

add_test(NAME ${PROJ} COMMAND ${PROJ})
endforeach()

set_target_properties(${PROJECTS} PROPERTIES FOLDER homework)

install(TARGETS ${PROJECTS} DESTINATION ${CMAKE_SOURCE_DIR}/../bin)