From 15d3c121393bd54c66b5d2a93371f3aec42c64e3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 3 Apr 2014 13:42:11 +0100 Subject: [PATCH] Fixed for FreeBSD (From Gerald Laplanche) --- CMakeLists.txt | 12 ++++++++---- simgear/canvas/ShivaVG/src/shDefs.h | 2 +- simgear/timing/timestamp.cxx | 7 +++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 364aec23..c2ad568b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,7 +260,9 @@ check_cxx_source_compiles( if(HAVE_DLFCN_H) check_library_exists(dl dlerror "" HAVE_DL) - set(DL_LIBRARY "dl") + if(HAVE_DL) + set(DL_LIBRARY "dl") + endif() endif() SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows") @@ -333,9 +335,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}") -include_directories(${PROJECT_SOURCE_DIR}) -include_directories(${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) -include_directories(${PROJECT_BINARY_DIR}/simgear) +# use BEFORE to ensure local directories are used first, +# ahead of system-installed libs +include_directories(BEFORE ${PROJECT_SOURCE_DIR}) +include_directories(BEFORE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) +include_directories(BEFORE ${PROJECT_BINARY_DIR}/simgear) include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} diff --git a/simgear/canvas/ShivaVG/src/shDefs.h b/simgear/canvas/ShivaVG/src/shDefs.h index d0f3bb84..ea5d59c8 100644 --- a/simgear/canvas/ShivaVG/src/shDefs.h +++ b/simgear/canvas/ShivaVG/src/shDefs.h @@ -34,7 +34,7 @@ #include #include -#ifndef VG_API_MACOSX +#if !defined(VG_API_MACOSX) && !defined(__FreeBSD__) # include #endif diff --git a/simgear/timing/timestamp.cxx b/simgear/timing/timestamp.cxx index 297f665a..24cad841 100644 --- a/simgear/timing/timestamp.cxx +++ b/simgear/timing/timestamp.cxx @@ -139,7 +139,9 @@ void SGTimeStamp::stamp() { // the timer tick) accuracy which is too bad to catch 60Hz... bool SGTimeStamp::sleepUntil(const SGTimeStamp& abstime) { -#if defined(_POSIX_TIMERS) && (0 < _POSIX_TIMERS) + // FreeBSD is missing clock_nanosleep, see + // https://wiki.freebsd.org/FreeBSD_and_Standards +#if defined(_POSIX_TIMERS) && (0 < _POSIX_TIMERS) && !defined(__FreeBSD__) SGTimeStamp abstimeForSleep = abstime; // Always undersleep by resolution of the clock @@ -234,7 +236,8 @@ bool SGTimeStamp::sleepUntil(const SGTimeStamp& abstime) bool SGTimeStamp::sleepFor(const SGTimeStamp& reltime) { -#if defined(_POSIX_TIMERS) && (0 < _POSIX_TIMERS) + // see comment above regarding FreeBSD +#if defined(_POSIX_TIMERS) && (0 < _POSIX_TIMERS) && !defined(__FreeBSD__) struct timespec ts; ts.tv_sec = reltime._sec; ts.tv_nsec = reltime._nsec; -- 2.39.5