Skip to content

Commit

Permalink
build: add concurrent level option for make while ninja is used (#2701)
Browse files Browse the repository at this point in the history
Signed-off-by: PragmaTwice <[email protected]>
  • Loading branch information
PragmaTwice authored Jan 1, 2025
1 parent 20bb15d commit ac5b9ac
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ endif()

if(CMAKE_GENERATOR STREQUAL "Ninja")
set(MAKE_COMMAND make)
set(NINJA_MAKE_JOBS 4 CACHE STRING "specify concurrent level while ninja calling make")
set(NINJA_MAKE_JOBS_FLAG -j${NINJA_MAKE_JOBS})
else()
set(MAKE_COMMAND $(MAKE))
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/jemalloc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if(NOT jemalloc_POPULATED)
WORKING_DIRECTORY ${jemalloc_BINARY_DIR}
)
add_custom_target(make_jemalloc
COMMAND ${MAKE_COMMAND}
COMMAND ${MAKE_COMMAND} ${NINJA_MAKE_JOBS_FLAG}
WORKING_DIRECTORY ${jemalloc_BINARY_DIR}
BYPRODUCTS ${jemalloc_BINARY_DIR}/lib/libjemalloc.a
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/lua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if(NOT lua_POPULATED)
set(LUA_CFLAGS "${LUA_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()

add_custom_target(make_lua COMMAND ${MAKE_COMMAND} "CC=${LUA_CXX}" "CFLAGS=${LUA_CFLAGS}" liblua.a
add_custom_target(make_lua COMMAND ${MAKE_COMMAND} "CC=${LUA_CXX}" "CFLAGS=${LUA_CFLAGS}" ${NINJA_MAKE_JOBS_FLAG} liblua.a
WORKING_DIRECTORY ${lua_SOURCE_DIR}/src
BYPRODUCTS ${lua_SOURCE_DIR}/src/liblua.a
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/luajit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if (NOT lua_POPULATED)
set(MACOSX_TARGET "MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif ()

add_custom_target(make_luajit COMMAND ${MAKE_COMMAND} libluajit.a
add_custom_target(make_luajit COMMAND ${MAKE_COMMAND} libluajit.a ${NINJA_MAKE_JOBS_FLAG}
"CFLAGS=${LUA_CFLAGS}" ${MACOSX_TARGET}
WORKING_DIRECTORY ${luajit_SOURCE_DIR}/src
BYPRODUCTS ${luajit_SOURCE_DIR}/src/libluajit.a
Expand Down
2 changes: 1 addition & 1 deletion cmake/lz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if(NOT lz4_POPULATED)
set(APPLE_FLAG "CFLAGS=-isysroot ${CMAKE_OSX_SYSROOT}")
endif()

add_custom_target(make_lz4 COMMAND ${MAKE_COMMAND} CC=${CMAKE_C_COMPILER} ${APPLE_FLAG} liblz4.a
add_custom_target(make_lz4 COMMAND ${MAKE_COMMAND} CC=${CMAKE_C_COMPILER} ${NINJA_MAKE_JOBS_FLAG} ${APPLE_FLAG} liblz4.a
WORKING_DIRECTORY ${lz4_SOURCE_DIR}/lib
BYPRODUCTS ${lz4_SOURCE_DIR}/lib/liblz4.a
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/zstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if(NOT zstd_POPULATED)
set(APPLE_FLAG "CFLAGS=-isysroot ${CMAKE_OSX_SYSROOT}")
endif()

add_custom_target(make_zstd COMMAND ${MAKE_COMMAND} CC=${CMAKE_C_COMPILER} ${APPLE_FLAG} libzstd.a
add_custom_target(make_zstd COMMAND ${MAKE_COMMAND} ${NINJA_MAKE_JOBS_FLAG} CC=${CMAKE_C_COMPILER} ${APPLE_FLAG} libzstd.a
WORKING_DIRECTORY ${zstd_SOURCE_DIR}/lib
BYPRODUCTS ${zstd_SOURCE_DIR}/lib/libzstd.a
)
Expand Down

0 comments on commit ac5b9ac

Please sign in to comment.