Skip to content

Commit

Permalink
Fix builds on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzybinary committed Aug 10, 2024
1 parent b24bdd9 commit a3ffddd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
10 changes: 7 additions & 3 deletions examples/realtime_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ if(LINUX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -export-dynamic")
endif()

if (WIN32)
add_custom_command(TARGET realtime_example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:realtime_example> $<TARGET_FILE_DIR:realtime_example>
COMMAND_EXPAND_LISTS
)
endif()

add_custom_command(TARGET realtime_example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:realtime_example> $<TARGET_RUNTIME_DLLS:realtime_example>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/dart/ $<TARGET_FILE_DIR:realtime_example>/dart
COMMAND_EXPAND_LISTS
)
Expand All @@ -44,5 +50,3 @@ target_link_libraries(realtime_example PUBLIC dart_dll cute)
if (MSVC)
set_property(TARGET realtime_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:realtime_example>)
endif()

set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/realtime_example")
14 changes: 9 additions & 5 deletions examples/simple_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ target_include_directories(simple_example PRIVATE
"${DART_DIR}/runtime/include"
)

if(WIN32)
add_custom_command(TARGET simple_example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:simple_example> $<TARGET_FILE_DIR:simple_example>
COMMAND_EXPAND_LISTS
)
endif()

add_custom_command(TARGET simple_example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:simple_example> $<TARGET_RUNTIME_DLLS:simple_example>
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:simple_example> ${PROJECT_SOURCE_DIR}/hello_world.dart
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/hello_world.dart $<TARGET_FILE_DIR:simple_example>
COMMAND_EXPAND_LISTS
)

target_link_libraries(simple_example PUBLIC dart_dll)

if (MSVC)
set_property(TARGET simple_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example>)
endif()

set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/simple_example")
endif()
12 changes: 8 additions & 4 deletions examples/simple_example_ffi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ target_include_directories(simple_example_ffi PRIVATE
"${DART_DIR}/runtime/include"
)

if(WIN32)
add_custom_command(TARGET simple_example_ffi POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:simple_example_ffi> $<TARGET_FILE_DIR:simple_example_ffi>
COMMAND_EXPAND_LISTS
)
endif()

add_custom_command(TARGET simple_example_ffi POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:simple_example_ffi> $<TARGET_RUNTIME_DLLS:simple_example_ffi>
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:simple_example_ffi> ${PROJECT_SOURCE_DIR}/hello_world_ffi.dart
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/hello_world_ffi.dart $<TARGET_FILE_DIR:simple_example_ffi>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/.dart_tool $<TARGET_FILE_DIR:simple_example_ffi>/.dart_tool
COMMAND_EXPAND_LISTS
)
Expand All @@ -21,5 +27,3 @@ target_link_libraries(simple_example_ffi PUBLIC dart_dll)
if (MSVC)
set_property(TARGET simple_example_ffi PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example_ffi>)
endif()

set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/simple_example_ffi")
20 changes: 15 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ endif()

find_library(LIB_DART_DEBUG
NAMES "${LIB_PREFIX}dart"
HINTS "${DART_DIR}/out/DebugX64/obj/runtime/bin" "${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin"
HINTS "${DART_DIR}/out/DebugX64/obj/runtime/bin"
"${DART_DIR}/xcodebuild/DebugX64/obj/runtime/bin"
"${DART_DIR}/xcodebuild/DebugARM64/obj/runtime/bin"
)

find_library(LIB_DART_RELEASE
NAMES "${LIB_PREFIX}dart"
HINTS "${DART_DIR}/out/ReleaseX64/obj/runtime/bin" "${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin"
HINTS "${DART_DIR}/out/ReleaseX64/obj/runtime/bin"
"${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin"
"${DART_DIR}/xcodebuild/ReleaseARM64/obj/runtime/bin"
)

target_compile_definitions(dart_dll PRIVATE
Expand Down Expand Up @@ -84,9 +88,15 @@ elseif(LINUX)
${CMAKE_DL_LIBS}
)
elseif(APPLE)
set(CMAKE_C_COMPILER "${DART_DIR}/buildtools/mac-x64/clang/bin/clang")
set(CMAKE_CXX_COMPILER "${DART_DIR}/buildtools/mac-x64/clang/bin/clang++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib++ ${DART_DIR}/buildtools/mac-x64/clang/lib/libc++.a -framework Cocoa -framework QuartzCore -framework Security")
if(CMAKE_APPLE_SILICON_PROCESSOR STREQUAL "arm64")
set(CMAKE_C_COMPILER "${DART_DIR}/buildtools/mac-arm64/clang/bin/clang")
set(CMAKE_CXX_COMPILER "${DART_DIR}/buildtools/mac-arm64/clang/bin/clang++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib++ ${DART_DIR}/buildtools/mac-arm64/clang/lib/libc++.a -framework Cocoa -framework QuartzCore -framework Security")
else()
set(CMAKE_C_COMPILER "${DART_DIR}/buildtools/mac-x64/clang/bin/clang")
set(CMAKE_CXX_COMPILER "${DART_DIR}/buildtools/mac-x64/clang/bin/clang++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib++ ${DART_DIR}/buildtools/mac-x64/clang/lib/libc++.a -framework Cocoa -framework QuartzCore -framework Security")
endif()
endif()

if(LIB_DART_DEBUG)
Expand Down

0 comments on commit a3ffddd

Please sign in to comment.