Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 43f5828

Browse files
committed
added gitignore
1 parent 6a9b632 commit 43f5828

File tree

234 files changed

+9571
-5767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+9571
-5767
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
dist: trusty
2-
sudo: required
2+
sudo: require
3+
34
language:
45
- cpp
6+
7+
# TODO(gocarlos): add here a build matrix with multiple compilers and macOS
58
compiler:
69
- gcc
10+
711
addons:
812
apt:
913
sources:
@@ -12,14 +16,12 @@ addons:
1216
- gcc-6
1317
- g++-6
1418
- cmake
15-
sudo: require
1619

1720
script:
18-
1921
# Export CC and CXX to tell cmake which compiler to use
2022
- export CC=/usr/bin/gcc-6
2123
- export CXX=/usr/bin/g++-6
2224
# Check versions of gcc, g++ and cmake
2325
- gcc -v && g++ -v && cmake --version
2426
# Run your build commands next
25-
- ./travis.sh
27+
- ./build.sh

CMakeLists.txt

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,50 @@
1-
cmake_minimum_required (VERSION 2.8)
1+
cmake_minimum_required (VERSION 3.1)
22
project (unit_test_example)
33

4-
# Use C++11 : cmake >= 3.1
4+
find_package(Threads REQUIRED)
5+
6+
# Require c++11.
57
set(CMAKE_CXX_STANDARD 11)
68
set(CMAKE_CXX_STANDARD_REQUIRED ON)
79

8-
# Use C++11 : cmake <=3.1
9-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
10-
10+
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include)
1111

1212
##############
1313
# External Library
1414
##############
1515

16-
# TODO(gocarlos) add this as an external project.
17-
add_subdirectory(lib/googletest-1.8.0)
16+
set(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/external)
17+
add_subdirectory(${EXT_PROJECTS_DIR}/gtest)
1818

1919
enable_testing()
2020

2121
# Include the gtest library.
22-
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
22+
include_directories(
23+
${gtest_SOURCE_DIR}/include
24+
${gtest_SOURCE_DIR}
25+
)
2326

2427
##############
2528
# Executables
2629
##############
2730

28-
add_executable (main src/sorting_and_searching.cpp)
31+
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)
32+
add_executable(${PROJECT_NAME} ${SRC_FILES})
2933

3034
##############
3135
# Unit Tests
3236
##############
3337

34-
add_executable(unit_test gtest/sorting_and_searching_test.cpp)
35-
target_link_libraries(unit_test gtest gtest_main)
38+
set(PROJECT_TEST_NAME ${PROJECT_NAME}_test)
39+
include_directories(${GTEST_INCLUDE_DIRS} ${COMMON_INCLUDES})
40+
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cpp)
41+
add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES})
42+
add_dependencies(${PROJECT_TEST_NAME} googletest)
43+
44+
target_link_libraries(${PROJECT_TEST_NAME}
45+
${GTEST_LIBS_DIR}/libgtest.a
46+
${GTEST_LIBS_DIR}/libgtest_main.a
47+
${CMAKE_THREAD_LIBS_INIT}
48+
)
49+
50+
add_test(test1 ${PROJECT_TEST_NAME})

LICENSE

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
This is free and unencumbered software released into the public domain.
1+
BSD 3-Clause License
22

3-
Anyone is free to copy, modify, publish, use, compile, sell, or
4-
distribute this software, either in source code form or as a compiled
5-
binary, for any purpose, commercial or non-commercial, and by any
6-
means.
3+
Copyright (c) 2017, Carlos Gomes
4+
All rights reserved.
75

8-
In jurisdictions that recognize copyright laws, the author or authors
9-
of this software dedicate any and all copyright interest in the
10-
software to the public domain. We make this dedication for the benefit
11-
of the public at large and to the detriment of our heirs and
12-
successors. We intend this dedication to be an overt act of
13-
relinquishment in perpetuity of all present and future rights to this
14-
software under copyright law.
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
158

