Determine posix timer availability by function availability

To avoid having to whitelist every os starting to implement posix
timer API just detect if the functions are available.
This commit is contained in:
Armin Novak 2018-05-02 08:40:30 +02:00
parent a03c0d88d5
commit 60bf33f79d
3 changed files with 12 additions and 8 deletions

View File

@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include(CheckFunctionExists)
set(WINPR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(WINPR_SRCS "")
set(WINPR_LIBS "")
@ -67,6 +69,16 @@ macro (winpr_definition_add)
set (WINPR_DEFINITIONS ${WINPR_DEFINITIONS} PARENT_SCOPE)
endmacro()
set(CMAKE_REQUIRED_LIBRARIES rt)
check_function_exists(timer_create TIMER_CREATE)
check_function_exists(timer_delete TIMER_DELETE)
check_function_exists(timer_settime TIMER_SETTIME)
check_function_exists(timer_gettime TIMER_GETTIME)
if (TIMER_CREATE AND TIMER_DELETE AND TIMER_SETTIME AND TIMER_GETTIME)
add_definitions(-DWITH_POSIX_TIMER)
winpr_library_add(rt)
endif()
if (ANDROID)
winpr_library_add(log)
endif()

View File

@ -35,10 +35,6 @@ if(FREEBSD)
winpr_library_add(${EPOLLSHIM_LIBS})
endif()
if((NOT WIN32) AND (NOT APPLE) AND (NOT ANDROID) AND (NOT OPENBSD))
winpr_library_add(rt)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -28,10 +28,6 @@
#include <winpr/synch.h>
#ifdef __linux__
#define WITH_POSIX_TIMER 1
#endif
#include "../handle/handle.h"
#ifndef _WIN32