From 62618152d22963c5b6ad3439b70049c4b01e1b98 Mon Sep 17 00:00:00 2001 From: Ag Date: Wed, 12 Apr 2023 20:05:05 +0530 Subject: [PATCH] osrm-backend: Fix build on darwin. --- pkgs/servers/osrm-backend/darwin.patch | 30 ++++++++++++++++++++++++++ pkgs/servers/osrm-backend/default.nix | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 pkgs/servers/osrm-backend/darwin.patch diff --git a/pkgs/servers/osrm-backend/darwin.patch b/pkgs/servers/osrm-backend/darwin.patch new file mode 100644 index 000000000000..0aa57e4e1b81 --- /dev/null +++ b/pkgs/servers/osrm-backend/darwin.patch @@ -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}) diff --git a/pkgs/servers/osrm-backend/default.nix b/pkgs/servers/osrm-backend/default.nix index 452163ee82cf..b76db692a783 100644 --- a/pkgs/servers/osrm-backend/default.nix +++ b/pkgs/servers/osrm-backend/default.nix @@ -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; }; }