Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] CMake: deprecate custom processor count logic #868

Merged
merged 2 commits into from
Mar 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming N falls-back to 0, right? ;).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does (reading the links provided helps. :D).

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")