Skip to content

Commit 7dbb27b

Browse files
authored
fix DART_EXECUTABLE lookup logic in CMakeLists (#367)
1 parent 9cb2126 commit 7dbb27b

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

packages/opencv_core/src/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ endmacro()
1616
function(_parse_dartcv_cmake_vars)
1717
# Generate module config from pubspec.yaml using Dart script
1818
# The step should not be mendatary for better user experience
19-
if(WIN32)
19+
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
2020
find_program(DART_EXECUTABLE dart.bat)
21-
else()
21+
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
2222
find_program(DART_EXECUTABLE dart)
23+
else()
24+
message(FATAL_ERROR "Current host system ${CMAKE_HOST_SYSTEM_NAME} is not supported!")
2325
endif()
2426

2527
if(NOT DART_EXECUTABLE)
@@ -59,9 +61,9 @@ function(_parse_dartcv_cmake_vars)
5961

6062
message(STATUS "Generate command output:\n${_output}")
6163

62-
if(_error)
63-
message(FATAL_ERROR "Error while running dartcv4:gen_cmake_vars: ${_error}")
64-
endif(_error)
64+
if(_error OR (NOT _output))
65+
message(FATAL_ERROR "Error while running dartcv4:gen_cmake_vars, error: ${_error}, output: ${_output}")
66+
endif()
6567

6668
string(REGEX MATCH "###DARTCV_GEN_CMAKE_VAR_BEGIN###\n.*###DARTCV_GEN_CMAKE_VAR_END###" _content ${_output})
6769

@@ -100,7 +102,7 @@ set(PROJECT_VERSION "${_version_project}")
100102

101103
# Flutter doesn't support build android-x86, disable here
102104
# https://docs.flutter.dev/deployment/android#what-are-the-supported-target-architectures
103-
if(ANDROID AND(DEFINED ANDROID_ABI))
105+
if(ANDROID AND (DEFINED ANDROID_ABI))
104106
if(${ANDROID_ABI} STREQUAL "x86")
105107
message(STATUS "Unsupported ABI: x86")
106108
return()

packages/opencv_dart/src/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ endmacro()
1616
function(_parse_dartcv_cmake_vars)
1717
# Generate module config from pubspec.yaml using Dart script
1818
# The step should not be mendatary for better user experience
19-
if(WIN32)
19+
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
2020
find_program(DART_EXECUTABLE dart.bat)
21-
else()
21+
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
2222
find_program(DART_EXECUTABLE dart)
23+
else()
24+
message(FATAL_ERROR "Current host system ${CMAKE_HOST_SYSTEM_NAME} is not supported!")
2325
endif()
2426

2527
if(NOT DART_EXECUTABLE)
@@ -59,9 +61,9 @@ function(_parse_dartcv_cmake_vars)
5961

6062
message(STATUS "Generate command output:\n${_output}")
6163

62-
if(_error)
63-
message(FATAL_ERROR "Error while running dartcv4:gen_cmake_vars: ${_error}")
64-
endif(_error)
64+
if(_error OR (NOT _output))
65+
message(FATAL_ERROR "Error while running dartcv4:gen_cmake_vars, error: ${_error}, output: ${_output}")
66+
endif()
6567

6668
string(REGEX MATCH "###DARTCV_GEN_CMAKE_VAR_BEGIN###\n.*###DARTCV_GEN_CMAKE_VAR_END###" _content ${_output})
6769

@@ -100,7 +102,7 @@ set(PROJECT_VERSION "${_version_project}")
100102

101103
# Flutter doesn't support build android-x86, disable here
102104
# https://docs.flutter.dev/deployment/android#what-are-the-supported-target-architectures
103-
if(ANDROID AND(DEFINED ANDROID_ABI))
105+
if(ANDROID AND (DEFINED ANDROID_ABI))
104106
if(${ANDROID_ABI} STREQUAL "x86")
105107
message(STATUS "Unsupported ABI: x86")
106108
return()

0 commit comments

Comments
 (0)