From dbb84885e3eaeeecfd6861b25bdea2034f6a25de Mon Sep 17 00:00:00 2001 From: maakshishov Date: Thu, 16 Jul 2020 16:33:31 +0300 Subject: [PATCH 1/9] pimatmatrix test --- CMakeLists.txt | 20 +++++++++++++++----- lib/main/math/test/testpimathmatrix.cpp | 0 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 lib/main/math/test/testpimathmatrix.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff959ed..b647673e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(pip) set(_PIP_MAJOR 1) -set(_PIP_MINOR 24) +set(_PIP_MINOR 23) set(_PIP_REVISION 0) set(_PIP_SUFFIX ) set(_PIP_COMPANY SHS) set(_PIP_DOMAIN org.SHS) - +set(TESTS=true) if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") endif() @@ -35,7 +35,7 @@ option(STD_IOSTREAM "Building with std iostream operators support" OFF) option(INTROSPECTION "Build with introspection" OFF) option(LIB "System install" ON) option(STATIC_LIB OFF) -option(TESTS "Build tests and perform their before install step" OFF) +option(TESTS "Build tests and perform their before install step" ON) set(PIP_UTILS 1) if(LIBPROJECT) set(PIP_UTILS ${UTILS}) @@ -86,6 +86,7 @@ set(PHDRS) if (TESTS) set(PIP_SRC_CONCURRENT_TEST "lib/concurrent/test") + set(PIP_SRC_MATH_TEST "lib/main/math/test") endif() if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) @@ -275,10 +276,14 @@ endif() if (TESTS) include(DownloadGTest) set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library" + set(MATH_TESTS 1) #"Enable tests for concurrent library" else() set(CONCURRENT_TESTS 0) + set(MATH_TESTS 0) endif() + + # Check if std::iostream operators support if(STD_IOSTREAM) add_definitions(-DPIP_STD_IOSTREAM) @@ -600,8 +605,13 @@ if (NOT CROSSTOOLS) target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) add_test(NAME pip_concurrent_test COMMAND tests) add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) - endif() - + endif() + if(MATH_TESTS) + add_executable(pip_math_test ${CPP_MATH_TEST}) + target_link_libraries(pip_math_test gtest_main gmock_main pip_math) + add_test(NAME pip_math_test COMMAND tests) + add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) + endif() # Build cloud library if crypt enabled if(sodium_FOUND) diff --git a/lib/main/math/test/testpimathmatrix.cpp b/lib/main/math/test/testpimathmatrix.cpp new file mode 100644 index 00000000..e69de29b From d8e47afe139f02a2e8803b0bd1ce68460d6ab9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Thu, 23 Jul 2020 17:28:10 +0300 Subject: [PATCH 2/9] matrix tests --- CMakeLists.txt | 19 +- lib/main/math/test/testpimathmatrix.cpp | 936 ++++++++++++++++++++++++ 2 files changed, 947 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b647673e..ee727801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,7 +185,7 @@ set(PIP_MAIN_FOLDERS) foreach(F ${PIP_FOLDERS}) list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"") include_directories("${PIP_SRC_MAIN}/${F}") - gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) + gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) endforeach(F) # Crypt lib gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS) @@ -216,6 +216,9 @@ gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS) # Cloud lib gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS) +#Math test lib +gather_src("${PIP_SRC_MATH_TEST}" CPP_MATH_TEST HDRS PHDRS) + if(PIP_FREERTOS) add_definitions(-DPIP_FREERTOS) set(ICU OFF) @@ -605,13 +608,13 @@ if (NOT CROSSTOOLS) target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) add_test(NAME pip_concurrent_test COMMAND tests) add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) - endif() - if(MATH_TESTS) - add_executable(pip_math_test ${CPP_MATH_TEST}) - target_link_libraries(pip_math_test gtest_main gmock_main pip_math) - add_test(NAME pip_math_test COMMAND tests) - add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) - endif() + endif() + if(MATH_TESTS) + add_executable(pip_math_test ${CPP_MATH_TEST}) + target_link_libraries(pip_math_test gtest_main gmock_main PIP) + add_test(NAME pip_math_test COMMAND tests) + #add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) + endif() # Build cloud library if crypt enabled if(sodium_FOUND) diff --git a/lib/main/math/test/testpimathmatrix.cpp b/lib/main/math/test/testpimathmatrix.cpp index e69de29b..8dbef289 100644 --- a/lib/main/math/test/testpimathmatrix.cpp +++ b/lib/main/math/test/testpimathmatrix.cpp @@ -0,0 +1,936 @@ +#include "gtest/gtest.h" +#include "pimathmatrix.h" + +using namespace std; + +PIMathMatrix origMatr; + +TEST(PIMathMatrix_Test, identity) +{ + PIMathMatrix matrix; + int i; + double d; + bool a, b; + matrix = origMatr.identity(3, 3); + d = matrix.determinant(); + for(i = 0; i < 3; i++) + { + if(matrix[i][i] == 1.0) + { + b = true; + } + else + { + b = false; + break; + } + } + if(d == 1.0) + { + a = true; + } + else + { + a = false; + } + ASSERT_TRUE(a && b); +} + +TEST(PIMathMatrix_Test, matrixRow) +{ + PIMathMatrix matrix; + PIMathVector vector; + uint i; + bool b; + vector.resize(3, 3.0); + vector.fill(5.0); + matrix = origMatr.matrixRow(vector); + for(i = 0; i < vector.size(); i++) + { + if(matrix[0][i] == 5.0) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, matrixCol) +{ + PIMathMatrix matrix; + PIMathVector vector; + uint i; + bool b; + vector.resize(3, 3.0); + vector.fill(5.0); + matrix = origMatr.matrixCol(vector); + for(i = 0; i < vector.size(); i++) + { + if(matrix[i][0] == 5.0) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, setCol) +{ + PIMathMatrix matrix; + PIMathVector vector; + uint i; + bool b; + vector.resize(3, 3.0); + vector.fill(5.0); + matrix = origMatr.matrixCol(vector); + vector.fill(10.0); + matrix.setCol(0, vector); + for(i = 0; i < vector.size(); i++) + { + if(matrix[i][0] == 10.0) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, setRow) +{ + PIMathMatrix matrix; + PIMathVector vector; + uint i; + bool b; + vector.resize(3, 3.0); + vector.fill(5.0); + matrix = origMatr.matrixRow(vector); + vector.fill(10.0); + matrix.setRow(0, vector); + for(i = 0; i < vector.size(); i++) + { + if(matrix[0][i] == 10.0) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, swapCols) +{ + PIMathMatrix matrix1; + PIMathVector vector; + uint i1 = 0; uint i2 = 1; + double a1[3], a2[3], a3[3]; + double b1[3], b2[3], b3[3]; + bool b; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1 = origMatr.identity(3, 3); + matrix1.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + for(int i = 0; i < 3; i++) + { + a1[i] = matrix1.element(i, 0); + a2[i] = matrix1.element(i, 1); + a3[i] = matrix1.element(i, 2); + } + matrix1.swapCols(i1, i2); + for(int i = 0; i < 3; i++) + { + b1[i] = matrix1.element(i, 0); + b2[i] = matrix1.element(i, 1); + b3[i] = matrix1.element(i, 2); + } + if((memcmp(a1, b2, sizeof(b1)) == 0) && (memcmp(a2, b1, sizeof(b1)) == 0) && (memcmp(a3, b3, sizeof(b1)) == 0)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, swapRows) +{ + PIMathMatrix matrix1; + PIMathVector vector; + uint i1 = 0; uint i2 = 1; + double a1[3], a2[3], a3[3]; + double b1[3], b2[3], b3[3]; + bool b; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1 = origMatr.identity(3, 3); + matrix1.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + for(int i = 0; i < 3; i++) + { + a1[i] = matrix1.element(0, i); + a2[i] = matrix1.element(1, i); + a3[i] = matrix1.element(2, i); + } + matrix1.swapRows(i1, i2); + for(int i = 0; i < 3; i++) + { + b1[i] = matrix1.element(0, i); + b2[i] = matrix1.element(1, i); + b3[i] = matrix1.element(2, i); + } + if((memcmp(a1, b2, sizeof(b1)) == 0) && (memcmp(a2, b1, sizeof(b1)) == 0) && (memcmp(a3, b3, sizeof(b1)) == 0)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} +TEST(PIMathMatrix_Test, fill) +{ + PIMathMatrix matrix; + int i = 0; + int j = 0; + int k = 0; + bool b; + matrix = origMatr.identity(3, 3); + matrix.fill(5.0); + while(i < 9) + { + if(k < 3) + { + if(matrix.element(j,k) == 5.0) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, isSquare) +{ + + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(4,3); + if((matrix1.isSquare() == true) && (matrix2.isSquare() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, isIdentity) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix2.fill(3.932); + if((matrix1.isIdentity() == true) && (matrix2.isIdentity() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, isNull) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix1.fill(0.0); + matrix2.fill(3.932); + if((matrix1.isNull() == true) && (matrix2.isNull() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, isValid) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + matrix1 = origMatr.identity(3,3); + if((matrix1.isValid() == true) && (matrix2.isValid() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Assignment) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + int i = 0; + int j = 0; + int k = 0; + bool b; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix2.fill(6.72); + matrix1 = matrix2; + while(i < 9) + { + if(k < 3) + { + if(matrix1.element(j,k) == 6.72) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Equal) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + PIMathMatrix matrix3; + PIMathVector vector; + bool b; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix3 = origMatr.identity(3,3); + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1.setCol(0, vector); + matrix2.setCol(0, vector); + matrix3.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + matrix2.setCol(1, vector); + matrix3.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + matrix2.setCol(2, vector); + vector.at(0) = 566.0; + vector.at(1) = 564.0; + vector.at(2) = 543.0; + matrix3.setCol(2, vector); + if(((matrix1 == matrix2) == true) && ((matrix1 == matrix3) == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Not_Equal) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + PIMathMatrix matrix3; + PIMathVector vector; + bool b; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix3 = origMatr.identity(3,3); + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1.setCol(0, vector); + matrix2.setCol(0, vector); + matrix3.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + matrix2.setCol(1, vector); + matrix3.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + matrix2.setCol(2, vector); + vector.at(0) = 566.0; + vector.at(1) = 564.0; + vector.at(2) = 543.0; + matrix3.setCol(2, vector); + if(((matrix1 != matrix2) == false) && ((matrix1 != matrix3) == true)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Addition_Aassignment) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix2.fill(6.72); + matrix1.fill(1.0); + matrix1 += matrix2; + while(i < 9) + { + if(k < 3) + { + if(matrix1.element(j,k) == 7.72) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Subtraction_Assignment) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix2.fill(6.72); + matrix1.fill(1.0); + matrix1 -= matrix2; + while(i < 9) + { + if(k < 3) + { + if(matrix1.element(j,k) == -5.72) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Multiplication_Assignment) +{ + PIMathMatrix matrix1; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix1.fill(6.72); + matrix1 *= 2.0; + while(i < 9) + { + if(k < 3) + { + if(matrix1.element(j,k) == 13.44) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Division_Assignment) +{ + PIMathMatrix matrix1; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix1.fill(6.72); + matrix1 /= 2.0; + while(i < 9) + { + if(k < 3) + { + if(matrix1.element(j,k) == 3.36) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Addition) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix1.fill(6.72); + matrix2.fill(8.28); + while(i < 9) + { + if(k < 3) + { + if((matrix1+matrix2).element(j,k) == 15.0) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Subtraction) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + matrix1 = origMatr.identity(3, 3); + matrix2 = origMatr.identity(3, 3); + origMatr.fill(8.0); + matrix1.fill(8.28); + origMatr = origMatr - matrix1; + matrix2.fill(-0.28); + if(origMatr == matrix2) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, operator_Multiplication) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix1.fill(6.72); + matrix2 = matrix1*4.0; + while(i < 9) + { + if(k < 3) + { + if(matrix2.element(j,k) == 26.88) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} +TEST(PIMathMatrix_Test, operator_Division) +{ + PIMathMatrix matrix1; + PIMathMatrix matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1 = origMatr.identity(3,3); + matrix2 = origMatr.identity(3,3); + matrix1.fill(6.72); + matrix2 = matrix1/4.0; + while(i < 9) + { + if(k < 3) + { + if(matrix2.element(j,k) == 1.68) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, determinant) +{ + double d; + double i = 59.0; + PIMathMatrix matrix; + PIMathVector vector; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix = origMatr.identity(3, 3); + matrix.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix.setCol(2, vector); + d = matrix.determinant(); + ASSERT_DOUBLE_EQ(d, i); +} + +TEST(PIMathMatrix_Test, trace) +{ + double t; + double i = 9.0; + PIMathMatrix matrix; + PIMathVector vector; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix = origMatr.identity(3, 3); + matrix.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix.setCol(2, vector); + t = matrix.trace(); + ASSERT_DOUBLE_EQ(t, i); +} + +TEST(PIMathMatrix_Test, toUpperTriangular) +{ + double d1, d2 = 1; + int i; + PIMathMatrix matrix; + PIMathVector vector; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix = origMatr.identity(3, 3); + matrix.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix.setCol(2, vector); + d1 = matrix.determinant(); + matrix.toUpperTriangular(); + for(i = 0; i < 3; i++) + { + d2 = d2 * matrix.element(i, i); + } + ASSERT_DOUBLE_EQ(d1, d2); +} + +TEST(PIMathMatrix_Test, invert) +{ + double d1, d2; + bool b; + PIMathMatrix matrix1; + PIMathMatrix matrix2; + PIMathMatrix matrix3; + PIMathMatrix matrix4; + PIMathVector vector; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1 = origMatr.identity(3, 3); + matrix1.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + d1 = matrix1.determinant(); + matrix2 = matrix1; + matrix2.invert(); + d2 = matrix2.determinant(); + matrix3 = origMatr.identity(3, 3); + matrix4 = origMatr.identity(3, 3); + matrix4.invert(); + if((matrix3 == matrix4) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, inverted) +{ + double d1, d2; + bool b; + PIMathMatrix matrix1; + PIMathMatrix matrix2; + PIMathMatrix matrix3; + PIMathMatrix matrix4; + PIMathVector vector; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1 = origMatr.identity(3, 3); + matrix1.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + d1 = matrix1.determinant(); + matrix2 = matrix1; + matrix1 = matrix2.invert(); + d2 = matrix1.determinant(); + matrix3 = origMatr.identity(3, 3); + matrix4 = origMatr.identity(3, 3); + matrix3 = matrix4.invert(); + if((matrix3 == matrix4) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrix_Test, transposed) +{ + double d1, d2; + bool b; + PIMathMatrix matrix1; + PIMathMatrix matrix2; + PIMathMatrix matrix3; + PIMathVector vector; + vector.resize(3, 3.0); + vector.at(0) = 3.0; + vector.at(1) = 6.0; + vector.at(2) = 8.0; + matrix1 = origMatr.identity(3, 3); + matrix1.setCol(0, vector); + vector.at(0) = 2.0; + vector.at(1) = 1.0; + vector.at(2) = 4.0; + matrix1.setCol(1, vector); + vector.at(0) = 6.0; + vector.at(1) = 2.0; + vector.at(2) = 5.0; + matrix1.setCol(2, vector); + d1 = matrix1.determinant(); + matrix2 = matrix1.transposed(); + d2 = matrix2.determinant(); + matrix3 = matrix2.transposed(); + if((d1 == d2) && (matrix1 == matrix3)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + + From bb635f6c514a181519d208185c37ec55d4e73fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Thu, 23 Jul 2020 17:29:37 +0300 Subject: [PATCH 3/9] matrix testing --- lib/main/math/test/testpimathmatrixt.cpp | 991 +++++++++++++++++++++++ 1 file changed, 991 insertions(+) create mode 100644 lib/main/math/test/testpimathmatrixt.cpp diff --git a/lib/main/math/test/testpimathmatrixt.cpp b/lib/main/math/test/testpimathmatrixt.cpp new file mode 100644 index 00000000..1d343237 --- /dev/null +++ b/lib/main/math/test/testpimathmatrixt.cpp @@ -0,0 +1,991 @@ +#include "gtest/gtest.h" +#include "pimathmatrix.h" + +const uint rows = 3; +const uint cols = 3; +PIMathMatrixT matr; +PIMathVectorT vect; + +TEST(PIMathMatrixT_Test, identity) +{ + PIMathMatrixT matrix; + double d; + double i = 1.0; + bool a; + bool output; + matrix = matr.identity(); + d = matrix.determinant(); + uint j; + for(j = 0; j < cols; j++) + { + if(matrix.at(i, i) == 1.0) a = true; + else + { + a = false; + break; + } + } + if((i == d) && (a == true)){ + output = true; + } + else{ + output = false; + } + ASSERT_TRUE(output); +} + +TEST(PIMathMatrixT_Test, at) +{ + uint i; + bool b; + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + matrix1 = matr.identity(); + matrix2 = matr.identity(); + for(i = 0; i < rows; i++) + { + if(matrix1.at(i,i) == 1.0) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} +TEST(PIMathMatrixT_Test, filled) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + double g = 1.0; + matrix2 = matr.fill(g); + uint j = 0, i = 0; + for(i = 0; i < cols; i++) + { + for(j = 0; j < rows; j++) + { + matrix1.at(j,i) = g; + } + } + ASSERT_TRUE(matrix2 == matrix1); +} + +TEST(PIMathMatrixT_Test, cols) +{ + ASSERT_EQ(cols,matr.cols()); +} + +TEST(PIMathMatrixT_Test, rows) +{ + ASSERT_EQ(rows,matr.rows()); +} + +TEST(PIMathMatrixT_Test, col) +{ + uint i; + uint g = 2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + vect = matr.col(g); + for(i = 0; i < matr.cols(); i++) + { + if(matr.at(i,g) == vect.at(i)) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, row) +{ + uint i; + uint g = 2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + vect = matr.row(g); + for(i = 0; i < matr.rows(); i++) + { + if(matr.at(g,i) == vect.at(i)) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, setCol) +{ + vect.at(0) = 1.0; + vect.at(1) = 3.0; + vect.at(2) = 5.0; + uint g = 1; + uint i = 0; + bool b; + matr.setCol(g, vect); + for(i = 0; i < vect.size(); i++) + { + if(matr.at(i,g) == vect.at(i)) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, setRow) +{ + vect.at(0) = 1.0; + vect.at(1) = 3.0; + vect.at(2) = 5.0; + uint g = 1; + uint i = 0; + bool b; + matr.setRow(g, vect); + for(i = 0; i < vect.size(); i++) + { + if(matr.at(g,i) == vect.at(i)) + { + b = true; + } + else + { + b = false; + break; + } + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, swapCols) +{ + PIMathVectorT before_Vect1; + PIMathVectorT before_Vect2; + PIMathVectorT after_Vect1; + PIMathVectorT after_Vect2; + int g1 = 1, g2 = 2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + before_Vect1 = matr.col(g1); + before_Vect2 = matr.col(g2); + matr.swapCols(g1,g2); + after_Vect1 = matr.col(g1); + after_Vect2 = matr.col(g2); + if((before_Vect1 == after_Vect2) && (before_Vect2 == after_Vect1)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, swapRows) +{ + PIMathVectorT before_Vect1; + PIMathVectorT before_Vect2; + PIMathVectorT after_Vect1; + PIMathVectorT after_Vect2; + int g1 = 1, g2 = 2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + before_Vect1 = matr.row(g1); + before_Vect2 = matr.row(g2); + matr.swapRows(g1,g2); + after_Vect1 = matr.row(g1); + after_Vect2 = matr.row(g2); + if((before_Vect1 == after_Vect2) && (before_Vect2 == after_Vect1)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, fill) +{ + PIMathMatrixT matrix1; + double g = 1.0; + matr.fill(g); + uint j = 0, i = 0; + for(i = 0; i < cols; i++) + { + for(j = 0; j < rows; j++) + { + matrix1.at(j,i) = g; + } + } + ASSERT_TRUE(matr == matrix1); +} + +TEST(PIMathMatrixT_Test, isSquare) +{ + PIMathMatrixT matrix1; + const uint new_Cols = 4; + PIMathMatrixT matrix2; + bool b; + if((matrix1.isSquare() == true) && (matrix2.isSquare() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, isIdentity) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + matrix1 = matr.identity(); + matrix2 = matr.filled(3.67); + if((matrix1.isIdentity() == true) && (matrix2.isIdentity() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, isNull) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + matrix2 = matr.filled(3.67); + if((matrix1.isNull() == true) && (matrix2.isNull() == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Assignment) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + int i = 0; + int j = 0; + int k = 0; + bool b; + matrix2.fill(6.72); + matrix1 = matrix2; + while(i < 9) + { + if(k < 3) + { + if(matrix1.at(j,k) == 6.72) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Equal) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + matrix1 = matr; + matrix2 = matr; + matrix2.at(2, 2) = 232; + if(((matr == matrix1) == true) && ((matr == matrix2) == false)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Not_Equal) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + matrix1 = matr; + matrix2 = matr; + matrix2.at(2, 2) = 232; + if(((matr != matrix1) == false) && ((matr != matrix2) == true)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Addition_Aassignment) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix2.fill(6.72); + matrix1.fill(1.0); + matrix1 += matrix2; + while(i < 9) + { + if(k < 3) + { + if(matrix1.at(j,k) == 7.72) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix2.fill(6.72); + matrix1.fill(1.0); + matrix1 -= matrix2; + while(i < 9) + { + if(k < 3) + { + if(matrix1.at(j,k) == -5.72) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment) +{ + PIMathMatrixT matrix1; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1.fill(6.72); + matrix1 *= 2.0; + while(i < 9) + { + if(k < 3) + { + if(matrix1.at(j,k) == 13.44) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Division_Assignment) +{ + PIMathMatrixT matrix1; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1.fill(6.72); + matrix1 /= 2.0; + while(i < 9) + { + if(k < 3) + { + if(matrix1.at(j,k) == 3.36) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Addition) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1.fill(6.72); + matrix2.fill(8.28); + while(i < 9) + { + if(k < 3) + { + if((matrix1 + matrix2).at(j,k) == 15.0) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Subtraction) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1.fill(6.72); + matrix2.fill(8.28); + while(i < 9) + { + if(k < 3) + { + if(round((matrix1 - matrix2).at(j,k) * 10000) / 10000 == -1.56) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, operator_Multiplication) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1.fill(6.72); + matrix2 = matrix1*4.0; + while(i < 9) + { + if(k < 3) + { + if(matrix2.at(j,k) == 26.88) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} +TEST(PIMathMatrixT_Test, operator_Division) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + bool b; + int i = 0; + int j = 0; + int k = 0; + matrix1.fill(6.72); + matrix2 = matrix1/4.0; + while(i < 9) + { + if(k < 3) + { + if(matrix2.at(j,k) == 1.68) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + ASSERT_TRUE(b); +} + + +TEST(PIMathMatrixT_Test, determinant) +{ + double d; + double i = 59.0; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + d = matr.determinant(); + ASSERT_DOUBLE_EQ(i, d); +} + +TEST(PIMathMatrixT_Test, invert) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + PIMathMatrixT matrix3; + double d1, d2; + bool b; + matrix1 = matr.identity(); + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + matrix2 = matr; + matr.invert(); + d1 = matr.determinant(); + d2 = matrix2.determinant(); + matrix3 = matrix1; + matrix1.invert(); + if((matrix1 == matrix3) && (d1 == 1/d2)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, inverted) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + PIMathMatrixT matrix3; + double d1, d2; + bool b; + matrix1 = matr.identity(); + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + matrix2 = matr.inverted(); + d1 = matr.determinant(); + d2 = matrix2.determinant(); + matrix3 = matrix1.inverted(); + if((matrix1 == matrix3) && (round((1/d1)*10000)/10000 == round(d2*10000)/10000)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, toUpperTriangular) +{ + PIMathMatrixT matrix; + double d1, d2 = 1; + uint i; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + matrix = matr.toUpperTriangular(); + d1 = matrix.determinant(); + for(i = 0; i < cols; i++) + { + d2 = d2*matrix.at(i,i); + } + ASSERT_DOUBLE_EQ(d1, d2); +} + +TEST(PIMathMatrixT_Test, transposed) +{ + PIMathMatrixT matrix1; + PIMathMatrixT matrix2; + double d1, d2; + bool b; + matr.at(0,0) = 3; + matr.at(0,1) = 6; + matr.at(0,2) = 8; + matr.at(1,0) = 2; + matr.at(1,1) = 1; + matr.at(1,2) = 4; + matr.at(2,0) = 6; + matr.at(2,1) = 2; + matr.at(2,2) = 5; + d1 = matr.determinant(); + matrix1 = matr.transposed(); + d2 = matrix1.determinant(); + matrix2 = matrix1.transposed(); + if((d1 == d2) && (matr == matrix2)) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, rotation) +{ + double angle = 1.0; + bool b; + PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::rotation(angle); + double c = cos(angle); + double s = sin(angle); + if((c == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (-s == matrix.at(0u,1u)) && (s == matrix.at(1u,0u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, scaleX_two) +{ + double factor = 5.64; + bool b; + PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleX(factor); + + if((1.0 == matrix.at(1u,1u)) && (factor == matrix.at(0u,0u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, scaleY_two) +{ + double factor = 5.64; + bool b; + PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::scaleY(factor); + + if((factor == matrix.at(1u,1u)) && (1.0 == matrix.at(0u,0u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, rotationX) +{ + double angle = 1.0; + bool b; + double c = cos(angle); + double s = sin(angle); + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotationX(angle); + + if((1.0 == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(2u,1u)) && (-s == matrix.at(1u,2u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, rotationY) +{ + double angle = 1.0; + bool b; + double c = cos(angle); + double s = sin(angle); + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotationY(angle); + + if((1.0 == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(2u,2u)) && (s == matrix.at(0u,2u)) && (-s == matrix.at(2u,0u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, rotationZ) +{ + double angle = 1.0; + bool b; + double c = cos(angle); + double s = sin(angle); + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotationZ(angle); + + if((1.0 == matrix.at(2u,2u)) && (c == matrix.at(0u,0u)) && (c == matrix.at(1u,1u)) && (s == matrix.at(1u,0u)) && (-s == matrix.at(0u,1u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, scaleX_three) +{ + double factor = 23.65; + bool b; + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleX(factor); + if((1.0 == matrix.at(2u,2u)) && (factor == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, scaleY_three) +{ + double factor = 23.65; + bool b; + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleY(factor); + if((1.0 == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (factor == matrix.at(1u,1u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, scaleZ_three) +{ + double factor = 23.65; + bool b; + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::scaleZ(factor); + if((factor == matrix.at(2u,2u)) && (1.0 == matrix.at(0u,0u)) && (1.0 == matrix.at(1u,1u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + From f71fbb00682996e170b9f6fafaa315db949f9fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Fri, 24 Jul 2020 15:24:13 +0300 Subject: [PATCH 4/9] new cmake --- CMakeLists.txt | 1155 ++++++++++++++++++++++++------------------------ 1 file changed, 579 insertions(+), 576 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee727801..f89c293b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(pip) set(_PIP_MAJOR 1) -set(_PIP_MINOR 23) +set(_PIP_MINOR 24) set(_PIP_REVISION 0) set(_PIP_SUFFIX ) set(_PIP_COMPANY SHS) set(_PIP_DOMAIN org.SHS) -set(TESTS=true) + if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") - set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set(PIP_BUILD 1) @@ -17,15 +17,15 @@ include(CheckFunctionExists) include(DeployMacros) include(PIPMacros) if(NOT DEFINED BUILD_NUMBER) - set(BUILD_NUMBER 9999) + set(BUILD_NUMBER 9999) endif() if("x${BUILD_NUMBER}" STREQUAL "x") - set(BUILD_NUMBER 0) + set(BUILD_NUMBER 0) endif() set(_ICU_DEFAULT OFF) if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE)) - set(_ICU_DEFAULT ON) + set(_ICU_DEFAULT ON) endif() @@ -38,23 +38,23 @@ option(STATIC_LIB OFF) option(TESTS "Build tests and perform their before install step" ON) set(PIP_UTILS 1) if(LIBPROJECT) - set(PIP_UTILS ${UTILS}) + set(PIP_UTILS ${UTILS}) endif() set(CMAKE_CXX_STANDARD 11) # Basic macro(gather_src DIR CPP H H_P) - set(CS) - set(HS) - set(PHS) - file(GLOB CS "${DIR}/*.cpp") - file(GLOB HS "${DIR}/*.h") - file(GLOB PHS "${DIR}/*_p.h") - list(REMOVE_ITEM HS "${PHS}") - list(APPEND ${CPP} ${CS}) - list(APPEND ${H} ${HS}) - list(APPEND ${H_P} ${PHS}) + set(CS) + set(HS) + set(PHS) + file(GLOB CS "${DIR}/*.cpp") + file(GLOB HS "${DIR}/*.h") + file(GLOB PHS "${DIR}/*_p.h") + list(REMOVE_ITEM HS "${PHS}") + list(APPEND ${CPP} ${CS}) + list(APPEND ${H} ${HS}) + list(APPEND ${H_P} ${PHS}) endmacro() set(PIP_SRC_MAIN "lib/main") @@ -68,16 +68,16 @@ set(PIP_SRC_IO_UTILS "lib/io_utils") set(PIP_SRC_CONCURRENT "lib/concurrent") set(PIP_SRC_CLOUD "lib/cloud") set(PIP_SRC_DIRS ${PIP_SRC_MAIN} - ${PIP_SRC_CONSOLE} - ${PIP_SRC_CRYPT} - ${PIP_SRC_COMPRESS} - ${PIP_SRC_USB} - ${PIP_SRC_FFTW} - ${PIP_SRC_OPENCL} - ${PIP_SRC_IO_UTILS} - ${PIP_SRC_CONCURRENT} - ${PIP_SRC_CLOUD} -) + ${PIP_SRC_CONSOLE} + ${PIP_SRC_CRYPT} + ${PIP_SRC_COMPRESS} + ${PIP_SRC_USB} + ${PIP_SRC_FFTW} + ${PIP_SRC_OPENCL} + ${PIP_SRC_IO_UTILS} + ${PIP_SRC_CONCURRENT} + ${PIP_SRC_CLOUD} + ) set(PIP_LIBS_TARGETS pip) set(LIBS_MAIN) set(LIBS_STATUS) @@ -85,89 +85,91 @@ set(HDRS) set(PHDRS) if (TESTS) - set(PIP_SRC_CONCURRENT_TEST "lib/concurrent/test") - set(PIP_SRC_MATH_TEST "lib/main/math/test") + include(DownloadGTest) + set(PIP_CONCURRENT_TEST "lib/concurrent/test") + set(PIP_SRC_MATH_TEST "lib/main/math/test") + set(PIP_SRC_CORE_TEST "lib/main/core/test") endif() if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) - set(STATIC_LIB ON) + set(STATIC_LIB ON) endif() if(STATIC_LIB) - set(PIP_LIB_TYPE STATIC) - add_definitions(-DPIP_STATIC_DEFINE) - #message(STATUS "Building PIP static library") + set(PIP_LIB_TYPE STATIC) + add_definitions(-DPIP_STATIC_DEFINE) + #message(STATUS "Building PIP static library") else() - set(PIP_LIB_TYPE SHARED) - #message(STATUS "Building PIP shared library") + set(PIP_LIB_TYPE SHARED) + #message(STATUS "Building PIP shared library") endif() # Version set_version(PIP - MAJOR "${_PIP_MAJOR}" - MINOR "${_PIP_MINOR}" - REVISION "${_PIP_REVISION}" - BUILD "${BUILD_NUMBER}" - SUFFIX "${_PIP_SUFFIX}" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") + MAJOR "${_PIP_MAJOR}" + MINOR "${_PIP_MINOR}" + REVISION "${_PIP_REVISION}" + BUILD "${BUILD_NUMBER}" + SUFFIX "${_PIP_SUFFIX}" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") set_deploy_property(pip ${PIP_LIB_TYPE} - LABEL "PIP main library" - FULLNAME "${_PIP_DOMAIN}.pip" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") + LABEL "PIP main library" + FULLNAME "${_PIP_DOMAIN}.pip" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") - file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") + file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") endif() list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") message(STATUS "Building PIP version ${PIP_VERSION} (${PIP_LIB_TYPE})") if(MINGW) - find_package(MinGW REQUIRED) - list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB}) + find_package(MinGW REQUIRED) + list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB}) else() - if(APPLE) - if(CMAKE_CROSSCOMPILING) - set(CMAKE_INSTALL_NAME_DIR "@rpath") - else() - include_directories(/usr/local/include) - link_directories(/usr/local/lib) - endif() - set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib") - set(CMAKE_MACOSX_RPATH 1) - else() - set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") - endif() + if(APPLE) + if(CMAKE_CROSSCOMPILING) + set(CMAKE_INSTALL_NAME_DIR "@rpath") + else() + include_directories(/usr/local/include) + link_directories(/usr/local/lib) + endif() + set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib") + set(CMAKE_MACOSX_RPATH 1) + else() + set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") + endif() endif() if(LIB) - if(WIN32) - if(MINGW) - set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) - endif() - else() - if (DEFINED ANDROID_PLATFORM) - set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) - else() - if(CMAKE_CROSSCOMPILING) - set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX}) - else() - set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local) - endif() - endif() - endif() + if(WIN32) + if(MINGW) + set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) + endif() + else() + if (DEFINED ANDROID_PLATFORM) + set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) + else() + if(CMAKE_CROSSCOMPILING) + set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX}) + else() + set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local) + endif() + endif() + endif() endif() if (NOT DEFINED PIP_CMG) - if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) - set(PIP_CMG "pip_cmg") - set(PIP_RC "pip_rc") - set(PIP_DEPLOY_TOOL "deploy_tool") - else() - set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator/pip_cmg") - set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler/pip_rc") - set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool/deploy_tool") - endif() + if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) + set(PIP_CMG "pip_cmg") + set(PIP_RC "pip_rc") + set(PIP_DEPLOY_TOOL "deploy_tool") + else() + set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator/pip_cmg") + set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler/pip_rc") + set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool/deploy_tool") + endif() endif() @@ -183,9 +185,9 @@ set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils include_directories("${PIP_SRC_MAIN}") set(PIP_MAIN_FOLDERS) foreach(F ${PIP_FOLDERS}) - list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"") - include_directories("${PIP_SRC_MAIN}/${F}") - gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) + list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"") + include_directories("${PIP_SRC_MAIN}/${F}") + gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) endforeach(F) # Crypt lib gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS) @@ -211,7 +213,7 @@ gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS) # Concurrent lib gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS) -gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS) +gather_src("${PIP_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS) # Cloud lib gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS) @@ -219,10 +221,13 @@ gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS) #Math test lib gather_src("${PIP_SRC_MATH_TEST}" CPP_MATH_TEST HDRS PHDRS) +#Core test lib +gather_src("${PIP_SRC_CORE_TEST}" CPP_CORE_TEST HDRS PHDRS) + if(PIP_FREERTOS) - add_definitions(-DPIP_FREERTOS) - set(ICU OFF) - set(LIB OFF) + add_definitions(-DPIP_FREERTOS) + set(ICU OFF) + set(LIB OFF) endif() # Check Bessel functions @@ -235,22 +240,22 @@ CHECK_FUNCTION_EXISTS(y0 PIP_MATH_Y0) CHECK_FUNCTION_EXISTS(y1 PIP_MATH_Y1) CHECK_FUNCTION_EXISTS(yn PIP_MATH_YN) if(PIP_MATH_J0) - add_definitions(-DPIP_MATH_J0) + add_definitions(-DPIP_MATH_J0) endif() if(PIP_MATH_J1) - add_definitions(-DPIP_MATH_J1) + add_definitions(-DPIP_MATH_J1) endif() if(PIP_MATH_JN) - add_definitions(-DPIP_MATH_JN) + add_definitions(-DPIP_MATH_JN) endif() if(PIP_MATH_Y0) - add_definitions(-DPIP_MATH_Y0) + add_definitions(-DPIP_MATH_Y0) endif() if(PIP_MATH_Y1) - add_definitions(-DPIP_MATH_Y1) + add_definitions(-DPIP_MATH_Y1) endif() if(PIP_MATH_YN) - add_definitions(-DPIP_MATH_YN) + add_definitions(-DPIP_MATH_YN) endif() @@ -258,8 +263,8 @@ endif() set(CMAKE_REQUIRED_INCLUDES time.h) set(CMAKE_REQUIRED_LIBRARIES ) if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT PIP_FREERTOS)) - list(APPEND LIBS_MAIN rt) - set(CMAKE_REQUIRED_LIBRARIES rt) + list(APPEND LIBS_MAIN rt) + set(CMAKE_REQUIRED_LIBRARIES rt) endif() CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0) CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1) @@ -268,41 +273,31 @@ CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2) # Check if build debug version if (CMAKE_BUILD_TYPE MATCHES Debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") - add_definitions(-DPIP_DEBUG) - message(STATUS "Building PIP debug version") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") + add_definitions(-DPIP_DEBUG) + message(STATUS "Building PIP debug version") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") - message(STATUS "Building PIP release version") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") + message(STATUS "Building PIP release version") endif() -if (TESTS) - include(DownloadGTest) - set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library" - set(MATH_TESTS 1) #"Enable tests for concurrent library" -else() - set(CONCURRENT_TESTS 0) - set(MATH_TESTS 0) -endif() - - # Check if std::iostream operators support if(STD_IOSTREAM) - add_definitions(-DPIP_STD_IOSTREAM) - message(STATUS "Building PIP with std iostream operators support") + add_definitions(-DPIP_STD_IOSTREAM) + message(STATUS "Building PIP with std iostream operators support") else() - message(STATUS "Building PIP without std iostream operators support") + message(STATUS "Building PIP without std iostream operators support") endif() # Check if ICU used for PIString and PIChar if(ICU) - message(STATUS "Building PIP with ICU") - add_definitions(-DPIP_ICU) - list(APPEND LIBS_MAIN icuuc) + message(STATUS "Building PIP with ICU") + add_definitions(-DPIP_ICU) + list(APPEND LIBS_MAIN icuuc) else() - message(STATUS "Building PIP without ICU") + message(STATUS "Building PIP without ICU") endif() @@ -310,468 +305,476 @@ endif() set(_PIP_DEFS "") set(_PIP_DEFS_FILE "${CMAKE_CURRENT_BINARY_DIR}/pip_defs.h") if(INTROSPECTION) - message(STATUS "Building PIP with introspection") - message(STATUS "Warning: Introspection reduces the performance!") - add_definitions(-DPIP_INTROSPECTION) - set(_PIP_DEFS "PIP_INTROSPECTION") + message(STATUS "Building PIP with introspection") + message(STATUS "Warning: Introspection reduces the performance!") + add_definitions(-DPIP_INTROSPECTION) + set(_PIP_DEFS "PIP_INTROSPECTION") else() - message(STATUS "Building PIP without introspection") + message(STATUS "Building PIP without introspection") endif() if ((NOT DEFINED _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PIP_DEFS}")) - set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE) - file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n") - if (NOT "x${_PIP_DEFS}" STREQUAL "x") - file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n") - endif() -endif() -list(APPEND HDRS ${_PIP_DEFS_FILE}) -#message("${_PIP_DEFS_CHANGED}") - - -# Check if RT timers exists -if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2) - add_definitions(-DPIP_TIMER_RT) - message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool") -else() - message(STATUS "Building PIP with timers: Thread, Pool") -endif() - - - -# Add main library -if(APPLE) - add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) -endif() -if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) - include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include) - #message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include") - #message("${ANDROID_NDK}/sysroot/usr/include") -endif() -if(NOT PIP_FREERTOS) -if(WIN32) - if(${C_COMPILER} STREQUAL "cl.exe") - else() - list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi) - endif() -else() - list(APPEND LIBS_MAIN dl) - if(DEFINED ENV{QNX_HOST}) - list(APPEND LIBS_MAIN socket) - else() - if (NOT DEFINED ANDROID_PLATFORM) - list(APPEND LIBS_MAIN pthread util) - endif() - endif() -endif() -endif() -set(PIP_LIBS) -if(PIP_FREERTOS) - set(PIP_LIBS ${LIBS_MAIN}) -else() - foreach(LIB_ ${LIBS_MAIN}) - find_library(${LIB_}_FOUND ${LIB_}) - if(${LIB_}_FOUND) - list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND}) - list(APPEND PIP_LIBS ${${LIB_}_FOUND}) - endif() - endforeach() -endif() -list(APPEND LIBS_STATUS ${LIBS_MAIN}) -import_version(pip PIP) -if(WIN32) - make_rc(pip _RC) - add_definitions(-DPSAPI_VERSION=1) - add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC}) - if(${C_COMPILER} STREQUAL "cl.exe") - set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0") - endif() -else() - set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC") - if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32") - else() - endif() - add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN}) -endif() -set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") -include(GenerateExportHeader) -generate_export_header(pip) -list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") -target_link_libraries(pip ${PIP_LIBS}) - -if (NOT CROSSTOOLS) - if (NOT PIP_FREERTOS) - # Check if USB is supported - find_library(usb_FOUND usb SHARED) - if(usb_FOUND) - message(STATUS "Building PIP with USB support") - import_version(pip_usb pip) - set_deploy_property(pip_usb ${PIP_LIB_TYPE} - LABEL "PIP usb support" - FULLNAME "${_PIP_DOMAIN}.pip_usb" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_usb _RC) - add_definitions(-DPIP_USB) - add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC}) - target_link_libraries(pip_usb pip ${usb_FOUND}) - list(APPEND LIBS_STATUS usb) - list(APPEND PIP_LIBS_TARGETS pip_usb) - else() - message(STATUS "Building PIP without USB support") - endif() - - - # Add console library - import_version(pip_console pip) - set_deploy_property(pip_console ${PIP_LIB_TYPE} - LABEL "PIP console support" - FULLNAME "${_PIP_DOMAIN}.pip_console" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_console _RC) - add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC}) - target_link_libraries(pip_console pip) - list(APPEND PIP_LIBS_TARGETS pip_console) - - - # Check if PIP support cryptographic encryption/decryption using sodium library - find_library(sodium_FOUND sodium) - if(sodium_FOUND) - message(STATUS "Building PIP with crypt support") - import_version(pip_crypt pip) - set_deploy_property(pip_crypt ${PIP_LIB_TYPE} - LABEL "PIP crypt support" - FULLNAME "${_PIP_DOMAIN}.pip_crypt" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_crypt _RC) - add_definitions(-DPIP_CRYPT) - add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC}) - target_link_libraries(pip_crypt pip ${sodium_FOUND}) - list(APPEND LIBS_STATUS sodium) - list(APPEND PIP_LIBS_TARGETS pip_crypt) - else() - message(STATUS "Building PIP without crypt support") - endif() - - - # Check if PIP support compress/decompress using zlib library - find_library(zlib_FOUND NAMES z zlib) - if(zlib_FOUND) - message(STATUS "Building PIP with zlib compress support") - import_version(pip_compress pip) - set_deploy_property(pip_compress ${PIP_LIB_TYPE} - LABEL "PIP compression support" - FULLNAME "${_PIP_DOMAIN}.pip_compress" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_compress _RC) - add_definitions(-DPIP_COMPRESS) - add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC}) - target_link_libraries(pip_compress pip ${zlib_FOUND}) - list(APPEND LIBS_STATUS zlib) - list(APPEND PIP_LIBS_TARGETS pip_compress) - else() - message(STATUS "Building PIP without compress support") - endif() - - - # Check if PIP support fftw3 for PIFFT using in math module - set(FFTW_LIB_NAME fftw3) - set(FFTW_LIB_SUFFIXES "" "f" "l" "q") - set(FFTW_LIB_SUFFIXES2 "" "-3") - set(FFTW_LIBS) - set(FFTW_ABS_LIBS) - set(PIP_FFTW_FOUND) - set(CMAKE_REQUIRED_INCLUDES fftw3.h) - foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES) - set(FFTW_BREAK false) - foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2) - if(NOT FFTW_BREAK) - set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}") - set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}") - find_library(${FFTW_CLN}_FOUND ${FFTW_CLN}) - find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT}) - if(${FFTW_CLN}_FOUND) - list(APPEND FFTW_LIBS "${FFTW_CLN}") - list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}") - #message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}") - set(${FFTW_CLN}_CTS "${FFTW_CLN}") - if(${FFTW_CLNT}_FOUND) - list(APPEND FFTW_LIBS "${FFTW_CLNT}") - list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}") - list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}") - endif() - set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS}) - CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE) - add_definitions(-DPIP_FFTW${FFTW_S_}) - set(PIP_FFTW_FOUND true) - if(${FFTW_CLN}_TSFE) - add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE) - else() - message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe") - endif() - #message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}") - endif() - endif() - endforeach() - endforeach() - if(FFTW_LIBS) - message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}") - import_version(pip_fftw pip) - set_deploy_property(pip_fftw ${PIP_LIB_TYPE} - LABEL "PIP FFTW support" - FULLNAME "${_PIP_DOMAIN}.pip_fftw" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_fftw _RC) - add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC}) - target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS}) - list(APPEND LIBS_STATUS ${FFTW_LIBS}) - list(APPEND PIP_LIBS_TARGETS pip_fftw) - else() - message(STATUS "Building PIP without fftw3 support") - endif() - - - # Check if PIP support OpenCL - find_package(OpenCL QUIET) - if(OpenCL_FOUND) - message(STATUS "Building PIP with OpenCL support") - import_version(pip_opencl pip) - set_deploy_property(pip_opencl ${PIP_LIB_TYPE} - LABEL "PIP OpenCL support" - FULLNAME "${_PIP_DOMAIN}.pip_opencl" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_opencl _RC) - if(APPLE) - include_directories(${OpenCL_INCLUDE_DIRS}/Headers) - else() - include_directories(${OpenCL_INCLUDE_DIRS}) - endif() - add_definitions(-DPIP_OPENCL) - pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf") - add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC}) - add_dependencies(pip_opencl pip_rc) - if(${CMAKE_VERSION} VERSION_LESS "3.7.0") - target_link_libraries(pip_opencl pip OpenCL) - else() - target_link_libraries(pip_opencl pip OpenCL::OpenCL) - endif() - list(APPEND LIBS_STATUS OpenCL) - list(APPEND PIP_LIBS_TARGETS pip_opencl) - set(OpenCL_FOUND ${OpenCL_LIBRARIES}) - else() - message(STATUS "Building PIP without OpenCL support") - endif() - - - # Check if PIP IO Utils library supports crypt - set(IO_UTILS_LIBS pip) - import_version(pip_io_utils pip) - set_deploy_property(pip_io_utils ${PIP_LIB_TYPE} - LABEL "PIP I/O utilites" - FULLNAME "${_PIP_DOMAIN}.pip_io_utils" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_io_utils _RC) - add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC}) - if(sodium_FOUND) - message(STATUS "Building PIP IO Utils library with crypt support") - list(APPEND IO_UTILS_LIBS pip_crypt) - else() - message(STATUS "Building PIP IO Utils library without crypt support, attention!") - endif() - target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) - list(APPEND PIP_LIBS_TARGETS pip_io_utils) - - - # Concurrent module - set(CONCURRENT_LIBS pip) - import_version(pip_concurrent pip) - set_deploy_property(pip_concurrent ${PIP_LIB_TYPE} - LABEL "PIP concurrent support" - FULLNAME "${_PIP_DOMAIN}.pip_concurrent" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_concurrent _RC) - add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC}) - target_link_libraries(pip_concurrent ${CONCURRENT_LIBS}) - set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11) - list(APPEND PIP_LIBS_TARGETS pip_concurrent) - - # Enable build tests for concurrent module - if(CONCURRENT_TESTS) - add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST}) - target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) - add_test(NAME pip_concurrent_test COMMAND tests) - add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) + set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE) + file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n") + if (NOT "x${_PIP_DEFS}" STREQUAL "x") + file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n") endif() - if(MATH_TESTS) - add_executable(pip_math_test ${CPP_MATH_TEST}) - target_link_libraries(pip_math_test gtest_main gmock_main PIP) - add_test(NAME pip_math_test COMMAND tests) - #add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) + endif() + list(APPEND HDRS ${_PIP_DEFS_FILE}) + #message("${_PIP_DEFS_CHANGED}") + + + # Check if RT timers exists + if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2) + add_definitions(-DPIP_TIMER_RT) + message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool") + else() + message(STATUS "Building PIP with timers: Thread, Pool") + endif() + + + + # Add main library + if(APPLE) + add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) + endif() + if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) + include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include) + #message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include") + #message("${ANDROID_NDK}/sysroot/usr/include") + endif() + if(NOT PIP_FREERTOS) + if(WIN32) + if(${C_COMPILER} STREQUAL "cl.exe") + else() + list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi) + endif() + else() + list(APPEND LIBS_MAIN dl) + if(DEFINED ENV{QNX_HOST}) + list(APPEND LIBS_MAIN socket) + else() + if (NOT DEFINED ANDROID_PLATFORM) + list(APPEND LIBS_MAIN pthread util) + endif() + endif() + endif() + endif() + set(PIP_LIBS) + if(PIP_FREERTOS) + set(PIP_LIBS ${LIBS_MAIN}) + else() + foreach(LIB_ ${LIBS_MAIN}) + find_library(${LIB_}_FOUND ${LIB_}) + if(${LIB_}_FOUND) + list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND}) + list(APPEND PIP_LIBS ${${LIB_}_FOUND}) + endif() + endforeach() + endif() + list(APPEND LIBS_STATUS ${LIBS_MAIN}) + import_version(pip PIP) + if(WIN32) + make_rc(pip _RC) + add_definitions(-DPSAPI_VERSION=1) + add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC}) + if(${C_COMPILER} STREQUAL "cl.exe") + set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0") + endif() + else() + set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC") + if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32") + else() + endif() + add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN}) + endif() + set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") + include(GenerateExportHeader) + generate_export_header(pip) + list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") + target_link_libraries(pip ${PIP_LIBS}) + + if (NOT CROSSTOOLS) + if (NOT PIP_FREERTOS) + # Check if USB is supported + find_library(usb_FOUND usb SHARED) + if(usb_FOUND) + message(STATUS "Building PIP with USB support") + import_version(pip_usb pip) + set_deploy_property(pip_usb ${PIP_LIB_TYPE} + LABEL "PIP usb support" + FULLNAME "${_PIP_DOMAIN}.pip_usb" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_usb _RC) + add_definitions(-DPIP_USB) + add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC}) + target_link_libraries(pip_usb pip ${usb_FOUND}) + list(APPEND LIBS_STATUS usb) + list(APPEND PIP_LIBS_TARGETS pip_usb) + else() + message(STATUS "Building PIP without USB support") + endif() + + + # Add console library + import_version(pip_console pip) + set_deploy_property(pip_console ${PIP_LIB_TYPE} + LABEL "PIP console support" + FULLNAME "${_PIP_DOMAIN}.pip_console" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_console _RC) + add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC}) + target_link_libraries(pip_console pip) + list(APPEND PIP_LIBS_TARGETS pip_console) + + + # Check if PIP support cryptographic encryption/decryption using sodium library + find_library(sodium_FOUND sodium) + if(sodium_FOUND) + message(STATUS "Building PIP with crypt support") + import_version(pip_crypt pip) + set_deploy_property(pip_crypt ${PIP_LIB_TYPE} + LABEL "PIP crypt support" + FULLNAME "${_PIP_DOMAIN}.pip_crypt" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_crypt _RC) + add_definitions(-DPIP_CRYPT) + add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC}) + target_link_libraries(pip_crypt pip ${sodium_FOUND}) + list(APPEND LIBS_STATUS sodium) + list(APPEND PIP_LIBS_TARGETS pip_crypt) + else() + message(STATUS "Building PIP without crypt support") + endif() + + + # Check if PIP support compress/decompress using zlib library + find_library(zlib_FOUND NAMES z zlib) + if(zlib_FOUND) + message(STATUS "Building PIP with zlib compress support") + import_version(pip_compress pip) + set_deploy_property(pip_compress ${PIP_LIB_TYPE} + LABEL "PIP compression support" + FULLNAME "${_PIP_DOMAIN}.pip_compress" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_compress _RC) + add_definitions(-DPIP_COMPRESS) + add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC}) + target_link_libraries(pip_compress pip ${zlib_FOUND}) + list(APPEND LIBS_STATUS zlib) + list(APPEND PIP_LIBS_TARGETS pip_compress) + else() + message(STATUS "Building PIP without compress support") + endif() + + + # Check if PIP support fftw3 for PIFFT using in math module + set(FFTW_LIB_NAME fftw3) + set(FFTW_LIB_SUFFIXES "" "f" "l" "q") + set(FFTW_LIB_SUFFIXES2 "" "-3") + set(FFTW_LIBS) + set(FFTW_ABS_LIBS) + set(PIP_FFTW_FOUND) + set(CMAKE_REQUIRED_INCLUDES fftw3.h) + foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES) + set(FFTW_BREAK false) + foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2) + if(NOT FFTW_BREAK) + set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}") + set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}") + find_library(${FFTW_CLN}_FOUND ${FFTW_CLN}) + find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT}) + if(${FFTW_CLN}_FOUND) + list(APPEND FFTW_LIBS "${FFTW_CLN}") + list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}") + #message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}") + set(${FFTW_CLN}_CTS "${FFTW_CLN}") + if(${FFTW_CLNT}_FOUND) + list(APPEND FFTW_LIBS "${FFTW_CLNT}") + list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}") + list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}") + endif() + set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS}) + CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE) + add_definitions(-DPIP_FFTW${FFTW_S_}) + set(PIP_FFTW_FOUND true) + if(${FFTW_CLN}_TSFE) + add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE) + else() + message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe") + endif() + #message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}") + endif() + endif() + endforeach() + endforeach() + if(FFTW_LIBS) + message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}") + import_version(pip_fftw pip) + set_deploy_property(pip_fftw ${PIP_LIB_TYPE} + LABEL "PIP FFTW support" + FULLNAME "${_PIP_DOMAIN}.pip_fftw" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_fftw _RC) + add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC}) + target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS}) + list(APPEND LIBS_STATUS ${FFTW_LIBS}) + list(APPEND PIP_LIBS_TARGETS pip_fftw) + else() + message(STATUS "Building PIP without fftw3 support") + endif() + + + # Check if PIP support OpenCL + find_package(OpenCL QUIET) + if(OpenCL_FOUND) + message(STATUS "Building PIP with OpenCL support") + import_version(pip_opencl pip) + set_deploy_property(pip_opencl ${PIP_LIB_TYPE} + LABEL "PIP OpenCL support" + FULLNAME "${_PIP_DOMAIN}.pip_opencl" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_opencl _RC) + if(APPLE) + include_directories(${OpenCL_INCLUDE_DIRS}/Headers) + else() + include_directories(${OpenCL_INCLUDE_DIRS}) + endif() + add_definitions(-DPIP_OPENCL) + pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf") + add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC}) + add_dependencies(pip_opencl pip_rc) + if(${CMAKE_VERSION} VERSION_LESS "3.7.0") + target_link_libraries(pip_opencl pip OpenCL) + else() + target_link_libraries(pip_opencl pip OpenCL::OpenCL) + endif() + list(APPEND LIBS_STATUS OpenCL) + list(APPEND PIP_LIBS_TARGETS pip_opencl) + set(OpenCL_FOUND ${OpenCL_LIBRARIES}) + else() + message(STATUS "Building PIP without OpenCL support") + endif() + + + # Check if PIP IO Utils library supports crypt + set(IO_UTILS_LIBS pip) + import_version(pip_io_utils pip) + set_deploy_property(pip_io_utils ${PIP_LIB_TYPE} + LABEL "PIP I/O utilites" + FULLNAME "${_PIP_DOMAIN}.pip_io_utils" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_io_utils _RC) + add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC}) + if(sodium_FOUND) + message(STATUS "Building PIP IO Utils library with crypt support") + list(APPEND IO_UTILS_LIBS pip_crypt) + else() + message(STATUS "Building PIP IO Utils library without crypt support, attention!") + endif() + target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) + list(APPEND PIP_LIBS_TARGETS pip_io_utils) + + + # Concurrent module + set(CONCURRENT_LIBS pip) + import_version(pip_concurrent pip) + set_deploy_property(pip_concurrent ${PIP_LIB_TYPE} + LABEL "PIP concurrent support" + FULLNAME "${_PIP_DOMAIN}.pip_concurrent" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_concurrent _RC) + add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC}) + target_link_libraries(pip_concurrent ${CONCURRENT_LIBS}) + set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11) + list(APPEND PIP_LIBS_TARGETS pip_concurrent) + + # Enable build tests for concurrent module + if(PIP_CONCURRENT_TEST) + add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST}) + target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) + add_test(NAME pip_concurrent_test COMMAND tests) + add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) + endif() + + if(PIP_SRC_MATH_TEST) + add_executable(pip_math_test ${CPP_MATH_TEST}) + target_link_libraries(pip_math_test gtest_main gmock_main PIP) + add_test(NAME pip_math_test COMMAND tests) + #add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) + endif() + + if(PIP_SRC_CORE_TEST) + add_executable(pip_core_test ${CPP_CORE_TEST}) + target_link_libraries(pip_core_test gtest_main gmock_main PIP) + add_test(NAME pip_core_test COMMAND tests) + #add_custom_target(pip_core_test_perform ALL COMMAND pip_core_test) + endif() + + # Build cloud library if crypt enabled + if(sodium_FOUND) + message(STATUS "Building PICloud support") + import_version(pip_cloud pip) + set_deploy_property(pip_cloud ${PIP_LIB_TYPE} + LABEL "PIP cloud transport support" + FULLNAME "${_PIP_DOMAIN}.pip_cloud" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_cloud _RC) + add_definitions(-DPIP_CLOUD) + add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC}) + target_link_libraries(pip_cloud pip pip_crypt) + list(APPEND PIP_LIBS_TARGETS pip_cloud) + endif() + + + # Test program + if(PIP_UTILS) + add_executable(pip_test "main.cpp") + target_link_libraries(pip_test pip) + endif() + + else() + + message(STATUS "Building PIP with crypt support") + add_definitions(-DPIP_CRYPT) + add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT}) + target_link_libraries(pip_crypt pip) + list(APPEND PIP_LIBS_TARGETS pip_crypt) + set(IO_UTILS_LIBS pip) + add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS}) + message(STATUS "Building PIP IO Utils library with crypt support") + list(APPEND IO_UTILS_LIBS pip_crypt) + target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) + list(APPEND PIP_LIBS_TARGETS pip_io_utils) + message(STATUS "Building PIP with zlib compress support") + add_definitions(-DPIP_COMPRESS) + add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS}) + target_link_libraries(pip_compress pip) + list(APPEND PIP_LIBS_TARGETS pip_compress) + + endif() + endif() + + # Install + # Check if system or local install will be used (to system install use "-DLIB=" argument of cmake) + if(LIB) + if(WIN32) + if(MINGW) + if (NOT CROSSTOOLS) + install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip) + install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB}) + endif() + install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN}) + find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH) + find_library(STDLIB "stdc++-6") + #message("${STDLIB}") + if (STDLIB) + file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator") + file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler") + file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool") + endif() + else() + #message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include) + endif() + else() + if (NOT CROSSTOOLS) + install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip) + endif() + install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + endif() + message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") + file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore") + install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) + else() + if(NOT PIP_FREERTOS) + if(WIN32) + install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin) + install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib) + else() + install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib) + endif() + install(FILES ${HDRS} DESTINATION include/pip) + message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") + endif() + endif() + + if(NOT PIP_FREERTOS) + + # Auxiliary + if (NOT CROSSTOOLS) + add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal") endif() - # Build cloud library if crypt enabled - if(sodium_FOUND) - message(STATUS "Building PICloud support") - import_version(pip_cloud pip) - set_deploy_property(pip_cloud ${PIP_LIB_TYPE} - LABEL "PIP cloud transport support" - FULLNAME "${_PIP_DOMAIN}.pip_cloud" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_cloud _RC) - add_definitions(-DPIP_CLOUD) - add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC}) - target_link_libraries(pip_cloud pip pip_crypt) - list(APPEND PIP_LIBS_TARGETS pip_cloud) - endif() + # Utils + add_subdirectory("utils/code_model_generator") + add_subdirectory("utils/resources_compiler") + add_subdirectory("utils/deploy_tool") + if(PIP_UTILS AND (NOT CROSSTOOLS)) + add_subdirectory("utils/system_test") + add_subdirectory("utils/remote_console") + add_subdirectory("utils/udp_file_transfer") + if(sodium_FOUND) + add_subdirectory("utils/system_daemon") + add_subdirectory("utils/crypt_tool") + add_subdirectory("utils/cloud_dispatcher") + endif() + endif() + + endif() - # Test program - if(PIP_UTILS) - add_executable(pip_test "main.cpp") - target_link_libraries(pip_test pip) - endif() + # Libraries messages + message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}") + if(DEFINED LIBPROJECT) + set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE) + list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS}) + set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) + endif() + if(NOT PIP_FREERTOS) + foreach(LIB_ ${LIBS_STATUS}) + message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND}) + if(NOT ${LIB_}_FOUND) + message(WARNING "Library ${LIB_} not found, please install it") + endif() + endforeach() + endif() - else() - - message(STATUS "Building PIP with crypt support") - add_definitions(-DPIP_CRYPT) - add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT}) - target_link_libraries(pip_crypt pip) - list(APPEND PIP_LIBS_TARGETS pip_crypt) - set(IO_UTILS_LIBS pip) - add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS}) - message(STATUS "Building PIP IO Utils library with crypt support") - list(APPEND IO_UTILS_LIBS pip_crypt) - target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) - list(APPEND PIP_LIBS_TARGETS pip_io_utils) - message(STATUS "Building PIP with zlib compress support") - add_definitions(-DPIP_COMPRESS) - add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS}) - target_link_libraries(pip_compress pip) - list(APPEND PIP_LIBS_TARGETS pip_compress) - - endif() -endif() - -# Install -# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake) -if(LIB) - if(WIN32) - if(MINGW) - if (NOT CROSSTOOLS) - install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip) - install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB}) - endif() - install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN}) - find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH) - find_library(STDLIB "stdc++-6") - #message("${STDLIB}") - if (STDLIB) - file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator") - file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler") - file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool") - endif() - else() - #message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include) - endif() - else() - if (NOT CROSSTOOLS) - install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip) - endif() - install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) - endif() - message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") - file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore") - install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) -else() - if(NOT PIP_FREERTOS) - if(WIN32) - install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin) - install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib) - else() - install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib) - endif() - install(FILES ${HDRS} DESTINATION include/pip) - message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") - endif() -endif() - -if(NOT PIP_FREERTOS) - -# Auxiliary - if (NOT CROSSTOOLS) - add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal") - endif() - -# Utils - add_subdirectory("utils/code_model_generator") - add_subdirectory("utils/resources_compiler") - add_subdirectory("utils/deploy_tool") - if(PIP_UTILS AND (NOT CROSSTOOLS)) - add_subdirectory("utils/system_test") - add_subdirectory("utils/remote_console") - add_subdirectory("utils/udp_file_transfer") - if(sodium_FOUND) - add_subdirectory("utils/system_daemon") - add_subdirectory("utils/crypt_tool") - add_subdirectory("utils/cloud_dispatcher") - endif() - endif() - -endif() - - -# Libraries messages -message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}") -if(DEFINED LIBPROJECT) - set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE) - list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS}) - set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) -endif() -if(NOT PIP_FREERTOS) - foreach(LIB_ ${LIBS_STATUS}) - message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND}) - if(NOT ${LIB_}_FOUND) - message(WARNING "Library ${LIB_} not found, please install it") - endif() - endforeach() -endif() - -# -# Build Documentation -# -if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS)) - include(PIPDocumentation) - find_package(Doxygen) - if(DOXYGEN_FOUND) - set(DOXY_PROJECT_NUMBER "${PIP_VERSION}") - set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") - set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") - set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"") - set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"") - if(DOXYGEN_DOT_EXECUTABLE) - string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}") - set(DOXY_DOT_PATH "\"${_DOT_PATH}\"") - set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"") - set(DOXY_DIA_PATH "\"${_DOT_PATH}\"") - endif() - set(DOXY_INPUT) - foreach(F ${PIP_SRC_DIRS}) - list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"") - endforeach(F) - string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}") - string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}") - add_documentation(doc doc/Doxyfile.in) - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL) - endif() -endif() + # + # Build Documentation + # + if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS)) + include(PIPDocumentation) + find_package(Doxygen) + if(DOXYGEN_FOUND) + set(DOXY_PROJECT_NUMBER "${PIP_VERSION}") + set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") + set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") + set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"") + set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"") + if(DOXYGEN_DOT_EXECUTABLE) + string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}") + set(DOXY_DOT_PATH "\"${_DOT_PATH}\"") + set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"") + set(DOXY_DIA_PATH "\"${_DOT_PATH}\"") + endif() + set(DOXY_INPUT) + foreach(F ${PIP_SRC_DIRS}) + list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"") + endforeach(F) + string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}") + string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}") + add_documentation(doc doc/Doxyfile.in) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL) + endif() + endif() From 13bafdc7c19e05257ea7ae1d7e111209b612621b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Fri, 24 Jul 2020 15:26:37 +0300 Subject: [PATCH 5/9] core test --- CMakeLists.txt.user | 1098 +++++++++++++++++++++++++++ lib/main/core/test/pistringTest.cpp | 10 + 2 files changed, 1108 insertions(+) create mode 100644 CMakeLists.txt.user create mode 100644 lib/main/core/test/pistringTest.cpp diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user new file mode 100644 index 00000000..c8d7ecc3 --- /dev/null +++ b/CMakeLists.txt.user @@ -0,0 +1,1098 @@ + + + + + + EnvironmentId + {590da41d-e68d-4f0d-9a90-bf433d6b70a5} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.12.7 MinGW 64-bit + Desktop Qt 5.12.7 MinGW 64-bit + qt.qt5.5127.win64_mingw73_kit + 1 + 0 + 3 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Debug + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Сборка + Сборка + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Очистка + Очистка + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Отладка + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Сборка + Сборка + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Очистка + Очистка + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Выпуск + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=RelWithDebInfo + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-RelWithDebInfo + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Сборка + Сборка + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Очистка + Очистка + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Выпуск с отладочной информацией + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=MinSizeRel + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-MinSizeRel + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Сборка + Сборка + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Очистка + Очистка + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Выпуск минимального размера + CMakeProjectManager.CMakeBuildConfiguration + + 4 + + + 0 + Развёртывание + Развёртывание + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + deploy_tool + CMakeProjectManager.CMakeRunConfiguration.deploy_tool + deploy_tool + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/deploy_tool + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pift + CMakeProjectManager.CMakeRunConfiguration.pift + pift + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/udp_file_transfer + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + piterminal + CMakeProjectManager.CMakeRunConfiguration.piterminal + piterminal + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/lib/main/auxiliary/piterminal + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_cmg + CMakeProjectManager.CMakeRunConfiguration.pip_cmg + pip_cmg + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/code_model_generator + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_concurrent_test + CMakeProjectManager.CMakeRunConfiguration.pip_concurrent_test + pip_concurrent_test + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_core_test + CMakeProjectManager.CMakeRunConfiguration.pip_core_test + pip_core_test + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_math_test + CMakeProjectManager.CMakeRunConfiguration.pip_math_test + pip_math_test + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_rc + CMakeProjectManager.CMakeRunConfiguration.pip_rc + pip_rc + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/resources_compiler + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_remote_console + CMakeProjectManager.CMakeRunConfiguration.pip_remote_console + pip_remote_console + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/remote_console + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_system_test + CMakeProjectManager.CMakeRunConfiguration.pip_system_test + pip_system_test + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/system_test + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + pip_test + CMakeProjectManager.CMakeRunConfiguration.pip_test + pip_test + + false + + false + true + true + false + false + true + + D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release + + 11 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/lib/main/core/test/pistringTest.cpp b/lib/main/core/test/pistringTest.cpp new file mode 100644 index 00000000..45b6272e --- /dev/null +++ b/lib/main/core/test/pistringTest.cpp @@ -0,0 +1,10 @@ +#include "gtest/gtest.h" +#include "pistring.h" + +using namespace std; + +PIString str; + +TEST(PIString_Tests, operator){ + ASSERT_TRUE(true); +} From c3257c7c50fcb89b38bcd17854dd721d616979e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A8=D0=B8=D1=88?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Fri, 24 Jul 2020 15:28:11 +0300 Subject: [PATCH 6/9] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20'CMakeLists.txt.user'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt.user | 1098 ------------------------------------------- 1 file changed, 1098 deletions(-) delete mode 100644 CMakeLists.txt.user diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user deleted file mode 100644 index c8d7ecc3..00000000 --- a/CMakeLists.txt.user +++ /dev/null @@ -1,1098 +0,0 @@ - - - - - - EnvironmentId - {590da41d-e68d-4f0d-9a90-bf433d6b70a5} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - -fno-delayed-template-parsing - - true - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.12.7 MinGW 64-bit - Desktop Qt 5.12.7 MinGW 64-bit - qt.qt5.5127.win64_mingw73_kit - 1 - 0 - 3 - - - CMAKE_BUILD_TYPE:STRING=Debug - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Debug - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Отладка - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Release - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Выпуск - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=RelWithDebInfo - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-RelWithDebInfo - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Выпуск с отладочной информацией - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=MinSizeRel - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-MinSizeRel - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Выпуск минимального размера - CMakeProjectManager.CMakeBuildConfiguration - - 4 - - - 0 - Развёртывание - Развёртывание - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - deploy_tool - CMakeProjectManager.CMakeRunConfiguration.deploy_tool - deploy_tool - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/deploy_tool - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pift - CMakeProjectManager.CMakeRunConfiguration.pift - pift - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/udp_file_transfer - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - piterminal - CMakeProjectManager.CMakeRunConfiguration.piterminal - piterminal - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/lib/main/auxiliary/piterminal - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_cmg - CMakeProjectManager.CMakeRunConfiguration.pip_cmg - pip_cmg - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/code_model_generator - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_concurrent_test - CMakeProjectManager.CMakeRunConfiguration.pip_concurrent_test - pip_concurrent_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_core_test - CMakeProjectManager.CMakeRunConfiguration.pip_core_test - pip_core_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_math_test - CMakeProjectManager.CMakeRunConfiguration.pip_math_test - pip_math_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_rc - CMakeProjectManager.CMakeRunConfiguration.pip_rc - pip_rc - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/resources_compiler - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_remote_console - CMakeProjectManager.CMakeRunConfiguration.pip_remote_console - pip_remote_console - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/remote_console - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_system_test - CMakeProjectManager.CMakeRunConfiguration.pip_system_test - pip_system_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/system_test - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_test - CMakeProjectManager.CMakeRunConfiguration.pip_test - pip_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - 11 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - From f1951ee711458bcb6713d995364dda9e261629e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Fri, 24 Jul 2020 15:56:51 +0300 Subject: [PATCH 7/9] CMAKE NEEEEEW --- CMakeLists.txt | 1086 +++++++++++++++++++++--------------------- CMakeLists.txt.user | 1098 ------------------------------------------- 2 files changed, 543 insertions(+), 1641 deletions(-) delete mode 100644 CMakeLists.txt.user diff --git a/CMakeLists.txt b/CMakeLists.txt index f89c293b..8203b65b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(_PIP_COMPANY SHS) set(_PIP_DOMAIN org.SHS) if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") - set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set(PIP_BUILD 1) @@ -17,15 +17,15 @@ include(CheckFunctionExists) include(DeployMacros) include(PIPMacros) if(NOT DEFINED BUILD_NUMBER) - set(BUILD_NUMBER 9999) + set(BUILD_NUMBER 9999) endif() if("x${BUILD_NUMBER}" STREQUAL "x") - set(BUILD_NUMBER 0) + set(BUILD_NUMBER 0) endif() set(_ICU_DEFAULT OFF) if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE)) - set(_ICU_DEFAULT ON) + set(_ICU_DEFAULT ON) endif() @@ -38,23 +38,23 @@ option(STATIC_LIB OFF) option(TESTS "Build tests and perform their before install step" ON) set(PIP_UTILS 1) if(LIBPROJECT) - set(PIP_UTILS ${UTILS}) + set(PIP_UTILS ${UTILS}) endif() set(CMAKE_CXX_STANDARD 11) # Basic macro(gather_src DIR CPP H H_P) - set(CS) - set(HS) - set(PHS) - file(GLOB CS "${DIR}/*.cpp") - file(GLOB HS "${DIR}/*.h") - file(GLOB PHS "${DIR}/*_p.h") - list(REMOVE_ITEM HS "${PHS}") - list(APPEND ${CPP} ${CS}) - list(APPEND ${H} ${HS}) - list(APPEND ${H_P} ${PHS}) + set(CS) + set(HS) + set(PHS) + file(GLOB CS "${DIR}/*.cpp") + file(GLOB HS "${DIR}/*.h") + file(GLOB PHS "${DIR}/*_p.h") + list(REMOVE_ITEM HS "${PHS}") + list(APPEND ${CPP} ${CS}) + list(APPEND ${H} ${HS}) + list(APPEND ${H_P} ${PHS}) endmacro() set(PIP_SRC_MAIN "lib/main") @@ -68,16 +68,16 @@ set(PIP_SRC_IO_UTILS "lib/io_utils") set(PIP_SRC_CONCURRENT "lib/concurrent") set(PIP_SRC_CLOUD "lib/cloud") set(PIP_SRC_DIRS ${PIP_SRC_MAIN} - ${PIP_SRC_CONSOLE} - ${PIP_SRC_CRYPT} - ${PIP_SRC_COMPRESS} - ${PIP_SRC_USB} - ${PIP_SRC_FFTW} - ${PIP_SRC_OPENCL} - ${PIP_SRC_IO_UTILS} - ${PIP_SRC_CONCURRENT} - ${PIP_SRC_CLOUD} - ) + ${PIP_SRC_CONSOLE} + ${PIP_SRC_CRYPT} + ${PIP_SRC_COMPRESS} + ${PIP_SRC_USB} + ${PIP_SRC_FFTW} + ${PIP_SRC_OPENCL} + ${PIP_SRC_IO_UTILS} + ${PIP_SRC_CONCURRENT} + ${PIP_SRC_CLOUD} +) set(PIP_LIBS_TARGETS pip) set(LIBS_MAIN) set(LIBS_STATUS) @@ -85,91 +85,91 @@ set(HDRS) set(PHDRS) if (TESTS) - include(DownloadGTest) - set(PIP_CONCURRENT_TEST "lib/concurrent/test") - set(PIP_SRC_MATH_TEST "lib/main/math/test") - set(PIP_SRC_CORE_TEST "lib/main/core/test") + include(DownloadGTest) + set(PIP_CONCURRENT_TEST "lib/concurrent/test") + set(PIP_SRC_MATH_TEST "lib/main/math/test") + set(PIP_SRC_CORE_TEST "lib/main/core/test") endif() if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) - set(STATIC_LIB ON) + set(STATIC_LIB ON) endif() if(STATIC_LIB) - set(PIP_LIB_TYPE STATIC) - add_definitions(-DPIP_STATIC_DEFINE) - #message(STATUS "Building PIP static library") + set(PIP_LIB_TYPE STATIC) + add_definitions(-DPIP_STATIC_DEFINE) + #message(STATUS "Building PIP static library") else() - set(PIP_LIB_TYPE SHARED) - #message(STATUS "Building PIP shared library") + set(PIP_LIB_TYPE SHARED) + #message(STATUS "Building PIP shared library") endif() # Version set_version(PIP - MAJOR "${_PIP_MAJOR}" - MINOR "${_PIP_MINOR}" - REVISION "${_PIP_REVISION}" - BUILD "${BUILD_NUMBER}" - SUFFIX "${_PIP_SUFFIX}" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") + MAJOR "${_PIP_MAJOR}" + MINOR "${_PIP_MINOR}" + REVISION "${_PIP_REVISION}" + BUILD "${BUILD_NUMBER}" + SUFFIX "${_PIP_SUFFIX}" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") set_deploy_property(pip ${PIP_LIB_TYPE} - LABEL "PIP main library" - FULLNAME "${_PIP_DOMAIN}.pip" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") + LABEL "PIP main library" + FULLNAME "${_PIP_DOMAIN}.pip" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") - file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") + file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") endif() list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") message(STATUS "Building PIP version ${PIP_VERSION} (${PIP_LIB_TYPE})") if(MINGW) - find_package(MinGW REQUIRED) - list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB}) + find_package(MinGW REQUIRED) + list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB}) else() - if(APPLE) - if(CMAKE_CROSSCOMPILING) - set(CMAKE_INSTALL_NAME_DIR "@rpath") - else() - include_directories(/usr/local/include) - link_directories(/usr/local/lib) - endif() - set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib") - set(CMAKE_MACOSX_RPATH 1) - else() - set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") - endif() + if(APPLE) + if(CMAKE_CROSSCOMPILING) + set(CMAKE_INSTALL_NAME_DIR "@rpath") + else() + include_directories(/usr/local/include) + link_directories(/usr/local/lib) + endif() + set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib") + set(CMAKE_MACOSX_RPATH 1) + else() + set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") + endif() endif() if(LIB) - if(WIN32) - if(MINGW) - set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) - endif() - else() - if (DEFINED ANDROID_PLATFORM) - set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) - else() - if(CMAKE_CROSSCOMPILING) - set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX}) - else() - set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local) - endif() - endif() - endif() + if(WIN32) + if(MINGW) + set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) + endif() + else() + if (DEFINED ANDROID_PLATFORM) + set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) + else() + if(CMAKE_CROSSCOMPILING) + set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX}) + else() + set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local) + endif() + endif() + endif() endif() if (NOT DEFINED PIP_CMG) - if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) - set(PIP_CMG "pip_cmg") - set(PIP_RC "pip_rc") - set(PIP_DEPLOY_TOOL "deploy_tool") - else() - set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator/pip_cmg") - set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler/pip_rc") - set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool/deploy_tool") - endif() + if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) + set(PIP_CMG "pip_cmg") + set(PIP_RC "pip_rc") + set(PIP_DEPLOY_TOOL "deploy_tool") + else() + set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator/pip_cmg") + set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler/pip_rc") + set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool/deploy_tool") + endif() endif() @@ -185,9 +185,9 @@ set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils include_directories("${PIP_SRC_MAIN}") set(PIP_MAIN_FOLDERS) foreach(F ${PIP_FOLDERS}) - list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"") - include_directories("${PIP_SRC_MAIN}/${F}") - gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) + list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"") + include_directories("${PIP_SRC_MAIN}/${F}") + gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) endforeach(F) # Crypt lib gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS) @@ -225,9 +225,9 @@ gather_src("${PIP_SRC_MATH_TEST}" CPP_MATH_TEST HDRS PHDRS) gather_src("${PIP_SRC_CORE_TEST}" CPP_CORE_TEST HDRS PHDRS) if(PIP_FREERTOS) - add_definitions(-DPIP_FREERTOS) - set(ICU OFF) - set(LIB OFF) + add_definitions(-DPIP_FREERTOS) + set(ICU OFF) + set(LIB OFF) endif() # Check Bessel functions @@ -240,22 +240,22 @@ CHECK_FUNCTION_EXISTS(y0 PIP_MATH_Y0) CHECK_FUNCTION_EXISTS(y1 PIP_MATH_Y1) CHECK_FUNCTION_EXISTS(yn PIP_MATH_YN) if(PIP_MATH_J0) - add_definitions(-DPIP_MATH_J0) + add_definitions(-DPIP_MATH_J0) endif() if(PIP_MATH_J1) - add_definitions(-DPIP_MATH_J1) + add_definitions(-DPIP_MATH_J1) endif() if(PIP_MATH_JN) - add_definitions(-DPIP_MATH_JN) + add_definitions(-DPIP_MATH_JN) endif() if(PIP_MATH_Y0) - add_definitions(-DPIP_MATH_Y0) + add_definitions(-DPIP_MATH_Y0) endif() if(PIP_MATH_Y1) - add_definitions(-DPIP_MATH_Y1) + add_definitions(-DPIP_MATH_Y1) endif() if(PIP_MATH_YN) - add_definitions(-DPIP_MATH_YN) + add_definitions(-DPIP_MATH_YN) endif() @@ -263,8 +263,8 @@ endif() set(CMAKE_REQUIRED_INCLUDES time.h) set(CMAKE_REQUIRED_LIBRARIES ) if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT PIP_FREERTOS)) - list(APPEND LIBS_MAIN rt) - set(CMAKE_REQUIRED_LIBRARIES rt) + list(APPEND LIBS_MAIN rt) + set(CMAKE_REQUIRED_LIBRARIES rt) endif() CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0) CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1) @@ -273,31 +273,31 @@ CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2) # Check if build debug version if (CMAKE_BUILD_TYPE MATCHES Debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") - add_definitions(-DPIP_DEBUG) - message(STATUS "Building PIP debug version") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") + add_definitions(-DPIP_DEBUG) + message(STATUS "Building PIP debug version") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") - message(STATUS "Building PIP release version") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") + message(STATUS "Building PIP release version") endif() # Check if std::iostream operators support if(STD_IOSTREAM) - add_definitions(-DPIP_STD_IOSTREAM) - message(STATUS "Building PIP with std iostream operators support") + add_definitions(-DPIP_STD_IOSTREAM) + message(STATUS "Building PIP with std iostream operators support") else() - message(STATUS "Building PIP without std iostream operators support") + message(STATUS "Building PIP without std iostream operators support") endif() # Check if ICU used for PIString and PIChar if(ICU) - message(STATUS "Building PIP with ICU") - add_definitions(-DPIP_ICU) - list(APPEND LIBS_MAIN icuuc) + message(STATUS "Building PIP with ICU") + add_definitions(-DPIP_ICU) + list(APPEND LIBS_MAIN icuuc) else() - message(STATUS "Building PIP without ICU") + message(STATUS "Building PIP without ICU") endif() @@ -305,476 +305,476 @@ endif() set(_PIP_DEFS "") set(_PIP_DEFS_FILE "${CMAKE_CURRENT_BINARY_DIR}/pip_defs.h") if(INTROSPECTION) - message(STATUS "Building PIP with introspection") - message(STATUS "Warning: Introspection reduces the performance!") - add_definitions(-DPIP_INTROSPECTION) - set(_PIP_DEFS "PIP_INTROSPECTION") + message(STATUS "Building PIP with introspection") + message(STATUS "Warning: Introspection reduces the performance!") + add_definitions(-DPIP_INTROSPECTION) + set(_PIP_DEFS "PIP_INTROSPECTION") else() - message(STATUS "Building PIP without introspection") + message(STATUS "Building PIP without introspection") endif() if ((NOT DEFINED _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PIP_DEFS}")) - set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE) - file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n") - if (NOT "x${_PIP_DEFS}" STREQUAL "x") - file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n") - endif() - endif() - list(APPEND HDRS ${_PIP_DEFS_FILE}) - #message("${_PIP_DEFS_CHANGED}") + set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE) + file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n") + if (NOT "x${_PIP_DEFS}" STREQUAL "x") + file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n") + endif() +endif() +list(APPEND HDRS ${_PIP_DEFS_FILE}) +#message("${_PIP_DEFS_CHANGED}") - # Check if RT timers exists - if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2) - add_definitions(-DPIP_TIMER_RT) - message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool") - else() - message(STATUS "Building PIP with timers: Thread, Pool") - endif() +# Check if RT timers exists +if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2) + add_definitions(-DPIP_TIMER_RT) + message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool") +else() + message(STATUS "Building PIP with timers: Thread, Pool") +endif() - # Add main library - if(APPLE) - add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) - endif() - if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) - include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include) - #message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include") - #message("${ANDROID_NDK}/sysroot/usr/include") - endif() - if(NOT PIP_FREERTOS) - if(WIN32) - if(${C_COMPILER} STREQUAL "cl.exe") - else() - list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi) - endif() - else() - list(APPEND LIBS_MAIN dl) - if(DEFINED ENV{QNX_HOST}) - list(APPEND LIBS_MAIN socket) - else() - if (NOT DEFINED ANDROID_PLATFORM) - list(APPEND LIBS_MAIN pthread util) - endif() - endif() - endif() - endif() - set(PIP_LIBS) - if(PIP_FREERTOS) - set(PIP_LIBS ${LIBS_MAIN}) - else() - foreach(LIB_ ${LIBS_MAIN}) - find_library(${LIB_}_FOUND ${LIB_}) - if(${LIB_}_FOUND) - list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND}) - list(APPEND PIP_LIBS ${${LIB_}_FOUND}) - endif() - endforeach() - endif() - list(APPEND LIBS_STATUS ${LIBS_MAIN}) - import_version(pip PIP) - if(WIN32) - make_rc(pip _RC) - add_definitions(-DPSAPI_VERSION=1) - add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC}) - if(${C_COMPILER} STREQUAL "cl.exe") - set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0") - endif() - else() - set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC") - if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32") - else() - endif() - add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN}) - endif() - set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") - include(GenerateExportHeader) - generate_export_header(pip) - list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") - target_link_libraries(pip ${PIP_LIBS}) +# Add main library +if(APPLE) + add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) +endif() +if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) + include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include) + #message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include") + #message("${ANDROID_NDK}/sysroot/usr/include") +endif() +if(NOT PIP_FREERTOS) +if(WIN32) + if(${C_COMPILER} STREQUAL "cl.exe") + else() + list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi) + endif() +else() + list(APPEND LIBS_MAIN dl) + if(DEFINED ENV{QNX_HOST}) + list(APPEND LIBS_MAIN socket) + else() + if (NOT DEFINED ANDROID_PLATFORM) + list(APPEND LIBS_MAIN pthread util) + endif() + endif() +endif() +endif() +set(PIP_LIBS) +if(PIP_FREERTOS) + set(PIP_LIBS ${LIBS_MAIN}) +else() + foreach(LIB_ ${LIBS_MAIN}) + find_library(${LIB_}_FOUND ${LIB_}) + if(${LIB_}_FOUND) + list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND}) + list(APPEND PIP_LIBS ${${LIB_}_FOUND}) + endif() + endforeach() +endif() +list(APPEND LIBS_STATUS ${LIBS_MAIN}) +import_version(pip PIP) +if(WIN32) + make_rc(pip _RC) + add_definitions(-DPSAPI_VERSION=1) + add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC}) + if(${C_COMPILER} STREQUAL "cl.exe") + set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0") + endif() +else() + set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC") + if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32") + else() + endif() + add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN}) +endif() +set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") +include(GenerateExportHeader) +generate_export_header(pip) +list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") +target_link_libraries(pip ${PIP_LIBS}) - if (NOT CROSSTOOLS) - if (NOT PIP_FREERTOS) - # Check if USB is supported - find_library(usb_FOUND usb SHARED) - if(usb_FOUND) - message(STATUS "Building PIP with USB support") - import_version(pip_usb pip) - set_deploy_property(pip_usb ${PIP_LIB_TYPE} - LABEL "PIP usb support" - FULLNAME "${_PIP_DOMAIN}.pip_usb" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_usb _RC) - add_definitions(-DPIP_USB) - add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC}) - target_link_libraries(pip_usb pip ${usb_FOUND}) - list(APPEND LIBS_STATUS usb) - list(APPEND PIP_LIBS_TARGETS pip_usb) - else() - message(STATUS "Building PIP without USB support") - endif() +if (NOT CROSSTOOLS) + if (NOT PIP_FREERTOS) + # Check if USB is supported + find_library(usb_FOUND usb SHARED) + if(usb_FOUND) + message(STATUS "Building PIP with USB support") + import_version(pip_usb pip) + set_deploy_property(pip_usb ${PIP_LIB_TYPE} + LABEL "PIP usb support" + FULLNAME "${_PIP_DOMAIN}.pip_usb" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_usb _RC) + add_definitions(-DPIP_USB) + add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC}) + target_link_libraries(pip_usb pip ${usb_FOUND}) + list(APPEND LIBS_STATUS usb) + list(APPEND PIP_LIBS_TARGETS pip_usb) + else() + message(STATUS "Building PIP without USB support") + endif() - # Add console library - import_version(pip_console pip) - set_deploy_property(pip_console ${PIP_LIB_TYPE} - LABEL "PIP console support" - FULLNAME "${_PIP_DOMAIN}.pip_console" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_console _RC) - add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC}) - target_link_libraries(pip_console pip) - list(APPEND PIP_LIBS_TARGETS pip_console) + # Add console library + import_version(pip_console pip) + set_deploy_property(pip_console ${PIP_LIB_TYPE} + LABEL "PIP console support" + FULLNAME "${_PIP_DOMAIN}.pip_console" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_console _RC) + add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC}) + target_link_libraries(pip_console pip) + list(APPEND PIP_LIBS_TARGETS pip_console) - # Check if PIP support cryptographic encryption/decryption using sodium library - find_library(sodium_FOUND sodium) - if(sodium_FOUND) - message(STATUS "Building PIP with crypt support") - import_version(pip_crypt pip) - set_deploy_property(pip_crypt ${PIP_LIB_TYPE} - LABEL "PIP crypt support" - FULLNAME "${_PIP_DOMAIN}.pip_crypt" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_crypt _RC) - add_definitions(-DPIP_CRYPT) - add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC}) - target_link_libraries(pip_crypt pip ${sodium_FOUND}) - list(APPEND LIBS_STATUS sodium) - list(APPEND PIP_LIBS_TARGETS pip_crypt) - else() - message(STATUS "Building PIP without crypt support") - endif() + # Check if PIP support cryptographic encryption/decryption using sodium library + find_library(sodium_FOUND sodium) + if(sodium_FOUND) + message(STATUS "Building PIP with crypt support") + import_version(pip_crypt pip) + set_deploy_property(pip_crypt ${PIP_LIB_TYPE} + LABEL "PIP crypt support" + FULLNAME "${_PIP_DOMAIN}.pip_crypt" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_crypt _RC) + add_definitions(-DPIP_CRYPT) + add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC}) + target_link_libraries(pip_crypt pip ${sodium_FOUND}) + list(APPEND LIBS_STATUS sodium) + list(APPEND PIP_LIBS_TARGETS pip_crypt) + else() + message(STATUS "Building PIP without crypt support") + endif() - # Check if PIP support compress/decompress using zlib library - find_library(zlib_FOUND NAMES z zlib) - if(zlib_FOUND) - message(STATUS "Building PIP with zlib compress support") - import_version(pip_compress pip) - set_deploy_property(pip_compress ${PIP_LIB_TYPE} - LABEL "PIP compression support" - FULLNAME "${_PIP_DOMAIN}.pip_compress" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_compress _RC) - add_definitions(-DPIP_COMPRESS) - add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC}) - target_link_libraries(pip_compress pip ${zlib_FOUND}) - list(APPEND LIBS_STATUS zlib) - list(APPEND PIP_LIBS_TARGETS pip_compress) - else() - message(STATUS "Building PIP without compress support") - endif() + # Check if PIP support compress/decompress using zlib library + find_library(zlib_FOUND NAMES z zlib) + if(zlib_FOUND) + message(STATUS "Building PIP with zlib compress support") + import_version(pip_compress pip) + set_deploy_property(pip_compress ${PIP_LIB_TYPE} + LABEL "PIP compression support" + FULLNAME "${_PIP_DOMAIN}.pip_compress" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_compress _RC) + add_definitions(-DPIP_COMPRESS) + add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC}) + target_link_libraries(pip_compress pip ${zlib_FOUND}) + list(APPEND LIBS_STATUS zlib) + list(APPEND PIP_LIBS_TARGETS pip_compress) + else() + message(STATUS "Building PIP without compress support") + endif() - # Check if PIP support fftw3 for PIFFT using in math module - set(FFTW_LIB_NAME fftw3) - set(FFTW_LIB_SUFFIXES "" "f" "l" "q") - set(FFTW_LIB_SUFFIXES2 "" "-3") - set(FFTW_LIBS) - set(FFTW_ABS_LIBS) - set(PIP_FFTW_FOUND) - set(CMAKE_REQUIRED_INCLUDES fftw3.h) - foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES) - set(FFTW_BREAK false) - foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2) - if(NOT FFTW_BREAK) - set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}") - set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}") - find_library(${FFTW_CLN}_FOUND ${FFTW_CLN}) - find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT}) - if(${FFTW_CLN}_FOUND) - list(APPEND FFTW_LIBS "${FFTW_CLN}") - list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}") - #message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}") - set(${FFTW_CLN}_CTS "${FFTW_CLN}") - if(${FFTW_CLNT}_FOUND) - list(APPEND FFTW_LIBS "${FFTW_CLNT}") - list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}") - list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}") - endif() - set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS}) - CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE) - add_definitions(-DPIP_FFTW${FFTW_S_}) - set(PIP_FFTW_FOUND true) - if(${FFTW_CLN}_TSFE) - add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE) - else() - message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe") - endif() - #message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}") - endif() - endif() - endforeach() - endforeach() - if(FFTW_LIBS) - message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}") - import_version(pip_fftw pip) - set_deploy_property(pip_fftw ${PIP_LIB_TYPE} - LABEL "PIP FFTW support" - FULLNAME "${_PIP_DOMAIN}.pip_fftw" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_fftw _RC) - add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC}) - target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS}) - list(APPEND LIBS_STATUS ${FFTW_LIBS}) - list(APPEND PIP_LIBS_TARGETS pip_fftw) - else() - message(STATUS "Building PIP without fftw3 support") - endif() + # Check if PIP support fftw3 for PIFFT using in math module + set(FFTW_LIB_NAME fftw3) + set(FFTW_LIB_SUFFIXES "" "f" "l" "q") + set(FFTW_LIB_SUFFIXES2 "" "-3") + set(FFTW_LIBS) + set(FFTW_ABS_LIBS) + set(PIP_FFTW_FOUND) + set(CMAKE_REQUIRED_INCLUDES fftw3.h) + foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES) + set(FFTW_BREAK false) + foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2) + if(NOT FFTW_BREAK) + set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}") + set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}") + find_library(${FFTW_CLN}_FOUND ${FFTW_CLN}) + find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT}) + if(${FFTW_CLN}_FOUND) + list(APPEND FFTW_LIBS "${FFTW_CLN}") + list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}") + #message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}") + set(${FFTW_CLN}_CTS "${FFTW_CLN}") + if(${FFTW_CLNT}_FOUND) + list(APPEND FFTW_LIBS "${FFTW_CLNT}") + list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}") + list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}") + endif() + set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS}) + CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE) + add_definitions(-DPIP_FFTW${FFTW_S_}) + set(PIP_FFTW_FOUND true) + if(${FFTW_CLN}_TSFE) + add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE) + else() + message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe") + endif() + #message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}") + endif() + endif() + endforeach() + endforeach() + if(FFTW_LIBS) + message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}") + import_version(pip_fftw pip) + set_deploy_property(pip_fftw ${PIP_LIB_TYPE} + LABEL "PIP FFTW support" + FULLNAME "${_PIP_DOMAIN}.pip_fftw" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_fftw _RC) + add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC}) + target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS}) + list(APPEND LIBS_STATUS ${FFTW_LIBS}) + list(APPEND PIP_LIBS_TARGETS pip_fftw) + else() + message(STATUS "Building PIP without fftw3 support") + endif() - # Check if PIP support OpenCL - find_package(OpenCL QUIET) - if(OpenCL_FOUND) - message(STATUS "Building PIP with OpenCL support") - import_version(pip_opencl pip) - set_deploy_property(pip_opencl ${PIP_LIB_TYPE} - LABEL "PIP OpenCL support" - FULLNAME "${_PIP_DOMAIN}.pip_opencl" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_opencl _RC) - if(APPLE) - include_directories(${OpenCL_INCLUDE_DIRS}/Headers) - else() - include_directories(${OpenCL_INCLUDE_DIRS}) - endif() - add_definitions(-DPIP_OPENCL) - pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf") - add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC}) - add_dependencies(pip_opencl pip_rc) - if(${CMAKE_VERSION} VERSION_LESS "3.7.0") - target_link_libraries(pip_opencl pip OpenCL) - else() - target_link_libraries(pip_opencl pip OpenCL::OpenCL) - endif() - list(APPEND LIBS_STATUS OpenCL) - list(APPEND PIP_LIBS_TARGETS pip_opencl) - set(OpenCL_FOUND ${OpenCL_LIBRARIES}) - else() - message(STATUS "Building PIP without OpenCL support") - endif() + # Check if PIP support OpenCL + find_package(OpenCL QUIET) + if(OpenCL_FOUND) + message(STATUS "Building PIP with OpenCL support") + import_version(pip_opencl pip) + set_deploy_property(pip_opencl ${PIP_LIB_TYPE} + LABEL "PIP OpenCL support" + FULLNAME "${_PIP_DOMAIN}.pip_opencl" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_opencl _RC) + if(APPLE) + include_directories(${OpenCL_INCLUDE_DIRS}/Headers) + else() + include_directories(${OpenCL_INCLUDE_DIRS}) + endif() + add_definitions(-DPIP_OPENCL) + pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf") + add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC}) + add_dependencies(pip_opencl pip_rc) + if(${CMAKE_VERSION} VERSION_LESS "3.7.0") + target_link_libraries(pip_opencl pip OpenCL) + else() + target_link_libraries(pip_opencl pip OpenCL::OpenCL) + endif() + list(APPEND LIBS_STATUS OpenCL) + list(APPEND PIP_LIBS_TARGETS pip_opencl) + set(OpenCL_FOUND ${OpenCL_LIBRARIES}) + else() + message(STATUS "Building PIP without OpenCL support") + endif() - # Check if PIP IO Utils library supports crypt - set(IO_UTILS_LIBS pip) - import_version(pip_io_utils pip) - set_deploy_property(pip_io_utils ${PIP_LIB_TYPE} - LABEL "PIP I/O utilites" - FULLNAME "${_PIP_DOMAIN}.pip_io_utils" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_io_utils _RC) - add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC}) - if(sodium_FOUND) - message(STATUS "Building PIP IO Utils library with crypt support") - list(APPEND IO_UTILS_LIBS pip_crypt) - else() - message(STATUS "Building PIP IO Utils library without crypt support, attention!") - endif() - target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) - list(APPEND PIP_LIBS_TARGETS pip_io_utils) + # Check if PIP IO Utils library supports crypt + set(IO_UTILS_LIBS pip) + import_version(pip_io_utils pip) + set_deploy_property(pip_io_utils ${PIP_LIB_TYPE} + LABEL "PIP I/O utilites" + FULLNAME "${_PIP_DOMAIN}.pip_io_utils" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_io_utils _RC) + add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC}) + if(sodium_FOUND) + message(STATUS "Building PIP IO Utils library with crypt support") + list(APPEND IO_UTILS_LIBS pip_crypt) + else() + message(STATUS "Building PIP IO Utils library without crypt support, attention!") + endif() + target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) + list(APPEND PIP_LIBS_TARGETS pip_io_utils) - # Concurrent module - set(CONCURRENT_LIBS pip) - import_version(pip_concurrent pip) - set_deploy_property(pip_concurrent ${PIP_LIB_TYPE} - LABEL "PIP concurrent support" - FULLNAME "${_PIP_DOMAIN}.pip_concurrent" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_concurrent _RC) - add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC}) - target_link_libraries(pip_concurrent ${CONCURRENT_LIBS}) - set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11) - list(APPEND PIP_LIBS_TARGETS pip_concurrent) + # Concurrent module + set(CONCURRENT_LIBS pip) + import_version(pip_concurrent pip) + set_deploy_property(pip_concurrent ${PIP_LIB_TYPE} + LABEL "PIP concurrent support" + FULLNAME "${_PIP_DOMAIN}.pip_concurrent" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_concurrent _RC) + add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC}) + target_link_libraries(pip_concurrent ${CONCURRENT_LIBS}) + set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11) + list(APPEND PIP_LIBS_TARGETS pip_concurrent) - # Enable build tests for concurrent module - if(PIP_CONCURRENT_TEST) - add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST}) - target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) - add_test(NAME pip_concurrent_test COMMAND tests) - add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) - endif() + # Enable build tests for concurrent module + if(PIP_CONCURRENT_TEST) + add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST}) + target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) + add_test(NAME pip_concurrent_test COMMAND tests) + add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) + endif() - if(PIP_SRC_MATH_TEST) - add_executable(pip_math_test ${CPP_MATH_TEST}) - target_link_libraries(pip_math_test gtest_main gmock_main PIP) - add_test(NAME pip_math_test COMMAND tests) - #add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) - endif() + if(PIP_SRC_MATH_TEST) + add_executable(pip_math_test ${CPP_MATH_TEST}) + target_link_libraries(pip_math_test gtest_main gmock_main PIP) + add_test(NAME pip_math_test COMMAND tests) + #add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) + endif() - if(PIP_SRC_CORE_TEST) - add_executable(pip_core_test ${CPP_CORE_TEST}) - target_link_libraries(pip_core_test gtest_main gmock_main PIP) - add_test(NAME pip_core_test COMMAND tests) - #add_custom_target(pip_core_test_perform ALL COMMAND pip_core_test) - endif() + if(PIP_SRC_CORE_TEST) + add_executable(pip_core_test ${CPP_CORE_TEST}) + target_link_libraries(pip_core_test gtest_main gmock_main PIP) + add_test(NAME pip_core_test COMMAND tests) + #add_custom_target(pip_core_test_perform ALL COMMAND pip_core_test) + endif() - # Build cloud library if crypt enabled - if(sodium_FOUND) - message(STATUS "Building PICloud support") - import_version(pip_cloud pip) - set_deploy_property(pip_cloud ${PIP_LIB_TYPE} - LABEL "PIP cloud transport support" - FULLNAME "${_PIP_DOMAIN}.pip_cloud" - COMPANY "${_PIP_COMPANY}" - INFO "Platform-Independent Primitives") - make_rc(pip_cloud _RC) - add_definitions(-DPIP_CLOUD) - add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC}) - target_link_libraries(pip_cloud pip pip_crypt) - list(APPEND PIP_LIBS_TARGETS pip_cloud) - endif() + # Build cloud library if crypt enabled + if(sodium_FOUND) + message(STATUS "Building PICloud support") + import_version(pip_cloud pip) + set_deploy_property(pip_cloud ${PIP_LIB_TYPE} + LABEL "PIP cloud transport support" + FULLNAME "${_PIP_DOMAIN}.pip_cloud" + COMPANY "${_PIP_COMPANY}" + INFO "Platform-Independent Primitives") + make_rc(pip_cloud _RC) + add_definitions(-DPIP_CLOUD) + add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC}) + target_link_libraries(pip_cloud pip pip_crypt) + list(APPEND PIP_LIBS_TARGETS pip_cloud) + endif() - # Test program - if(PIP_UTILS) - add_executable(pip_test "main.cpp") - target_link_libraries(pip_test pip) - endif() + # Test program + if(PIP_UTILS) + add_executable(pip_test "main.cpp") + target_link_libraries(pip_test pip) + endif() - else() + else() - message(STATUS "Building PIP with crypt support") - add_definitions(-DPIP_CRYPT) - add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT}) - target_link_libraries(pip_crypt pip) - list(APPEND PIP_LIBS_TARGETS pip_crypt) - set(IO_UTILS_LIBS pip) - add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS}) - message(STATUS "Building PIP IO Utils library with crypt support") - list(APPEND IO_UTILS_LIBS pip_crypt) - target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) - list(APPEND PIP_LIBS_TARGETS pip_io_utils) - message(STATUS "Building PIP with zlib compress support") - add_definitions(-DPIP_COMPRESS) - add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS}) - target_link_libraries(pip_compress pip) - list(APPEND PIP_LIBS_TARGETS pip_compress) + message(STATUS "Building PIP with crypt support") + add_definitions(-DPIP_CRYPT) + add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT}) + target_link_libraries(pip_crypt pip) + list(APPEND PIP_LIBS_TARGETS pip_crypt) + set(IO_UTILS_LIBS pip) + add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS}) + message(STATUS "Building PIP IO Utils library with crypt support") + list(APPEND IO_UTILS_LIBS pip_crypt) + target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) + list(APPEND PIP_LIBS_TARGETS pip_io_utils) + message(STATUS "Building PIP with zlib compress support") + add_definitions(-DPIP_COMPRESS) + add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS}) + target_link_libraries(pip_compress pip) + list(APPEND PIP_LIBS_TARGETS pip_compress) - endif() - endif() + endif() +endif() - # Install - # Check if system or local install will be used (to system install use "-DLIB=" argument of cmake) - if(LIB) - if(WIN32) - if(MINGW) - if (NOT CROSSTOOLS) - install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip) - install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB}) - endif() - install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN}) - find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH) - find_library(STDLIB "stdc++-6") - #message("${STDLIB}") - if (STDLIB) - file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator") - file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler") - file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool") - endif() - else() - #message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include) - endif() - else() - if (NOT CROSSTOOLS) - install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip) - endif() - install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) - endif() - message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") - file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore") - install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) - else() - if(NOT PIP_FREERTOS) - if(WIN32) - install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin) - install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib) - else() - install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib) - endif() - install(FILES ${HDRS} DESTINATION include/pip) - message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") - endif() - endif() +# Install +# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake) +if(LIB) + if(WIN32) + if(MINGW) + if (NOT CROSSTOOLS) + install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip) + install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB}) + endif() + install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN}) + find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH) + find_library(STDLIB "stdc++-6") + #message("${STDLIB}") + if (STDLIB) + file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator") + file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler") + file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool") + endif() + else() + #message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include) + endif() + else() + if (NOT CROSSTOOLS) + install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip) + endif() + install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + endif() + message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") + file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore") + install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) +else() + if(NOT PIP_FREERTOS) + if(WIN32) + install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin) + install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib) + else() + install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib) + endif() + install(FILES ${HDRS} DESTINATION include/pip) + message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") + endif() +endif() - if(NOT PIP_FREERTOS) +if(NOT PIP_FREERTOS) - # Auxiliary - if (NOT CROSSTOOLS) - add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal") - endif() +# Auxiliary + if (NOT CROSSTOOLS) + add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal") + endif() - # Utils - add_subdirectory("utils/code_model_generator") - add_subdirectory("utils/resources_compiler") - add_subdirectory("utils/deploy_tool") - if(PIP_UTILS AND (NOT CROSSTOOLS)) - add_subdirectory("utils/system_test") - add_subdirectory("utils/remote_console") - add_subdirectory("utils/udp_file_transfer") - if(sodium_FOUND) - add_subdirectory("utils/system_daemon") - add_subdirectory("utils/crypt_tool") - add_subdirectory("utils/cloud_dispatcher") - endif() - endif() - - endif() +# Utils + add_subdirectory("utils/code_model_generator") + add_subdirectory("utils/resources_compiler") + add_subdirectory("utils/deploy_tool") + if(PIP_UTILS AND (NOT CROSSTOOLS)) + add_subdirectory("utils/system_test") + add_subdirectory("utils/remote_console") + add_subdirectory("utils/udp_file_transfer") + if(sodium_FOUND) + add_subdirectory("utils/system_daemon") + add_subdirectory("utils/crypt_tool") + add_subdirectory("utils/cloud_dispatcher") + endif() + endif() + +endif() - # Libraries messages - message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}") - if(DEFINED LIBPROJECT) - set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE) - list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS}) - set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) - endif() - if(NOT PIP_FREERTOS) - foreach(LIB_ ${LIBS_STATUS}) - message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND}) - if(NOT ${LIB_}_FOUND) - message(WARNING "Library ${LIB_} not found, please install it") - endif() - endforeach() - endif() +# Libraries messages +message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}") +if(DEFINED LIBPROJECT) + set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE) + list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS}) + set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) +endif() +if(NOT PIP_FREERTOS) + foreach(LIB_ ${LIBS_STATUS}) + message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND}) + if(NOT ${LIB_}_FOUND) + message(WARNING "Library ${LIB_} not found, please install it") + endif() + endforeach() +endif() - # - # Build Documentation - # - if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS)) - include(PIPDocumentation) - find_package(Doxygen) - if(DOXYGEN_FOUND) - set(DOXY_PROJECT_NUMBER "${PIP_VERSION}") - set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") - set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") - set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"") - set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"") - if(DOXYGEN_DOT_EXECUTABLE) - string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}") - set(DOXY_DOT_PATH "\"${_DOT_PATH}\"") - set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"") - set(DOXY_DIA_PATH "\"${_DOT_PATH}\"") - endif() - set(DOXY_INPUT) - foreach(F ${PIP_SRC_DIRS}) - list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"") - endforeach(F) - string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}") - string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}") - add_documentation(doc doc/Doxyfile.in) - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL) - endif() - endif() +# +# Build Documentation +# +if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS)) + include(PIPDocumentation) + find_package(Doxygen) + if(DOXYGEN_FOUND) + set(DOXY_PROJECT_NUMBER "${PIP_VERSION}") + set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") + set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") + set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"") + set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"") + if(DOXYGEN_DOT_EXECUTABLE) + string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}") + set(DOXY_DOT_PATH "\"${_DOT_PATH}\"") + set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"") + set(DOXY_DIA_PATH "\"${_DOT_PATH}\"") + endif() + set(DOXY_INPUT) + foreach(F ${PIP_SRC_DIRS}) + list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"") + endforeach(F) + string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}") + string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}") + add_documentation(doc doc/Doxyfile.in) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL) + endif() +endif() diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user deleted file mode 100644 index c8d7ecc3..00000000 --- a/CMakeLists.txt.user +++ /dev/null @@ -1,1098 +0,0 @@ - - - - - - EnvironmentId - {590da41d-e68d-4f0d-9a90-bf433d6b70a5} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - -fno-delayed-template-parsing - - true - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.12.7 MinGW 64-bit - Desktop Qt 5.12.7 MinGW 64-bit - qt.qt5.5127.win64_mingw73_kit - 1 - 0 - 3 - - - CMAKE_BUILD_TYPE:STRING=Debug - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Debug - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Отладка - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Release - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Выпуск - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=RelWithDebInfo - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-RelWithDebInfo - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Выпуск с отладочной информацией - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=MinSizeRel - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-MinSizeRel - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Сборка - Сборка - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Очистка - Очистка - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Выпуск минимального размера - CMakeProjectManager.CMakeBuildConfiguration - - 4 - - - 0 - Развёртывание - Развёртывание - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - deploy_tool - CMakeProjectManager.CMakeRunConfiguration.deploy_tool - deploy_tool - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/deploy_tool - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pift - CMakeProjectManager.CMakeRunConfiguration.pift - pift - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/udp_file_transfer - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - piterminal - CMakeProjectManager.CMakeRunConfiguration.piterminal - piterminal - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/lib/main/auxiliary/piterminal - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_cmg - CMakeProjectManager.CMakeRunConfiguration.pip_cmg - pip_cmg - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/code_model_generator - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_concurrent_test - CMakeProjectManager.CMakeRunConfiguration.pip_concurrent_test - pip_concurrent_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_core_test - CMakeProjectManager.CMakeRunConfiguration.pip_core_test - pip_core_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_math_test - CMakeProjectManager.CMakeRunConfiguration.pip_math_test - pip_math_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_rc - CMakeProjectManager.CMakeRunConfiguration.pip_rc - pip_rc - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/resources_compiler - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_remote_console - CMakeProjectManager.CMakeRunConfiguration.pip_remote_console - pip_remote_console - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/remote_console - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_system_test - CMakeProjectManager.CMakeRunConfiguration.pip_system_test - pip_system_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release/utils/system_test - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - pip_test - CMakeProjectManager.CMakeRunConfiguration.pip_test - pip_test - - false - - false - true - true - false - false - true - - D:/ewfew/build-pip-Desktop_Qt_5_12_7_MinGW_64_bit-Release - - 11 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - From fcf91a26b6d50229d4f06de14df05bb0d618e906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Tue, 1 Sep 2020 12:10:56 +0300 Subject: [PATCH 8/9] Tests update --- lib/main/math/test/testpimathmatrix.cpp | 313 +++++------------------ lib/main/math/test/testpimathmatrixt.cpp | 300 +++++----------------- 2 files changed, 141 insertions(+), 472 deletions(-) diff --git a/lib/main/math/test/testpimathmatrix.cpp b/lib/main/math/test/testpimathmatrix.cpp index 8dbef289..4eeccd0c 100644 --- a/lib/main/math/test/testpimathmatrix.cpp +++ b/lib/main/math/test/testpimathmatrix.cpp @@ -1,18 +1,44 @@ #include "gtest/gtest.h" #include "pimathmatrix.h" -using namespace std; - -PIMathMatrix origMatr; +bool cmpMatrixWithValue(PIMathMatrix matrix, double val) +{ + int i = 0; + int j = 0; + int k = 0; + bool b; + while(i < 9) + { + if(k < 3) + { + if(matrix.element(j,k) == val) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + return b; +} TEST(PIMathMatrix_Test, identity) { + PIMathMatrix origMatr; PIMathMatrix matrix; int i; - double d; - bool a, b; + bool b; matrix = origMatr.identity(3, 3); - d = matrix.determinant(); for(i = 0; i < 3; i++) { if(matrix[i][i] == 1.0) @@ -25,19 +51,12 @@ TEST(PIMathMatrix_Test, identity) break; } } - if(d == 1.0) - { - a = true; - } - else - { - a = false; - } - ASSERT_TRUE(a && b); + ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, matrixRow) { + PIMathMatrix origMatr; PIMathMatrix matrix; PIMathVector vector; uint i; @@ -62,6 +81,7 @@ TEST(PIMathMatrix_Test, matrixRow) TEST(PIMathMatrix_Test, matrixCol) { + PIMathMatrix origMatr; PIMathMatrix matrix; PIMathVector vector; uint i; @@ -86,6 +106,7 @@ TEST(PIMathMatrix_Test, matrixCol) TEST(PIMathMatrix_Test, setCol) { + PIMathMatrix origMatr; PIMathMatrix matrix; PIMathVector vector; uint i; @@ -112,6 +133,7 @@ TEST(PIMathMatrix_Test, setCol) TEST(PIMathMatrix_Test, setRow) { + PIMathMatrix origMatr; PIMathMatrix matrix; PIMathVector vector; uint i; @@ -138,6 +160,7 @@ TEST(PIMathMatrix_Test, setRow) TEST(PIMathMatrix_Test, swapCols) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathVector vector; uint i1 = 0; uint i2 = 1; @@ -184,6 +207,7 @@ TEST(PIMathMatrix_Test, swapCols) TEST(PIMathMatrix_Test, swapRows) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathVector vector; uint i1 = 0; uint i2 = 1; @@ -229,41 +253,18 @@ TEST(PIMathMatrix_Test, swapRows) } TEST(PIMathMatrix_Test, fill) { + PIMathMatrix origMatr; PIMathMatrix matrix; - int i = 0; - int j = 0; - int k = 0; bool b; matrix = origMatr.identity(3, 3); matrix.fill(5.0); - while(i < 9) - { - if(k < 3) - { - if(matrix.element(j,k) == 5.0) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix, 5.0); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, isSquare) { - + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; @@ -282,6 +283,7 @@ TEST(PIMathMatrix_Test, isSquare) TEST(PIMathMatrix_Test, isIdentity) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; @@ -301,6 +303,7 @@ TEST(PIMathMatrix_Test, isIdentity) TEST(PIMathMatrix_Test, isNull) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; @@ -321,6 +324,7 @@ TEST(PIMathMatrix_Test, isNull) TEST(PIMathMatrix_Test, isValid) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; @@ -338,43 +342,21 @@ TEST(PIMathMatrix_Test, isValid) TEST(PIMathMatrix_Test, operator_Assignment) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; - int i = 0; - int j = 0; - int k = 0; bool b; matrix1 = origMatr.identity(3,3); matrix2 = origMatr.identity(3,3); matrix2.fill(6.72); matrix1 = matrix2; - while(i < 9) - { - if(k < 3) - { - if(matrix1.element(j,k) == 6.72) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 6.72); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Equal) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; PIMathMatrix matrix3; @@ -418,6 +400,7 @@ TEST(PIMathMatrix_Test, operator_Equal) TEST(PIMathMatrix_Test, operator_Not_Equal) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; PIMathMatrix matrix3; @@ -461,189 +444,75 @@ TEST(PIMathMatrix_Test, operator_Not_Equal) TEST(PIMathMatrix_Test, operator_Addition_Aassignment) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix2 = origMatr.identity(3,3); matrix2.fill(6.72); matrix1.fill(1.0); matrix1 += matrix2; - while(i < 9) - { - if(k < 3) - { - if(matrix1.element(j,k) == 7.72) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 7.72); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Subtraction_Assignment) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix2 = origMatr.identity(3,3); matrix2.fill(6.72); matrix1.fill(1.0); matrix1 -= matrix2; - while(i < 9) - { - if(k < 3) - { - if(matrix1.element(j,k) == -5.72) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, -5.72); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Multiplication_Assignment) { + PIMathMatrix origMatr; PIMathMatrix matrix1; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix1.fill(6.72); matrix1 *= 2.0; - while(i < 9) - { - if(k < 3) - { - if(matrix1.element(j,k) == 13.44) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 13.44); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Division_Assignment) { + PIMathMatrix origMatr; PIMathMatrix matrix1; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix1.fill(6.72); matrix1 /= 2.0; - while(i < 9) - { - if(k < 3) - { - if(matrix1.element(j,k) == 3.36) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 3.36); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Addition) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix2 = origMatr.identity(3,3); matrix1.fill(6.72); matrix2.fill(8.28); - while(i < 9) - { - if(k < 3) - { - if((matrix1+matrix2).element(j,k) == 15.0) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1 + matrix2, 15.0); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Subtraction) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; @@ -666,79 +535,34 @@ TEST(PIMathMatrix_Test, operator_Subtraction) TEST(PIMathMatrix_Test, operator_Multiplication) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix2 = origMatr.identity(3,3); matrix1.fill(6.72); matrix2 = matrix1*4.0; - while(i < 9) - { - if(k < 3) - { - if(matrix2.element(j,k) == 26.88) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix2, 26.88); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, operator_Division) { + PIMathMatrix origMatr; PIMathMatrix matrix1; PIMathMatrix matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1 = origMatr.identity(3,3); matrix2 = origMatr.identity(3,3); matrix1.fill(6.72); matrix2 = matrix1/4.0; - while(i < 9) - { - if(k < 3) - { - if(matrix2.element(j,k) == 1.68) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix2, 1.68); ASSERT_TRUE(b); } TEST(PIMathMatrix_Test, determinant) { + PIMathMatrix origMatr; double d; double i = 59.0; PIMathMatrix matrix; @@ -763,6 +587,7 @@ TEST(PIMathMatrix_Test, determinant) TEST(PIMathMatrix_Test, trace) { + PIMathMatrix origMatr; double t; double i = 9.0; PIMathMatrix matrix; @@ -787,6 +612,7 @@ TEST(PIMathMatrix_Test, trace) TEST(PIMathMatrix_Test, toUpperTriangular) { + PIMathMatrix origMatr; double d1, d2 = 1; int i; PIMathMatrix matrix; @@ -816,6 +642,7 @@ TEST(PIMathMatrix_Test, toUpperTriangular) TEST(PIMathMatrix_Test, invert) { + PIMathMatrix origMatr; double d1, d2; bool b; PIMathMatrix matrix1; @@ -857,6 +684,7 @@ TEST(PIMathMatrix_Test, invert) TEST(PIMathMatrix_Test, inverted) { + PIMathMatrix origMatr; double d1, d2; bool b; PIMathMatrix matrix1; @@ -898,6 +726,7 @@ TEST(PIMathMatrix_Test, inverted) TEST(PIMathMatrix_Test, transposed) { + PIMathMatrix origMatr; double d1, d2; bool b; PIMathMatrix matrix1; @@ -932,5 +761,3 @@ TEST(PIMathMatrix_Test, transposed) } ASSERT_TRUE(b); } - - diff --git a/lib/main/math/test/testpimathmatrixt.cpp b/lib/main/math/test/testpimathmatrixt.cpp index 1d343237..38976bf8 100644 --- a/lib/main/math/test/testpimathmatrixt.cpp +++ b/lib/main/math/test/testpimathmatrixt.cpp @@ -3,11 +3,42 @@ const uint rows = 3; const uint cols = 3; -PIMathMatrixT matr; -PIMathVectorT vect; + +bool cmpMatrixWithValue(PIMathMatrixT matrix, double val) +{ + int i = 0; + int j = 0; + int k = 0; + bool b; + while(i < 9) + { + if(k < 3) + { + if(matrix.at(j,k) == val) + { + b = true; + } + else + { + b = false; + break; + } + k++; + if(k == 3) + { + j++; + k = 0; + } + } + i++; + } + return b; +} + TEST(PIMathMatrixT_Test, identity) { + PIMathMatrixT matr; PIMathMatrixT matrix; double d; double i = 1.0; @@ -38,6 +69,7 @@ TEST(PIMathMatrixT_Test, at) { uint i; bool b; + PIMathMatrixT matr; PIMathMatrixT matrix1; PIMathMatrixT matrix2; matrix1 = matr.identity(); @@ -60,6 +92,8 @@ TEST(PIMathMatrixT_Test, filled) { PIMathMatrixT matrix1; PIMathMatrixT matrix2; + PIMathMatrixT matr; + PIMathVectorT vect; double g = 1.0; matrix2 = matr.fill(g); uint j = 0, i = 0; @@ -75,16 +109,20 @@ TEST(PIMathMatrixT_Test, filled) TEST(PIMathMatrixT_Test, cols) { + PIMathMatrixT matr; ASSERT_EQ(cols,matr.cols()); } TEST(PIMathMatrixT_Test, rows) { + PIMathMatrixT matr; ASSERT_EQ(rows,matr.rows()); } TEST(PIMathMatrixT_Test, col) { + PIMathMatrixT matr; + PIMathVectorT vect; uint i; uint g = 2; bool b; @@ -115,6 +153,8 @@ TEST(PIMathMatrixT_Test, col) TEST(PIMathMatrixT_Test, row) { + PIMathMatrixT matr; + PIMathVectorT vect; uint i; uint g = 2; bool b; @@ -145,6 +185,8 @@ TEST(PIMathMatrixT_Test, row) TEST(PIMathMatrixT_Test, setCol) { + PIMathMatrixT matr; + PIMathVectorT vect; vect.at(0) = 1.0; vect.at(1) = 3.0; vect.at(2) = 5.0; @@ -169,6 +211,8 @@ TEST(PIMathMatrixT_Test, setCol) TEST(PIMathMatrixT_Test, setRow) { + PIMathMatrixT matr; + PIMathVectorT vect; vect.at(0) = 1.0; vect.at(1) = 3.0; vect.at(2) = 5.0; @@ -193,6 +237,7 @@ TEST(PIMathMatrixT_Test, setRow) TEST(PIMathMatrixT_Test, swapCols) { + PIMathMatrixT matr; PIMathVectorT before_Vect1; PIMathVectorT before_Vect2; PIMathVectorT after_Vect1; @@ -226,6 +271,7 @@ TEST(PIMathMatrixT_Test, swapCols) TEST(PIMathMatrixT_Test, swapRows) { + PIMathMatrixT matr; PIMathVectorT before_Vect1; PIMathVectorT before_Vect2; PIMathVectorT after_Vect1; @@ -259,6 +305,7 @@ TEST(PIMathMatrixT_Test, swapRows) TEST(PIMathMatrixT_Test, fill) { + PIMathMatrixT matr; PIMathMatrixT matrix1; double g = 1.0; matr.fill(g); @@ -275,6 +322,7 @@ TEST(PIMathMatrixT_Test, fill) TEST(PIMathMatrixT_Test, isSquare) { + PIMathMatrixT matr; PIMathMatrixT matrix1; const uint new_Cols = 4; PIMathMatrixT matrix2; @@ -292,6 +340,7 @@ TEST(PIMathMatrixT_Test, isSquare) TEST(PIMathMatrixT_Test, isIdentity) { + PIMathMatrixT matr; PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; @@ -312,6 +361,7 @@ TEST(PIMathMatrixT_Test, isNull) { PIMathMatrixT matrix1; PIMathMatrixT matrix2; + PIMathMatrixT matr; bool b; matrix2 = matr.filled(3.67); if((matrix1.isNull() == true) && (matrix2.isNull() == false)) @@ -329,34 +379,11 @@ TEST(PIMathMatrixT_Test, operator_Assignment) { PIMathMatrixT matrix1; PIMathMatrixT matrix2; - int i = 0; - int j = 0; - int k = 0; + PIMathMatrixT matr; bool b; matrix2.fill(6.72); matrix1 = matrix2; - while(i < 9) - { - if(k < 3) - { - if(matrix1.at(j,k) == 6.72) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 6.72); ASSERT_TRUE(b); } @@ -364,6 +391,7 @@ TEST(PIMathMatrixT_Test, operator_Equal) { PIMathMatrixT matrix1; PIMathMatrixT matrix2; + PIMathMatrixT matr; bool b; matr.at(0,0) = 3; matr.at(0,1) = 6; @@ -393,6 +421,7 @@ TEST(PIMathMatrixT_Test, operator_Not_Equal) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; + PIMathMatrixT matr; matr.at(0,0) = 3; matr.at(0,1) = 6; matr.at(0,2) = 8; @@ -421,34 +450,10 @@ TEST(PIMathMatrixT_Test, operator_Addition_Aassignment) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix2.fill(6.72); matrix1.fill(1.0); matrix1 += matrix2; - while(i < 9) - { - if(k < 3) - { - if(matrix1.at(j,k) == 7.72) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 7.72); ASSERT_TRUE(b); } @@ -457,34 +462,10 @@ TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix2.fill(6.72); matrix1.fill(1.0); matrix1 -= matrix2; - while(i < 9) - { - if(k < 3) - { - if(matrix1.at(j,k) == -5.72) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, -5.72); ASSERT_TRUE(b); } @@ -492,33 +473,9 @@ TEST(PIMathMatrixT_Test, operator_Multiplication_Assignment) { PIMathMatrixT matrix1; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1.fill(6.72); matrix1 *= 2.0; - while(i < 9) - { - if(k < 3) - { - if(matrix1.at(j,k) == 13.44) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 13.44); ASSERT_TRUE(b); } @@ -526,33 +483,9 @@ TEST(PIMathMatrixT_Test, operator_Division_Assignment) { PIMathMatrixT matrix1; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1.fill(6.72); matrix1 /= 2.0; - while(i < 9) - { - if(k < 3) - { - if(matrix1.at(j,k) == 3.36) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1, 3.36); ASSERT_TRUE(b); } @@ -561,33 +494,9 @@ TEST(PIMathMatrixT_Test, operator_Addition) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1.fill(6.72); matrix2.fill(8.28); - while(i < 9) - { - if(k < 3) - { - if((matrix1 + matrix2).at(j,k) == 15.0) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix1 + matrix2, 15.0); ASSERT_TRUE(b); } @@ -596,33 +505,9 @@ TEST(PIMathMatrixT_Test, operator_Subtraction) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; - matrix1.fill(6.72); - matrix2.fill(8.28); - while(i < 9) - { - if(k < 3) - { - if(round((matrix1 - matrix2).at(j,k) * 10000) / 10000 == -1.56) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + matrix1.fill(6.0); + matrix2.fill(5.0); + b = cmpMatrixWithValue(matrix1 - matrix2, 1.0); ASSERT_TRUE(b); } @@ -631,33 +516,9 @@ TEST(PIMathMatrixT_Test, operator_Multiplication) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1.fill(6.72); matrix2 = matrix1*4.0; - while(i < 9) - { - if(k < 3) - { - if(matrix2.at(j,k) == 26.88) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix2, 26.88); ASSERT_TRUE(b); } TEST(PIMathMatrixT_Test, operator_Division) @@ -665,33 +526,9 @@ TEST(PIMathMatrixT_Test, operator_Division) PIMathMatrixT matrix1; PIMathMatrixT matrix2; bool b; - int i = 0; - int j = 0; - int k = 0; matrix1.fill(6.72); matrix2 = matrix1/4.0; - while(i < 9) - { - if(k < 3) - { - if(matrix2.at(j,k) == 1.68) - { - b = true; - } - else - { - b = false; - break; - } - k++; - if(k == 3) - { - j++; - k = 0; - } - } - i++; - } + b = cmpMatrixWithValue(matrix2, 1.68); ASSERT_TRUE(b); } @@ -700,6 +537,7 @@ TEST(PIMathMatrixT_Test, determinant) { double d; double i = 59.0; + PIMathMatrixT matr; matr.at(0,0) = 3; matr.at(0,1) = 6; matr.at(0,2) = 8; @@ -718,6 +556,7 @@ TEST(PIMathMatrixT_Test, invert) PIMathMatrixT matrix1; PIMathMatrixT matrix2; PIMathMatrixT matrix3; + PIMathMatrixT matr; double d1, d2; bool b; matrix1 = matr.identity(); @@ -752,6 +591,7 @@ TEST(PIMathMatrixT_Test, inverted) PIMathMatrixT matrix1; PIMathMatrixT matrix2; PIMathMatrixT matrix3; + PIMathMatrixT matr; double d1, d2; bool b; matrix1 = matr.identity(); @@ -784,6 +624,7 @@ TEST(PIMathMatrixT_Test, toUpperTriangular) PIMathMatrixT matrix; double d1, d2 = 1; uint i; + PIMathMatrixT matr; matr.at(0,0) = 3; matr.at(0,1) = 6; matr.at(0,2) = 8; @@ -806,6 +647,7 @@ TEST(PIMathMatrixT_Test, transposed) { PIMathMatrixT matrix1; PIMathMatrixT matrix2; + PIMathMatrixT matr; double d1, d2; bool b; matr.at(0,0) = 3; From 2913fc284bfde20ac439e0ddc2d59897933a222d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D1=88=D0=BE=D0=B2=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Tue, 1 Sep 2020 12:54:02 +0300 Subject: [PATCH 9/9] Merge with pip 3 --- tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 71177e1d..bebb15da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,3 +16,4 @@ endmacro() # Concurrent tests pip_test(concurrent "") +pip_test(math "")