[PERFORMANCE] Should now perform tests in parallel using the ctest -j flag according to how many cores there are in the system.
parent
0987ae259c
commit
28f7704eea
|
@ -97,10 +97,42 @@ else()
|
|||
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" OFF)
|
||||
endif()
|
||||
mark_as_advanced(GTSAM_SINGLE_TEST_EXE)
|
||||
#Parallelize CTests since ctest supports the -j command
|
||||
#Get number of cores from here: https://cmake.org/pipermail/cmake/2010-October/040122.html
|
||||
if(NOT DEFINED PROCESSOR_COUNT)
|
||||
# Unknown:
|
||||
set(PROCESSOR_COUNT 0)
|
||||
|
||||
# Linux:
|
||||
set(cpuinfo_file "/proc/cpuinfo")
|
||||
if(EXISTS "${cpuinfo_file}")
|
||||
file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
|
||||
list(LENGTH procs PROCESSOR_COUNT)
|
||||
endif()
|
||||
|
||||
# Mac:
|
||||
if(APPLE)
|
||||
find_program(cmd_sys_pro "system_profiler")
|
||||
if(cmd_sys_pro)
|
||||
execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)
|
||||
string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1"
|
||||
PROCESSOR_COUNT "${info}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Windows:
|
||||
if(WIN32)
|
||||
set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PROCESSOR_COUNT)
|
||||
set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")
|
||||
endif()
|
||||
|
||||
# Enable make check (http://www.cmake.org/Wiki/CMakeEmulateMakeCheck)
|
||||
if(GTSAM_BUILD_TESTS)
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --output-on-failure)
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_BUILD_FLAGS} -C $<CONFIGURATION> --output-on-failure)
|
||||
endif()
|
||||
|
||||
# Add examples target
|
||||
|
|
Loading…
Reference in New Issue