Merge from GitLab CMake-CLion feature branch

This commit is contained in:
John Wellbelove 2018-10-28 12:54:45 +00:00
parent 4703b78fb9
commit 7ceabcb571
4 changed files with 58 additions and 26 deletions

11
.gitignore vendored
View File

@ -236,3 +236,14 @@ pip-log.txt
*.session
*.tags
*.db
#############
## CLion
#############
.idea/
# CMake
cmake-build-*/
unittest-cpp

View File

@ -13,12 +13,12 @@ project(etl)
set(ETL_PROFILE "DEFAULT" CACHE STRING "Defines what profile header to include. See https://www.etlcpp.com/setup.html"
)
option(BUILD_TESTS "Build unit tests" ON)
option(BUILD_TESTS "Build unit tests" OFF)
# Note: this will not compile src/c/ecl_timer.c as that c file has a dependence
# on ecl_user.h which is provided by clients of this library
add_library(etl
add_library(etl STATIC
src/binary.cpp
src/crc16.cpp
src/crc16_ccitt.cpp
@ -29,8 +29,6 @@ add_library(etl
src/error_handler.cpp
src/pearson.cpp
src/random.cpp
src/private
src/private/pvoidvector.cpp
)
target_include_directories(etl
PUBLIC

View File

@ -43,16 +43,35 @@ SOFTWARE.
#if defined(ETL_IN_UNIT_TEST)
#if !defined(ETLSTD)
#define ETLSTD etlstd
#define ETLSTD etlstd
#endif
namespace etlstd
namespace etlstd
#else
#if !defined(ETLSTD)
#define ETLSTD std
#define ETLSTD std
#endif
namespace std
namespace std
#endif
{
//***************************************************************************
// advance
template <typename TIterator, typename TDistance>
typename etl::enable_if<!etl::is_same<typename ETLSTD::iterator_traits<TIterator>::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type
advance(TIterator itr, TDistance distance)
{
while (distance-- != 0)
{
++itr;
}
}
template <typename TIterator, typename TDistance>
typename etl::enable_if<etl::is_same<typename ETLSTD::iterator_traits<TIterator>::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type
advance(TIterator itr, TDistance distance)
{
return itr += distance;
}
//***************************************************************************
// copy
// Pointer
@ -234,7 +253,7 @@ SOFTWARE.
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare;
return ETLSTD::make_pair(ETLSTD::lower_bound(first, last, value, compare()),
ETLSTD::upper_bound(first, last, value, compare()));
ETLSTD::upper_bound(first, last, value, compare()));
}
//***************************************************************************
@ -242,7 +261,7 @@ SOFTWARE.
template <typename TIterator, typename TUnaryPredicate>
TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
while (first != last)
while (first != last)
{
if (predicate(*first))
{
@ -302,7 +321,7 @@ SOFTWARE.
{
*first++ = value;
}
return first;
}
@ -322,7 +341,7 @@ SOFTWARE.
while (first != last)
{
if (*first == value)
if (*first == value)
{
++n;
}
@ -342,7 +361,7 @@ SOFTWARE.
while (first != last)
{
if (predicate(*first))
if (predicate(*first))
{
++n;
}
@ -473,7 +492,7 @@ SOFTWARE.
template <typename TIteratorIn, typename TIteratorOut, typename TUnaryOperation>
TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation)
{
while (first1 != last1)
while (first1 != last1)
{
*d_first++ = unary_operation(*first1++);
}
@ -572,7 +591,7 @@ SOFTWARE.
value_t value = last[-1];
last[-1] = first[0];
private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), value, compare);
}

View File

@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.5.0)
project(etl_unit_tests)
# Bring in the UnitTest++ include directories and libraries
find_package(UnitTest++)
add_definitions(-DETL_DEBUG)
if(NOT UnitTest++_FOUND)
# Add unittest-cpp as an ExternalProject
# Add unittest-cpp as an ExternalProject
include(cmake/unit-test_external_project.cmake)
add_unittest_cpp()
else()
@ -46,7 +46,7 @@ set(TEST_SOURCE_FILES
test_enum_type.cpp
test_error_handler.cpp
test_exception.cpp
test_factory.cpp
# test_factory.cpp
test_fixed_iterator.cpp
test_flat_map.cpp
test_flat_multimap.cpp
@ -120,27 +120,31 @@ set(TEST_SOURCE_FILES
test_xor_rotate_checksum.cpp
# Compile the source level ecl_timer here as test has provided a ecl_user.h file
${CMAKE_SOURCE_DIR}/src/c/ecl_timer.c
${PROJECT_SOURCE_DIR}/../src/c/ecl_timer.c
)
if (WIN32)
# test_error_handler.cpp uses windows APIs that assume the microsoft project
# is setup for unicode support. Note: This may have adverse effects on client
# projects and the tests should be updated to be independent of project setup
# projects and the tests should be updated to be independent of project setup
ADD_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_UNICODE)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
list(APPEND TEST_SOURCE_FILES "test_atomic_gcc_sync.cpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
endif()
add_executable(etl_tests
add_executable(etl_tests
${TEST_SOURCE_FILES}
)
target_link_libraries(etl_tests etl UnitTest++)
target_include_directories(etl_tests
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Enable the 'make test' CMake target using the executable defined above
@ -152,6 +156,6 @@ add_test(etl_unit_tests etl_tests)
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
# Remaining Tests to be implemented:
# Remaining Tests to be implemented:
#1. Enable embedded compile target testing
# - test_embedded_compile.cpp