@@ -568,52 +568,26 @@ if(INFO)
568
568
# modifications on blas_connector and lapack_connector
569
569
endif ()
570
570
571
- IF ( BUILD_TESTING )
572
- set_if_higher ( CMAKE_CXX_STANDARD 14 ) # Required in orbital
573
- include ( CTest )
574
- enable_testing ( )
575
- find_package ( GTest HINTS /usr/local/lib/ ${GTEST_DIR } )
576
- if ( NOT ${GTest_FOUND} )
571
+ # Add performance test in abacus
572
+ IF ( ENABLE_GOOGLEBENCH )
573
+ set ( BUILD_TESTING ON )
574
+ find_package ( benchmark HINTS ${BENCHMARK_DIR} )
575
+ if ( NOT ${benchmark_FOUND } )
576
+ set ( BENCHMARK_USE_BUNDLED_GTEST OFF )
577
577
include (FetchContent )
578
578
FetchContent_Declare (
579
- googletest
580
- GIT_REPOSITORY https://github.com/google/googletest .git
579
+ benchmark
580
+ GIT_REPOSITORY https://github.com/google/benchmark .git
581
581
GIT_TAG "origin/main"
582
582
GIT_SHALLOW TRUE
583
583
GIT_PROGRESS TRUE
584
584
)
585
- FetchContent_MakeAvailable (googletest )
585
+ FetchContent_MakeAvailable (benchmark )
586
586
endif ()
587
- # TODO: Try the GoogleTest module.
588
- # https://cmake.org/cmake/help/latest/module/GoogleTest.html
589
- add_subdirectory (tests ) # Contains integration tests
590
-
591
- function (AddTest ) # function for UT
592
- cmake_parse_arguments (UT "DYN" "TARGET" "LIBS;DYN_LIBS;STATIC_LIBS;SOURCES;DEPENDS" ${ARGN} )
593
- add_executable (${UT_TARGET} ${UT_SOURCES} )
594
-
595
- if (ENABLE_COVERAGE )
596
- add_coverage (${UT_TARGET} )
597
- endif ()
598
-
599
- #dependencies & link library
600
- target_link_libraries (${UT_TARGET} ${UT_LIBS}
601
- Threads::Threads GTest::gtest_main GTest::gmock_main )
602
- if (USE_OPENMP )
603
- target_link_libraries (${UT_TARGET} OpenMP::OpenMP_CXX )
604
- endif ()
605
- install (TARGETS ${UT_TARGET} DESTINATION ${CMAKE_BINARY_DIR} /tests )
606
- add_test (NAME ${UT_TARGET}
607
- COMMAND ${UT_TARGET}
608
- WORKING_DIRECTORY $< TARGET_FILE_DIR:${UT_TARGET} >
609
- )
610
- endfunction (AddTest )
611
587
endif ()
612
588
613
-
614
- # Add performance test in abacus
615
- IF (ENABLE_GOOGLEBENCH )
616
- set (CMAKE_CXX_STANDARD 14 ) # Required in orbital
589
+ IF (BUILD_TESTING )
590
+ set_if_higher (CMAKE_CXX_STANDARD 14 ) # Required in orbital
617
591
include (CTest )
618
592
enable_testing ()
619
593
find_package (GTest HINTS /usr/local/lib/ ${GTEST_DIR} )
@@ -628,37 +602,27 @@ IF (ENABLE_GOOGLEBENCH)
628
602
)
629
603
FetchContent_MakeAvailable (googletest )
630
604
endif ()
605
+ # TODO: Try the GoogleTest module.
606
+ # https://cmake.org/cmake/help/latest/module/GoogleTest.html
607
+ add_subdirectory (tests ) # Contains integration tests
631
608
632
- find_package (benchmark REQUIRED )
633
- if (NOT ${benchmark_FOUND} )
634
- include (FetchContent )
635
- FetchContent_Declare (
636
- benchmark
637
- GIT_REPOSITORY https://github.com/google/benchmark.git
638
- GIT_TAG "origin/main"
639
- GIT_SHALLOW TRUE
640
- GIT_PROGRESS TRUE
641
- )
642
- FetchContent_MakeAvailable (benchmark )
643
- endif ()
644
-
645
- function (AddPerfTest ) # function for UT
646
- add_compile_options (-O2 )
609
+ function (AddTest ) # function for UT
647
610
cmake_parse_arguments (UT "DYN" "TARGET" "LIBS;DYN_LIBS;STATIC_LIBS;SOURCES;DEPENDS" ${ARGN} )
648
611
add_executable (${UT_TARGET} ${UT_SOURCES} )
649
612
650
613
if (ENABLE_COVERAGE )
651
614
add_coverage (${UT_TARGET} )
652
615
endif ()
653
616
654
-
655
- # Link Google Benchmark to the project
656
- target_link_libraries (${UT_TARGET} benchmark::benchmark )
657
-
658
-
659
617
#dependencies & link library
660
- target_link_libraries (${UT_TARGET} ${UT_LIBS}
661
- Threads::Threads GTest::gtest_main GTest::gmock_main )
618
+ if (ENABLE_GOOGLEBENCH )
619
+ target_link_libraries (${UT_TARGET} ${UT_LIBS}
620
+ Threads::Threads GTest::gtest_main GTest::gmock_main benchmark::benchmark )
621
+ else ()
622
+ target_link_libraries (${UT_TARGET} ${UT_LIBS}
623
+ Threads::Threads GTest::gtest_main GTest::gmock_main )
624
+ endif ()
625
+
662
626
if (USE_OPENMP )
663
627
target_link_libraries (${UT_TARGET} OpenMP::OpenMP_CXX )
664
628
endif ()
@@ -668,10 +632,8 @@ IF (ENABLE_GOOGLEBENCH)
668
632
WORKING_DIRECTORY $< TARGET_FILE_DIR:${UT_TARGET} >
669
633
)
670
634
endfunction (AddTest )
671
- endif ()
672
-
673
-
674
635
636
+ endif ()
675
637
676
638
add_subdirectory (source )
677
639
0 commit comments