new cmake

This commit is contained in:
Шишов Максим Денисович
2020-07-24 15:24:13 +03:00
parent bb635f6c51
commit f71fbb0068

View File

@@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip) project(pip)
set(_PIP_MAJOR 1) set(_PIP_MAJOR 1)
set(_PIP_MINOR 23) set(_PIP_MINOR 24)
set(_PIP_REVISION 0) set(_PIP_REVISION 0)
set(_PIP_SUFFIX ) set(_PIP_SUFFIX )
set(_PIP_COMPANY SHS) set(_PIP_COMPANY SHS)
set(_PIP_DOMAIN org.SHS) set(_PIP_DOMAIN org.SHS)
set(TESTS=true)
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") 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() endif()
@@ -85,8 +85,10 @@ set(HDRS)
set(PHDRS) set(PHDRS)
if (TESTS) if (TESTS)
set(PIP_SRC_CONCURRENT_TEST "lib/concurrent/test") include(DownloadGTest)
set(PIP_CONCURRENT_TEST "lib/concurrent/test")
set(PIP_SRC_MATH_TEST "lib/main/math/test") set(PIP_SRC_MATH_TEST "lib/main/math/test")
set(PIP_SRC_CORE_TEST "lib/main/core/test")
endif() endif()
if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
@@ -211,7 +213,7 @@ gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS)
# Concurrent lib # Concurrent lib
gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS) 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 # Cloud lib
gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS) gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
@@ -219,6 +221,9 @@ gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
#Math test lib #Math test lib
gather_src("${PIP_SRC_MATH_TEST}" CPP_MATH_TEST HDRS PHDRS) 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) if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS) add_definitions(-DPIP_FREERTOS)
set(ICU OFF) set(ICU OFF)
@@ -276,16 +281,6 @@ else()
message(STATUS "Building PIP release version") message(STATUS "Building PIP release version")
endif() 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 # Check if std::iostream operators support
if(STD_IOSTREAM) if(STD_IOSTREAM)
@@ -603,19 +598,27 @@ if (NOT CROSSTOOLS)
list(APPEND PIP_LIBS_TARGETS pip_concurrent) list(APPEND PIP_LIBS_TARGETS pip_concurrent)
# Enable build tests for concurrent module # Enable build tests for concurrent module
if(CONCURRENT_TESTS) if(PIP_CONCURRENT_TEST)
add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST}) add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST})
target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent)
add_test(NAME pip_concurrent_test COMMAND tests) add_test(NAME pip_concurrent_test COMMAND tests)
add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test)
endif() endif()
if(MATH_TESTS)
if(PIP_SRC_MATH_TEST)
add_executable(pip_math_test ${CPP_MATH_TEST}) add_executable(pip_math_test ${CPP_MATH_TEST})
target_link_libraries(pip_math_test gtest_main gmock_main PIP) target_link_libraries(pip_math_test gtest_main gmock_main PIP)
add_test(NAME pip_math_test COMMAND tests) add_test(NAME pip_math_test COMMAND tests)
#add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test) #add_custom_target(pip_math_test_perform ALL COMMAND pip_math_test)
endif() 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 # Build cloud library if crypt enabled
if(sodium_FOUND) if(sodium_FOUND)
message(STATUS "Building PICloud support") message(STATUS "Building PICloud support")