From eb9a91a9dcb98c5266f36e019e4fe73fa881e857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D0=BE=D0=BC=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=A1=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B0=D0=BD=20=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Fri, 24 Jan 2020 09:47:32 +0000 Subject: [PATCH] Share testing library for all project git-svn-id: svn://db.shs.com.ru/pip@873 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- CMakeLists.txt | 7 ++++- DownloadGTest.cmake | 31 +++++++++++++++++++ ...MakeLists.txt.in => GTestCMakeLists.txt.in | 0 src_concurrent/test/CMakeLists.txt | 31 ------------------- 4 files changed, 37 insertions(+), 32 deletions(-) create mode 100644 DownloadGTest.cmake rename src_concurrent/test/CMakeLists.txt.in => GTestCMakeLists.txt.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15e9a7c2..939d12b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(INTROSPECTION "Build with introspection" OFF) option(LIB "System install" ON) option(STATIC_LIB OFF) option(DEBUG "Build with -g3" OFF) +option(TESTS "Build tests and perform their before install step" OFF) set(PIP_UTILS 1) if(LIBPROJECT) set(PIP_UTILS ${UTILS}) @@ -221,6 +222,10 @@ else() message(STATUS "Building PIP release version") endif() +if (TESTS) + include(DownloadGTest.cmake) + option(CONCURRENT_TESTS "Enable tests for concurrent library" ON) +endif() # Check if std::iostream operators support if(STD_IOSTREAM) @@ -487,7 +492,7 @@ if (NOT PIP_FREERTOS) list(APPEND PIP_LIBS_TARGETS pip_concurrent) # Enable build tests for concurrent module - if(CONCURRENT_TESTING) + if(CONCURRENT_TESTS) add_subdirectory(src_concurrent/test) endif() diff --git a/DownloadGTest.cmake b/DownloadGTest.cmake new file mode 100644 index 00000000..b6b9e5a5 --- /dev/null +++ b/DownloadGTest.cmake @@ -0,0 +1,31 @@ +# Download and unpack googletest at configure time +configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt) +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL) + +# The gtest/gtest_main targets carry header search path +# dependencies automatically when using CMake 2.8.11 or +# later. Otherwise we have to add them here ourselves. +if (CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include") +endif() \ No newline at end of file diff --git a/src_concurrent/test/CMakeLists.txt.in b/GTestCMakeLists.txt.in similarity index 100% rename from src_concurrent/test/CMakeLists.txt.in rename to GTestCMakeLists.txt.in diff --git a/src_concurrent/test/CMakeLists.txt b/src_concurrent/test/CMakeLists.txt index 3a120782..04f4206d 100644 --- a/src_concurrent/test/CMakeLists.txt +++ b/src_concurrent/test/CMakeLists.txt @@ -1,35 +1,4 @@ project(concurrent_test) -# Download and unpack googletest at configure time -configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) -if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") -endif() - -# Prevent overriding the parent project's compiler/linker -# settings on Windows -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - -# Add googletest directly to our build. This defines -# the gtest and gtest_main targets. -add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src - ${CMAKE_CURRENT_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL) - -# The gtest/gtest_main targets carry header search path -# dependencies automatically when using CMake 2.8.11 or -# later. Otherwise we have to add them here ourselves. -if (CMAKE_VERSION VERSION_LESS 2.8.11) - include_directories("${gtest_SOURCE_DIR}/include") -endif() file(GLOB_RECURSE CPPS "*.cpp") #find_package(GTest REQUIRED)