16-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22-
OTHER DEALINGS IN THE SOFTWARE.
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
2311

24-
For more information, please refer to <http://unlicense.org>
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# unit_tests_example PROJECT
1+
# Example of the usage of google tests with CMake.
22

3-
Tested on Ubuntu 16.04, GCC 5.4.0, CMake 3.5.1
43

54
[![Build Status](https://travis-ci.org/gocarlos/unit_tests_example.svg?branch=master)](https://travis-ci.org/gocarlos/unit_tests_example)
65

6+
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
7+
78

89
## USAGE - RUN
910
In the project root:
@@ -14,4 +15,3 @@ In the project root:
1415
* make
1516
* ./main % executable
1617
* ./unit_test % unit test
17-

appveyor.yml

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

build/CMakeCache.txt

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@
1414
# EXTERNAL cache entries
1515
########################
1616

17-
//Builds the googlemock subproject
18-
BUILD_GMOCK:BOOL=ON
19-
20-
//Builds the googletest subproject
21-
BUILD_GTEST:BOOL=OFF
22-
23-
//Build shared libraries (DLLs).
24-
BUILD_SHARED_LIBS:BOOL=OFF
25-
2617
//Path to a program.
2718
CMAKE_AR:FILEPATH=/usr/bin/ar
2819

@@ -34,7 +25,7 @@ CMAKE_BUILD_TYPE:STRING=
3425
CMAKE_COLOR_MAKEFILE:BOOL=ON
3526

3627
//CXX compiler
37-
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
28+
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-7
3829

3930
//Flags used by the compiler during all build types.
4031
CMAKE_CXX_FLAGS:STRING=
@@ -53,7 +44,7 @@ CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
5344
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
5445

5546
//C compiler
56-
CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
47+
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-7
5748

5849
//Flags used by the compiler during all build types.
5950
CMAKE_C_FLAGS:STRING=
@@ -123,7 +114,7 @@ CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
123114
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
124115

125116
//Value Computed by CMake
126-
CMAKE_PROJECT_NAME:STATIC=interview_rapyuta
117+
CMAKE_PROJECT_NAME:STATIC=unit_test_example
127118

128119
//Path to a program.
129120
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
@@ -174,63 +165,20 @@ CMAKE_STRIP:FILEPATH=/usr/bin/strip
174165
// Studio IDE projects all commands are done without /nologo.
175166
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
176167

177-
//Path to a program.
178-
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
179-
180-
//Value Computed by CMake
181-
gmock_BINARY_DIR:STATIC=/home/gocarlos/git/unit_tests_example/build/lib/googletest-1.8.0/googlemock
182-
183-
//Dependencies for the target
184-
gmock_LIB_DEPENDS:STATIC=general;-lpthread;
185-
186-
//Value Computed by CMake
187-
gmock_SOURCE_DIR:STATIC=/home/gocarlos/git/unit_tests_example/lib/googletest-1.8.0/googlemock
188-
189-
//Build all of Google Mock's own tests.
190-
gmock_build_tests:BOOL=OFF
191-
192-
//Dependencies for the target
193-
gmock_main_LIB_DEPENDS:STATIC=general;-lpthread;
168+
//Git command line client
169+
GIT_EXECUTABLE:FILEPATH=/usr/bin/git
194170

195171
//Value Computed by CMake
196-
googletest-distribution_BINARY_DIR:STATIC=/home/gocarlos/git/unit_tests_example/build/lib/googletest-1.8.0
172+
gtest_builder_BINARY_DIR:STATIC=/home/gocarlos/git/unit_tests_example/build/external/gtest
197173

198174
//Value Computed by CMake
199-
googletest-distribution_SOURCE_DIR:STATIC=/home/gocarlos/git/unit_tests_example/lib/googletest-1.8.0
200-
201-
//Value Computed by CMake
202-
gtest_BINARY_DIR:STATIC=/home/gocarlos/git/unit_tests_example/build/lib/googletest-1.8.0/googlemock/gtest
203-
204-
//Dependencies for the target
205-
gtest_LIB_DEPENDS:STATIC=general;-lpthread;
206-
207-
//Value Computed by CMake
208-
gtest_SOURCE_DIR:STATIC=/home/gocarlos/git/unit_tests_example/lib/googletest-1.8.0/googletest
209-
210-
//Build gtest's sample programs.
211-
gtest_build_samples:BOOL=OFF
212-
213-
//Build all of gtest's own tests.
214-
gtest_build_tests:BOOL=OFF
215-
216-
//Disable uses of pthreads in gtest.
217-
gtest_disable_pthreads:BOOL=OFF
218-
219-
//Use shared (DLL) run-time lib even when Google Test is built
220-
// as static lib.
221-
gtest_force_shared_crt:BOOL=OFF
222-
223-
//Build gtest with internal symbols hidden in shared libraries.
224-
gtest_hide_internal_symbols:BOOL=OFF
225-
226-
//Dependencies for the target
227-
gtest_main_LIB_DEPENDS:STATIC=general;-lpthread;general;gtest;
175+
gtest_builder_SOURCE_DIR:STATIC=/home/gocarlos/git/unit_tests_example/external/gtest
228176

229177
//Value Computed by CMake
230-
interview_rapyuta_BINARY_DIR:STATIC=/home/gocarlos/git/unit_tests_example/build
178+
unit_test_example_BINARY_DIR:STATIC=/home/gocarlos/git/unit_tests_example/build
231179

232180
//Value Computed by CMake
233-
interview_rapyuta_SOURCE_DIR:STATIC=/home/gocarlos/git/unit_tests_example
181+
unit_test_example_SOURCE_DIR:STATIC=/home/gocarlos/git/unit_tests_example
234182

235183

236184
########################
@@ -244,9 +192,9 @@ CMAKE_CACHEFILE_DIR:INTERNAL=/home/gocarlos/git/unit_tests_example/build
244192
//Major version of cmake used to create the current loaded cache
245193
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
246194
//Minor version of cmake used to create the current loaded cache
247-
CMAKE_CACHE_MINOR_VERSION:INTERNAL=5
195+
CMAKE_CACHE_MINOR_VERSION:INTERNAL=7
248196
//Patch version of cmake used to create the current loaded cache
249-
CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
197+
CMAKE_CACHE_PATCH_VERSION:INTERNAL=2
250198
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
251199
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
252200
//Path to CMake executable.
@@ -331,15 +279,15 @@ CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
331279
//ADVANCED property for variable: CMAKE_NM
332280
CMAKE_NM-ADVANCED:INTERNAL=1
333281
//number of local generators
334-
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=4
282+
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=2
335283
//ADVANCED property for variable: CMAKE_OBJCOPY
336284
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
337285
//ADVANCED property for variable: CMAKE_OBJDUMP
338286
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
339287
//ADVANCED property for variable: CMAKE_RANLIB
340288
CMAKE_RANLIB-ADVANCED:INTERNAL=1
341289
//Path to CMake installation.
342-
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.5
290+
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.7
343291
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
344292
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
345293
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
@@ -370,10 +318,8 @@ CMAKE_STRIP-ADVANCED:INTERNAL=1
370318
CMAKE_UNAME:INTERNAL=/bin/uname
371319
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
372320
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
373-
//Details about finding PythonInterp
374-
FIND_PACKAGE_MESSAGE_DETAILS_PythonInterp:INTERNAL=[/usr/bin/python][v2.7.12()]
375321
//Details about finding Threads
376322
FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()]
377-
//ADVANCED property for variable: PYTHON_EXECUTABLE
378-
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
323+
//ADVANCED property for variable: GIT_EXECUTABLE
324+
GIT_EXECUTABLE-ADVANCED:INTERNAL=1
379325

-8.44 KB
Binary file not shown.
-8.45 KB
Binary file not shown.
-8.59 KB
Binary file not shown.

0 commit comments

Comments
 (0)