diff --git a/CMakeLists.txt b/CMakeLists.txt index d5c5b12..7b42493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,7 @@ if(DOWNLOAD_GTEST OR GTEST_SRC_DIR) endif() if(BUILD_TESTS) + enable_testing() include_directories(${XTENSOR_BLAS_INCLUDE_DIR}) include_directories(${xtensor_INCLUDE_DIRS}) add_subdirectory(test) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f257a71..c80f6de 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,6 +12,8 @@ cmake_minimum_required(VERSION 3.1) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) project(xtensor-blas-test) + enable_testing() + find_package(xtensor REQUIRED CONFIG) set(XTENSOR_INCLUDE_DIR ${xtensor_INCLUDE_DIRS}) find_package(xtensor-blas REQUIRED CONFIG) @@ -75,7 +77,10 @@ if(DOWNLOAD_GTEST OR GTEST_SRC_DIR) ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL) set(GTEST_INCLUDE_DIRS "${gtest_SOURCE_DIR}/include") - set(GTEST_BOTH_LIBRARIES gtest_main gtest) + add_library(GTest::gtest INTERFACE IMPORTED) + target_link_libraries(GTest::gtest INTERFACE gtest) + add_library(GTest::gtest_main INTERFACE IMPORTED) + target_link_libraries(GTest::gtest_main INTERFACE gtest_main) else() find_package(GTest REQUIRED) endif() @@ -117,7 +122,7 @@ if(DOWNLOAD_GTEST OR GTEST_SRC_DIR) add_dependencies(test_xtensor_blas gtest_main) endif() -target_link_libraries(test_xtensor_blas ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(test_xtensor_blas ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} GTest::gtest GTest::gtest_main ${CMAKE_THREAD_LIBS_INIT}) if(CPP17) target_compile_features(test_xtensor_blas PUBLIC cxx_std_17) else() @@ -125,3 +130,4 @@ else() endif() add_custom_target(xtest COMMAND test_xtensor_blas DEPENDS test_xtensor_blas) +add_test(NAME xtest COMMAND test_xtensor_blas)