Skip to content

Commit

Permalink
[chore] CMake: deprecate custom processor count logic (#868)
Browse files Browse the repository at this point in the history
CMake 2.8.5 shipped with a built-in module.

Also quote `KO_DOWNLOAD_DIR`.

Today it looks like this: https://github.com/Kitware/CMake/blob/283330976f2379eec214bfe1d51a27c29cc1f8fc/Modules/ProcessorCount.cmake

For 3.5 it looks like this: https://github.com/Kitware/CMake/blob/64130a7e793483e24c1d68bdd234f81d5edb2d51/Modules/ProcessorCount.cmake

Either way, same idea but more complete with "automatic" updates & improvements.
  • Loading branch information
Frenzie committed Mar 17, 2019
1 parent 6582561 commit 9dd7333
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions thirdparty/cmake_modules/koreader_thirdparty_common.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
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)
execute_process(COMMAND sysctl -n hw.ncpu OUTPUT_VARIABLE ncpu)
set(PROCESSOR_COUNT "${ncpu}")
endif()

# Windows:
if(WIN32)
set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
endif()
include(ProcessorCount)
ProcessorCount(N)
# 0 if unknown
set(PROCESSOR_COUNT ${N})
endif()

if(APPLE)
Expand Down Expand Up @@ -54,4 +38,4 @@ macro(ep_get_binary_dir varName)
set(${varName} "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-prefix/src/${PROJECT_NAME}-build")
endmacro(ep_get_binary_dir)

set(KO_DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/downloads)
set(KO_DOWNLOAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/downloads")

0 comments on commit 9dd7333

Please sign in to comment.