osrm-backend: Fix build on darwin.

This commit is contained in:
Ag 2023-04-12 20:05:05 +05:30
parent 8ca6b762bf
commit 62618152d2
2 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e49fac2..25e3302 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,14 @@ option(ENABLE_GLIBC_WORKAROUND "Workaround GLIBC symbol exports" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+IF(APPLE)
+ set(CMAKE_THREAD_LIBS_INIT "-lpthread")
+ set(CMAKE_HAVE_THREADS_LIBRARY 1)
+ set(CMAKE_USE_WIN32_THREADS_INIT 0)
+ set(CMAKE_USE_PTHREADS_INIT 1)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ENDIF()
+
if(ENABLE_MASON)
# versions in use
set(MASON_BOOST_VERSION "1.65.1")
@@ -405,7 +413,8 @@ endif()
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10")
execute_process(COMMAND xcrun --sdk macosx --show-sdk-path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND uname -m OUTPUT_VARIABLE JAMBA_OSX_NATIVE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(CMAKE_OSX_ARCHITECTURES "x86_64")
+ set(CMAKE_OSX_ARCHITECTURES "${JAMBA_OSX_NATIVE_ARCHITECTURE}")
+ message(STATUS "Set Architecture to ${JAMBA_OSX_NATIVE_ARCHITECTURE} on OS X")
- message(STATUS "Set Architecture to x64 on OS X")
exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})

View file

@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
buildInputs = [ bzip2 libxml2 libzip boost lua luabind tbb expat ];
patches = [ ./darwin.patch ];
env.NIX_CFLAGS_COMPILE = toString [
# Needed with GCC 12
"-Wno-error=stringop-overflow"
@ -28,6 +30,6 @@ stdenv.mkDerivation rec {
description = "Open Source Routing Machine computes shortest paths in a graph. It was designed to run well with map data from the Openstreetmap Project";
license = lib.licenses.bsd2;
maintainers = with lib.maintainers;[ erictapen ];
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
}