Skip to content

Commit

Permalink
chore: Integrate build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzybinary committed Mar 24, 2024
1 parent 208d32a commit c02a5dc
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ jobs:
working-directory: ./scripts/build_helpers
- name: Build Dart
run: dart ./scripts/build_helpers/bin/build_dart.dart -v
- uses: threeal/[email protected]
- name: Cmake
uses: threeal/[email protected]
with:
options:
"BUILD_SAMPLES=OFF"
- name: Build Shared Library
run: cmake --build build --config release
- name: Assemble artifacts
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dart-sdk/*
.build/*
build/*
artifacts/*
artifacts/*
depot_tools/*
out/*
.vs
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ cmake_minimum_required(VERSION 3.21)

project(DartSharedLibrary VERSION 0.1)

option(BUILD_SMAPLES "Build the Sampels" ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(DART_DLL_DIR "${PROJECT_SOURCE_DIR}/src")
set(DART_DIR "${PROJECT_SOURCE_DIR}/dart-sdk/sdk")

set(OUTPUT_DEBUG "${OUTPUT_PATH_EXT}/Debug")
set(OUTPUT_RELEASE "${OUTPUT_PATH_EXT}/Release")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/$<$<CONFIG:DEBUG>:${OUTPUT_DEBUG}>$<$<CONFIG:RELEASE>:${OUTPUT_RELEASE}>")
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/out/${OUTPUT_PATH_EXT}/${CMAKE_BUILD_TYPE}")
set(LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/${OUTPUT_PATH_EXT}/${CMAKE_BUILD_TYPE}")

add_subdirectory(src)
add_subdirectory(examples)
if(BUILD_SAMPLES)
add_subdirectory(examples)
endif()
9 changes: 7 additions & 2 deletions examples/realtime_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.21)
project(realtime_example)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

set(CUTE_FRAMEWORK_STATIC ON)
set(CF_FRAMEWORK_BUILD_TESTS OFF)
# Samples Build on Windows Falied
Expand Down Expand Up @@ -32,14 +34,17 @@ if(LINUX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -export-dynamic")
endif()

add_custom_command(TARGET realtime_example POST_BUILD
add_custom_target(ALWAYS_DO_POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:realtime_example> $<TARGET_RUNTIME_DLLS:simple_example_ffi>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/dart $<TARGET_FILE_DIR:realtime_example>/dart
COMMAND_EXPAND_LISTS
)
add_dependencies(realtime_example ALWAYS_DO_POST_BUILD)

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()
endif()

set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/realtime_example")
8 changes: 4 additions & 4 deletions examples/simple_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ add_custom_command(TARGET simple_example POST_BUILD
COMMAND_EXPAND_LISTS
)

add_dependencies(simple_example ALWAYS_DO_POST_BUILD)

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_property(TARGET realtime_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example>)
endif()

set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/simple_example")
4 changes: 4 additions & 0 deletions examples/simple_example_ffi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ add_custom_command(TARGET simple_example_ffi POST_BUILD
COMMAND_EXPAND_LISTS
)

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

target_link_libraries(simple_example_ffi PUBLIC dart_dll)
16 changes: 10 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.21)

project(dart_dll VERSION 0.1.2)

Expand All @@ -14,16 +14,22 @@ add_library(dart_dll SHARED
isolate_setup.cpp
)

target_include_directories(dart_dll PUBLIC
target_include_directories(dart_dll PRIVATE
"${DART_DIR}/runtime"
)

if(WIN32)
set(LIB_PREFIX "lib")
endif()

cmake_path(ABSOLUTE_PATH DART_DIR NORMALIZE OUTPUT_VARIABLE DART_DIR)

MESSAGE(STATUS "Dart SDK ${DART_DIR}")

if(NOT EXISTS "${DART_DIR}/runtime/include/dart_api.h")
MESSAGE(FATAL_ERROR "Missing Dart SDK or not found")
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"
Expand All @@ -41,10 +47,6 @@ target_compile_definitions(dart_dll PRIVATE
)

if(WIN32)
set_property(TARGET dart_dll PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded"
)

target_compile_definitions(dart_dll PRIVATE
_HAS_EXCEPTIONS=0
_SCL_SECURE=0
Expand Down Expand Up @@ -87,6 +89,8 @@ endif()

if(LIB_DART_DEBUG)
target_link_libraries(dart_dll debug ${LIB_DART_DEBUG})
else()
target_link_libraries(dart_dll debug ${LIB_DART_RELEASE})
endif()

target_link_libraries(dart_dll optimized ${LIB_DART_RELEASE})

0 comments on commit c02a5dc

Please sign in to comment.