From fc4aed4c695b8c6057111afc23dc42c2135ca55b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 19 Jul 2018 11:04:41 +0900 Subject: [PATCH] Tidy cmake, separate gtest support (#2007) This will extract gtest support codes to separate file Signed-off-by: SaeHie Park --- CMakeLists.txt | 35 +---------------------------------- cmake/support/gtest.cmake | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 cmake/support/gtest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7287cde..80437d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,41 +57,8 @@ endif() # CI server places pre-built ARM compute libraries on this directory. link_directories(${CMAKE_INSTALL_PREFIX}/lib) -# # GTest support -# -if(OBS_BUILD) - enable_testing() - find_package(GTest REQUIRED) - include_directories(${GTEST_INCLUDE_DIR}) -else() - include(ExternalProject) - if (BUILD_IS_NATIVE) - set(GoogleTestCMakeArgs) - else() - set(GoogleTestCMakeArgs -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/cmake/config/config_${TARGET_ARCH}-${TARGET_OS}.cmake) - endif() - # Download and install GoogleTest - ExternalProject_Add( - googletest - URL http://npuarchive.mooo.com/archive/nnfw/gtest/release-1.8.0.zip - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/googletest - # Disable install step - INSTALL_COMMAND "" - LOG_DOWNLOAD 1 - LOG_BUILD 1 - LOG_CONFIGURE 1 - CMAKE_ARGS "${GoogleTestCMakeArgs}" - ) - ExternalProject_Get_Property(googletest source_dir binary_dir) - - # include and link path for all sub project - include_directories(${source_dir}/googletest/include/) - link_directories(${binary_dir}/googlemock/gtest/) -endif() - -# gtest libs -set(NNFW_GTEST_LIBS libgtest.a libgtest_main.a ${LIB_PTHREAD}) +include("cmake/support/gtest.cmake") # TODO For now Android build is being enabled incrementally so not all subdirectories are added yet. # However we are going to have the same subdirectories with other OS eventually. diff --git a/cmake/support/gtest.cmake b/cmake/support/gtest.cmake new file mode 100644 index 0000000..73a990b --- /dev/null +++ b/cmake/support/gtest.cmake @@ -0,0 +1,35 @@ +# +# GTest support +# +if(OBS_BUILD) + enable_testing() + find_package(GTest REQUIRED) + include_directories(${GTEST_INCLUDE_DIR}) +else() + include(ExternalProject) + if (BUILD_IS_NATIVE) + set(GoogleTestCMakeArgs) + else() + set(GoogleTestCMakeArgs -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/cmake/config/config_${TARGET_ARCH}-${TARGET_OS}.cmake) + endif() + # Download and install GoogleTest + ExternalProject_Add( + googletest + URL http://npuarchive.mooo.com/archive/nnfw/gtest/release-1.8.0.zip + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/googletest + # Disable install step + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_BUILD 1 + LOG_CONFIGURE 1 + CMAKE_ARGS "${GoogleTestCMakeArgs}" + ) + ExternalProject_Get_Property(googletest source_dir binary_dir) + + # include and link path for all sub project + include_directories(${source_dir}/googletest/include/) + link_directories(${binary_dir}/googlemock/gtest/) +endif() + +# gtest libs +set(NNFW_GTEST_LIBS libgtest.a libgtest_main.a ${LIB_PTHREAD}) -- 2.7.4