CMakeLists.txt 4.17 KB
Newer Older
Gluttton's avatar
Gluttton committed
1
# Common variables.
2 3
SET (CMAKE_CXX_STANDARD 11)
SET (CMAKE_CXX_STANDARD_REQUIRED ON)
Anton Bukov's avatar
Anton Bukov committed
4 5 6 7 8 9 10 11
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wmissing-include-dirs -Wfloat-equal -Wshadow")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion -Winit-self -Weffc++ ")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wsign-promo")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wvla -Winvalid-pch -Winline -Wredundant-decls")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual -Wpointer-arith")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
Gluttton's avatar
Gluttton committed
12
SET (CMAKE_SHARED_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")
Anton Bukov's avatar
Anton Bukov committed
13
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
Gluttton's avatar
Gluttton committed
14 15


16
INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/include/boolinq)
Anton Bukov's avatar
Anton Bukov committed
17
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/googletest-src/googletest/include)
18

Gluttton's avatar
Gluttton committed
19 20 21
# Unit tests.
SET (
    BoolinqTest_SOURCES
22 23 24
    ${PROJECT_SOURCE_DIR}/test/AllTest.cpp
    ${PROJECT_SOURCE_DIR}/test/AnyTest.cpp
    ${PROJECT_SOURCE_DIR}/test/AvgTest.cpp
25
    ${PROJECT_SOURCE_DIR}/test/AppendTest.cpp
26 27 28
    ${PROJECT_SOURCE_DIR}/test/BitsTest.cpp
    ${PROJECT_SOURCE_DIR}/test/BytesTest.cpp
    ${PROJECT_SOURCE_DIR}/test/ConcatTest.cpp
29 30
    ${PROJECT_SOURCE_DIR}/test/ContainsTest.cpp
    ${PROJECT_SOURCE_DIR}/test/CountTest.cpp
31
    ${PROJECT_SOURCE_DIR}/test/DistinctTest.cpp
32 33
    ${PROJECT_SOURCE_DIR}/test/DotCallTest.cpp
    ${PROJECT_SOURCE_DIR}/test/ElementAtTest.cpp
34
    ${PROJECT_SOURCE_DIR}/test/FirstTest.cpp
35
    ${PROJECT_SOURCE_DIR}/test/ForEachTest.cpp
36
    ${PROJECT_SOURCE_DIR}/test/GroupByTest.cpp
37
    ${PROJECT_SOURCE_DIR}/test/CtorTest.cpp
38
    ${PROJECT_SOURCE_DIR}/test/LastTest.cpp
39 40 41
    ${PROJECT_SOURCE_DIR}/test/LinqTest.cpp
    ${PROJECT_SOURCE_DIR}/test/MaxTest.cpp
    ${PROJECT_SOURCE_DIR}/test/MinTest.cpp
42
    ${PROJECT_SOURCE_DIR}/test/OrderByTest.cpp
43
    ${PROJECT_SOURCE_DIR}/test/PrependTest.cpp
44
    ${PROJECT_SOURCE_DIR}/test/RangeTest.cpp
45 46
    ${PROJECT_SOURCE_DIR}/test/ReverseTest.cpp
    ${PROJECT_SOURCE_DIR}/test/SelectTest.cpp
Anton Bukov's avatar
Anton Bukov committed
47
    ${PROJECT_SOURCE_DIR}/test/SelectManyTest.cpp
48 49
    ${PROJECT_SOURCE_DIR}/test/SkipTest.cpp
    ${PROJECT_SOURCE_DIR}/test/SkipWhileTest.cpp
50
    ${PROJECT_SOURCE_DIR}/test/SumTest.cpp
51 52 53 54 55 56 57 58 59
    ${PROJECT_SOURCE_DIR}/test/TakeTest.cpp
    ${PROJECT_SOURCE_DIR}/test/TakeWhileTest.cpp
    ${PROJECT_SOURCE_DIR}/test/ToStdDequeTest.cpp
    ${PROJECT_SOURCE_DIR}/test/ToStdListTest.cpp
    ${PROJECT_SOURCE_DIR}/test/ToStdSetTest.cpp
    ${PROJECT_SOURCE_DIR}/test/ToStdVectorTest.cpp
    ${PROJECT_SOURCE_DIR}/test/UnbitsTest.cpp
    ${PROJECT_SOURCE_DIR}/test/UnbytesTest.cpp
    ${PROJECT_SOURCE_DIR}/test/WhereTest.cpp
60 61
)
ADD_EXECUTABLE (
Anton Bukov's avatar
Anton Bukov committed
62
    "${PROJECT_NAME}-test"
63 64 65
    ${BoolinqTest_SOURCES}
)
TARGET_LINK_LIBRARIES (
Anton Bukov's avatar
Anton Bukov committed
66
    "${PROJECT_NAME}-test"
67
    gtest_main
Anton Bukov's avatar
Anton Bukov committed
68
    gtest
69
    #gcov
Gluttton's avatar
Gluttton committed
70 71
)
ENABLE_TESTING ()
Anton Bukov's avatar
Anton Bukov committed
72
ADD_TEST (BoolinqTest "${PROJECT_NAME}-test")
Gluttton's avatar
Gluttton committed
73 74 75 76 77 78 79 80 81 82


# Test coverage report.
SET (Coverage_REPORT ${PROJECT_BINARY_DIR}/coverage.info)
SET (Coverage_DIR    ${PROJECT_BINARY_DIR}/coverage)
ADD_CUSTOM_COMMAND (
    OUTPUT  ${Coverage_REPORT}
    COMMAND lcov -q -c -f -b . -d ${PROJECT_BINARY_DIR}/boolinq -o ${Coverage_REPORT}
    COMMAND lcov -e ${Coverage_REPORT} '${PROJECT_SOURCE_DIR}/boolinq/*' -o ${Coverage_REPORT}
    COMMAND genhtml ${Coverage_REPORT} --legend --demangle-cpp -f -q -o ${Coverage_DIR}
Anton Bukov's avatar
Anton Bukov committed
83
    DEPENDS "${PROJECT_NAME}-test"
Gluttton's avatar
Gluttton committed
84 85 86 87 88 89 90 91 92 93
)
ADD_CUSTOM_TARGET (coverage DEPENDS ${Coverage_REPORT})
# FIXME: Doesn't work correctly (require explicit call cmake when files appear).
FILE (GLOB_RECURSE Coverage_GCNO ${PROJECT_BINARY_DIR}/*.gcno)
FILE (GLOB_RECURSE Coverage_GCDA ${PROJECT_BINARY_DIR}/*.gcda)
LIST (APPEND Coverage_DATA "${Coverage_REPORT}")
LIST (APPEND Coverage_DATA "${Coverage_DIR}")
LIST (APPEND Coverage_DATA "${Coverage_GCNO}")
LIST (APPEND Coverage_DATA "${Coverage_GCDA}")
SET_DIRECTORY_PROPERTIES (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${Coverage_DATA}")