diff --git a/CMakeLists.txt b/CMakeLists.txt index 79453a1..740f79c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,94 @@ # Common variables. CMAKE_MINIMUM_REQUIRED (VERSION 3.0) -PROJECT (boolinq VERSION 3.0.0 LANGUAGES CXX) -INCLUDE(Dart) +IF (DEFINED PROJECT_NAME) + set(BOOLINQ_SUBPROJECT ON) +ENDIF () +PROJECT (boolinq VERSION 3.0.5 LANGUAGES CXX) -SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -ggdb3 -DDEBUG") -SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3") +INCLUDE (CMakePackageConfigHelpers) +INCLUDE (GNUInstallDirs) +INCLUDE (Dart) + + +SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -ggdb3 -DDEBUG") + + +OPTION (BUILD_TESTS "Build unit tests" ON) +OPTION (BUILD_BENCHMARK "Build benchmark" ON) # Static code analyse. SET (CppCheck_REPORT ${PROJECT_BINARY_DIR}/cppcheck.report) ADD_CUSTOM_COMMAND ( OUTPUT ${CppCheck_REPORT} - COMMAND cppcheck ${PROJECT_SOURCE_DIR}/imclude/boolinq/boolinq.h --enable=all --force --inconclusive &>cppcheck.report + COMMAND cppcheck ${PROJECT_SOURCE_DIR}/include/boolinq/boolinq.h --enable=all --force --inconclusive &>cppcheck.report ) ADD_CUSTOM_TARGET (cppcheck DEPENDS ${CppCheck_REPORT}) SET_DIRECTORY_PROPERTIES (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CppCheck_REPORT}) +# Initialize CMake target. +ADD_LIBRARY (boolinq INTERFACE) +ADD_LIBRARY (boolinq::boolinq ALIAS boolinq) + +TARGET_COMPILE_FEATURES (boolinq INTERFACE cxx_std_11) +TARGET_INCLUDE_DIRECTORIES (boolinq INTERFACE + $ + $ +) + + # Testing. -ADD_SUBDIRECTORY (externals/googletest) -ADD_SUBDIRECTORY (externals/benchmark) -ADD_SUBDIRECTORY (test) -ADD_SUBDIRECTORY (bench) -ADD_DEPENDENCIES ("${PROJECT_NAME}-test" gtest) -ADD_DEPENDENCIES ("${PROJECT_NAME}-test14" gtest) -ADD_DEPENDENCIES ("${PROJECT_NAME}-bench" benchmark) +IF (BUILD_TESTS OR BUILD_BENCHMARK) + FIND_PACKAGE(GTest QUIET) + IF (NOT GTest_FOUND) + ADD_SUBDIRECTORY (externals/googletest) + ENDIF () +ENDIF() + +IF (BUILD_TESTS) + ADD_SUBDIRECTORY (test) + IF (NOT GTest_FOUND) + ADD_DEPENDENCIES ("${PROJECT_NAME}-test" gtest) + ADD_DEPENDENCIES ("${PROJECT_NAME}-test14" gtest) + ENDIF () +ENDIF () + +IF (BUILD_BENCHMARK) + FIND_PACKAGE(benchmark QUIET) + IF (NOT benchmark_FOUND) + ADD_SUBDIRECTORY (externals/benchmark) + ADD_SUBDIRECTORY (bench) + ADD_DEPENDENCIES ("${PROJECT_NAME}-bench" benchmark) + ELSE () + ADD_SUBDIRECTORY (bench) + ENDIF () +ENDIF () + + +# Installation. +IF (NOT BOOLINQ_SUBPROJECT) + WRITE_BASIC_PACKAGE_VERSION_FILE ( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion + ) + + INSTALL (TARGETS boolinq EXPORT boolinqTargets) + + INSTALL (EXPORT boolinqTargets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/boolinq + NAMESPACE boolinq:: + FILE ${PROJECT_NAME}Config.cmake + ) + + INSTALL (FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/boolinq + ) + + INSTALL (DIRECTORY include/boolinq + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" + ) +ENDIF () diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index 96d5820..f87471d 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -8,18 +8,45 @@ SET (TARGET "${PROJECT_NAME}-bench" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wvla -W SET (TARGET "${PROJECT_NAME}-bench" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual -Wpointer-arith -Wold-style-cast") -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/include/boolinq) -INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/benchmark-src/include) -INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/googletest-src/googletest/include) - - # Benchmarks. ADD_EXECUTABLE ( "${PROJECT_NAME}-bench" ${PROJECT_SOURCE_DIR}/bench/SpeedTest.cpp ) + TARGET_LINK_LIBRARIES ( "${PROJECT_NAME}-bench" - benchmark - gtest + boolinq::boolinq ) + +IF (GTest_FOUND) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-bench" + GTest::gtest + ) +ELSE () + TARGET_INCLUDE_DIRECTORIES ( + "${PROJECT_NAME}-bench" PRIVATE + ${CMAKE_BINARY_DIR}/googletest-src/googletest/include + ) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-bench" + gtest + ) +ENDIF () + +IF (benchmark_FOUND) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-bench" + benchmark::benchmark + ) +ELSE () + TARGET_INCLUDE_DIRECTORIES ( + "${PROJECT_NAME}-bench" PRIVATE + ${CMAKE_BINARY_DIR}/benchmark-src/include + ) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-bench" + benchmark + ) +ENDIF () diff --git a/bench/SpeedTest.cpp b/bench/SpeedTest.cpp index 4d62f0e..f36ed6a 100644 --- a/bench/SpeedTest.cpp +++ b/bench/SpeedTest.cpp @@ -4,7 +4,7 @@ #include #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/AllTest.cpp b/test/AllTest.cpp index 4419ac2..6bcc4ec 100644 --- a/test/AllTest.cpp +++ b/test/AllTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/AnyTest.cpp b/test/AnyTest.cpp index 803e735..b14a539 100644 --- a/test/AnyTest.cpp +++ b/test/AnyTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/AppendTest.cpp b/test/AppendTest.cpp index d0f028a..bcb77f3 100644 --- a/test/AppendTest.cpp +++ b/test/AppendTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/AvgTest.cpp b/test/AvgTest.cpp index 5046584..a63b354 100644 --- a/test/AvgTest.cpp +++ b/test/AvgTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/BitsTest.cpp b/test/BitsTest.cpp index c51037e..5068d50 100644 --- a/test/BitsTest.cpp +++ b/test/BitsTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/BytesTest.cpp b/test/BytesTest.cpp index d78d273..c34a229 100644 --- a/test/BytesTest.cpp +++ b/test/BytesTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0976f15..99ee9f5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,9 +9,6 @@ SET (TARGET "${PROJECT_NAME}-test" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/include/boolinq) -INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/googletest-src/googletest/include) - # Unit tests. SET ( BoolinqTest_SOURCES @@ -61,10 +58,26 @@ ADD_EXECUTABLE ( TARGET_LINK_LIBRARIES ( "${PROJECT_NAME}-test" - gtest_main - gtest - #gcov + boolinq::boolinq ) +IF (GTest_FOUND) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-test" + GTest::gtest + GTest::gtest_main + ) +ELSE() + TARGET_INCLUDE_DIRECTORIES ( + "${PROJECT_NAME}-test" PRIVATE + ${CMAKE_BINARY_DIR}/googletest-src/googletest/include + ) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-test" + gtest_main + gtest + #gcov + ) +ENDIF () #separate target for the complex group by test requiring C++14 ADD_EXECUTABLE ( @@ -76,9 +89,25 @@ TARGET_COMPILE_FEATURES("${PROJECT_NAME}-test14" PRIVATE cxx_std_14) TARGET_LINK_LIBRARIES ( "${PROJECT_NAME}-test14" - gtest_main - gtest + boolinq::boolinq ) +IF (GTest_FOUND) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-test14" + GTest::gtest + GTest::gtest_main + ) +ELSE() + TARGET_INCLUDE_DIRECTORIES ( + "${PROJECT_NAME}-test14" PRIVATE + ${CMAKE_BINARY_DIR}/googletest-src/googletest/include + ) + TARGET_LINK_LIBRARIES ( + "${PROJECT_NAME}-test14" + gtest_main + gtest + ) +ENDIF () ENABLE_TESTING () ADD_TEST (BoolinqTest "${PROJECT_NAME}-test") diff --git a/test/CommonTests.h b/test/CommonTests.h index 41b7d2b..eaaa887 100644 --- a/test/CommonTests.h +++ b/test/CommonTests.h @@ -2,7 +2,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ConcatTest.cpp b/test/ConcatTest.cpp index 0ba5b21..54c183e 100644 --- a/test/ConcatTest.cpp +++ b/test/ConcatTest.cpp @@ -1,7 +1,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ContainsTest.cpp b/test/ContainsTest.cpp index 17de8fb..991e6c3 100644 --- a/test/ContainsTest.cpp +++ b/test/ContainsTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/CountTest.cpp b/test/CountTest.cpp index 58c4d47..7aa0c66 100644 --- a/test/CountTest.cpp +++ b/test/CountTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/CtorTest.cpp b/test/CtorTest.cpp index fee35a8..0ed32de 100644 --- a/test/CtorTest.cpp +++ b/test/CtorTest.cpp @@ -9,7 +9,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/DistinctTest.cpp b/test/DistinctTest.cpp index c713a53..a0583e0 100644 --- a/test/DistinctTest.cpp +++ b/test/DistinctTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/DotCallTest.cpp b/test/DotCallTest.cpp index 6c7eb81..e79302c 100644 --- a/test/DotCallTest.cpp +++ b/test/DotCallTest.cpp @@ -6,7 +6,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ElementAtTest.cpp b/test/ElementAtTest.cpp index 8b8c4e2..52fd6eb 100644 --- a/test/ElementAtTest.cpp +++ b/test/ElementAtTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/FirstTest.cpp b/test/FirstTest.cpp index d2abc49..7971c0e 100644 --- a/test/FirstTest.cpp +++ b/test/FirstTest.cpp @@ -4,7 +4,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ForEachTest.cpp b/test/ForEachTest.cpp index fa3955f..b8e3c00 100644 --- a/test/ForEachTest.cpp +++ b/test/ForEachTest.cpp @@ -4,7 +4,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/GroupByTest.cpp b/test/GroupByTest.cpp index edcf0d0..48313d0 100644 --- a/test/GroupByTest.cpp +++ b/test/GroupByTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/GroupByTestComplex.cpp b/test/GroupByTestComplex.cpp index 285c2e0..011e115 100644 --- a/test/GroupByTestComplex.cpp +++ b/test/GroupByTestComplex.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/LastTest.cpp b/test/LastTest.cpp index 439e126..898a92d 100644 --- a/test/LastTest.cpp +++ b/test/LastTest.cpp @@ -4,7 +4,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/LinqTest.cpp b/test/LinqTest.cpp index 7285cdb..64a799b 100644 --- a/test/LinqTest.cpp +++ b/test/LinqTest.cpp @@ -5,7 +5,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/MaxTest.cpp b/test/MaxTest.cpp index ef0cbc2..f6b2976 100644 --- a/test/MaxTest.cpp +++ b/test/MaxTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/MinTest.cpp b/test/MinTest.cpp index f28a446..729c7cb 100644 --- a/test/MinTest.cpp +++ b/test/MinTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/OrderByTest.cpp b/test/OrderByTest.cpp index d4715e4..a506179 100644 --- a/test/OrderByTest.cpp +++ b/test/OrderByTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/PrependTest.cpp b/test/PrependTest.cpp index ce978c9..94fbbb3 100644 --- a/test/PrependTest.cpp +++ b/test/PrependTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/RangeTest.cpp b/test/RangeTest.cpp index ad7b97c..ecd5b55 100644 --- a/test/RangeTest.cpp +++ b/test/RangeTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ReverseTest.cpp b/test/ReverseTest.cpp index 279f6f9..f497d06 100644 --- a/test/ReverseTest.cpp +++ b/test/ReverseTest.cpp @@ -6,7 +6,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/SelectManyTest.cpp b/test/SelectManyTest.cpp index 98e767b..b963cc6 100644 --- a/test/SelectManyTest.cpp +++ b/test/SelectManyTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/SelectTest.cpp b/test/SelectTest.cpp index f6257c2..e1992d2 100644 --- a/test/SelectTest.cpp +++ b/test/SelectTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/SkipTest.cpp b/test/SkipTest.cpp index 4296b43..c190fc6 100644 --- a/test/SkipTest.cpp +++ b/test/SkipTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/SkipWhileTest.cpp b/test/SkipWhileTest.cpp index 1cad78d..9b433e8 100644 --- a/test/SkipWhileTest.cpp +++ b/test/SkipWhileTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/SumTest.cpp b/test/SumTest.cpp index 436d6c5..23ad9f7 100644 --- a/test/SumTest.cpp +++ b/test/SumTest.cpp @@ -3,7 +3,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/TakeTest.cpp b/test/TakeTest.cpp index 41ab987..8557083 100644 --- a/test/TakeTest.cpp +++ b/test/TakeTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/TakeWhileTest.cpp b/test/TakeWhileTest.cpp index 8bb5975..6b47a9d 100644 --- a/test/TakeWhileTest.cpp +++ b/test/TakeWhileTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ToStdDequeTest.cpp b/test/ToStdDequeTest.cpp index 4998828..ac01f0e 100644 --- a/test/ToStdDequeTest.cpp +++ b/test/ToStdDequeTest.cpp @@ -2,7 +2,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ToStdListTest.cpp b/test/ToStdListTest.cpp index 3f33ebb..464f98d 100644 --- a/test/ToStdListTest.cpp +++ b/test/ToStdListTest.cpp @@ -2,7 +2,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ToStdSetTest.cpp b/test/ToStdSetTest.cpp index 4d152a3..330f44f 100644 --- a/test/ToStdSetTest.cpp +++ b/test/ToStdSetTest.cpp @@ -2,7 +2,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/ToStdVectorTest.cpp b/test/ToStdVectorTest.cpp index 4d495e8..10daaef 100644 --- a/test/ToStdVectorTest.cpp +++ b/test/ToStdVectorTest.cpp @@ -2,7 +2,7 @@ #include -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/UnbitsTest.cpp b/test/UnbitsTest.cpp index 371262d..5c38f80 100644 --- a/test/UnbitsTest.cpp +++ b/test/UnbitsTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/UnbytesTest.cpp b/test/UnbytesTest.cpp index 924b0ff..c1d727f 100644 --- a/test/UnbytesTest.cpp +++ b/test/UnbytesTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq; diff --git a/test/WhereTest.cpp b/test/WhereTest.cpp index 00a3b7f..16a858a 100644 --- a/test/WhereTest.cpp +++ b/test/WhereTest.cpp @@ -4,7 +4,7 @@ #include #include "CommonTests.h" -#include "boolinq.h" +#include using namespace boolinq;