Skip to content

Commit 8653be6

Browse files
committed
[ur] macOS fix dylib version & enable color diagnostics
Update the `MAKE_LIBRARY_NAME` macro to match the library naming scheme CMake uses when `VERSION` is specified on macOS, taking the form `lib<name>.<version>.dylib`. Enable color diagnostics for AppleClang. And disable the `CMAKE_FIND_FRAMEWORK` option so that in-tree dylibs are correctly loaded.
1 parent 70459f4 commit 8653be6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ include(CTest)
1414
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1515
include(helpers)
1616

17+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
18+
set(CMAKE_FIND_FRAMEWORK NEVER)
19+
endif()
20+
1721
find_package(Python3 COMPONENTS Interpreter)
1822

1923
set(CMAKE_CXX_STANDARD 17)
@@ -52,7 +56,7 @@ endif()
5256
if(NOT MSVC)
5357
add_compile_options(-fPIC -Wall -Wpedantic
5458
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
55-
$<$<CXX_COMPILER_ID:Clang>:-fcolor-diagnostics>)
59+
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>)
5660
if(UR_DEVELOPER_MODE)
5761
add_compile_options(-Werror -fno-omit-frame-pointer)
5862
endif()

source/common/ur_util.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ inline int ur_getpid(void) { return static_cast<int>(getpid()); }
5757
#define MAKE_LIBRARY_NAME(NAME, VERSION) NAME ".dll"
5858
#else
5959
#define HMODULE void *
60+
#if defined(__APPLE__)
61+
#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME "." VERSION ".dylib"
62+
#else
6063
#define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME ".so." VERSION
6164
#endif
65+
#endif
6266

6367
inline std::string create_library_path(const char *name, const char *path) {
6468
std::string library_path;

0 commit comments

Comments
 (0)