feat: added compilable cmake for core, added method to get physical core count.
This commit is contained in:
parent
1c6b515826
commit
734aee7d18
6 changed files with 113 additions and 0 deletions
72
cmake/BuildPJProject.cmake
Normal file
72
cmake/BuildPJProject.cmake
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
include(FetchContent)
|
||||
|
||||
set(PJ_VERSION_TAG 2.16)
|
||||
|
||||
|
||||
|
||||
set(PJ_REPO https://github.com/pjsip/pjproject.git)
|
||||
set(PJ_INSTALL_PATH ${PROJECT_SOURCE_DIR}/bin/pjproject/)
|
||||
|
||||
set(PJ_CONFIG_CMD "configure --prefix=${PJ_INSTALL_PATH}")
|
||||
set(PJ_BUILD_CMD "make dep; make -j")
|
||||
|
||||
message(STATUS "PJProject build information:")
|
||||
message(STATUS "Repo: ${PJ_REPO}")
|
||||
message(STATUS "Version: ${PJ_VERSION_TAG}")
|
||||
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
|
||||
FetchContent_Declare(
|
||||
PJProject
|
||||
GIT_REPOSITORY ${PJ_REPO}
|
||||
GIT_TAG ${PJ_VERSION_TAG}
|
||||
GIT_PROGRESS ON
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(PJProject)
|
||||
|
||||
if (NOT pjproject_POPULATED)
|
||||
FetchContent_Populate(PJProject)
|
||||
endif()
|
||||
|
||||
message(STATUS "PJProject sources at: ${pjproject_SOURCE_DIR}")
|
||||
message(STATUS "Start building PJProject...")
|
||||
|
||||
execute_process(COMMAND "./configure --disable-pjsua2" WORKING_DIRECTORY ${pjproject_SOURCE_DIR} OUTPUT_VARIABLE exec_output_msgs)
|
||||
message("${exec_output_msgs}")
|
||||
execute_process(COMMAND make dep WORKING_DIRECTORY ${pjproject_SOURCE_DIR} OUTPUT_VARIABLE exec_output_msgs)
|
||||
message("${exec_output_msgs}")
|
||||
execute_process(COMMAND make WORKING_DIRECTORY ${pjproject_SOURCE_DIR} OUTPUT_VARIABLE exec_output_msgs)
|
||||
message("${exec_output_msgs}")
|
||||
|
||||
file(GLOB PJ_LIB "${pjproject_SOURCE_DIR}/pjlib/lib/*pj-*")
|
||||
if (NOT PJ_LIB)
|
||||
message(FATAL_ERROR "Couldn't find pj-lib compiled library.")
|
||||
endif()
|
||||
|
||||
message(STATUS "pj-lib lib at: ${PJSUA_LIB}")
|
||||
|
||||
file(GLOB PJSUA_LIB "${pjproject_SOURCE_DIR}/pjsip/lib/*pjsua-*")
|
||||
|
||||
if (NOT PJSUA_LIB)
|
||||
message(FATAL_ERROR "Couldn't find pjsua compiled library.")
|
||||
endif()
|
||||
|
||||
message(STATUS "pjsua lib at: ${PJSUA_LIB}")
|
||||
|
||||
add_library(pjproject::pj STATIC IMPORTED)
|
||||
set_target_properties(pjproject::pj PROPERTIES
|
||||
IMPORTED_LOCATION ${PJ_LIB}
|
||||
)
|
||||
|
||||
add_library(pjproject::pjsua STATIC IMPORTED)
|
||||
set_target_properties(pjproject::pjsua PROPERTIES
|
||||
IMPORTED_LOCATION ${PJSUA_LIB}
|
||||
)
|
||||
|
||||
target_include_directories(pjproject::pjsua
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${pjproject_SOURCE_DIR}/pjsip/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(src)
|
||||
13
core/src/CMakeLists.txt
Normal file
13
core/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
set(CORE_SRC
|
||||
core.c
|
||||
)
|
||||
|
||||
list(TRANSFORM CORE_SRC PREPEND ${CMAKE_CURRENT_LIST_DIR}/)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
add_library(pigeon-core ${CORE_SRC})
|
||||
target_include_directories(pigeon-core PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src)
|
||||
target_link_libraries(pigeon-core OpenSSL::SSL)
|
||||
1
core/src/core.c
Normal file
1
core/src/core.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
0
core/src/core.h
Normal file
0
core/src/core.h
Normal file
26
core/src/thread_util.h
Normal file
26
core/src/thread_util.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef THREAD_UTIL_H
|
||||
#define THREAD_UTIL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Method return count of physical cores in system
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
|
||||
size_t get_core_count(void) {
|
||||
SYSTEM_INFO sys_info;
|
||||
GetSystemInfo(&sys_info);
|
||||
|
||||
return (size_t)sys_info.dwNumberOfProcessors;
|
||||
}
|
||||
#elif defined(__unix__) || defined(__unix) || \
|
||||
(defined(__APPLE__) && defined(__MACH__))
|
||||
#include <unistd.h>
|
||||
|
||||
size_t get_core_count(void) { return (size_t)sysconf(_SC_NPROCESSORS_ONLN); }
|
||||
#else
|
||||
#error "Get core count feature not realised for current platform."
|
||||
#endif
|
||||
|
||||
#endif // !THREAD_UTIL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue