Skip to content

Commit

Permalink
Merge pull request #514 from luxonis/build_from_sources_error
Browse files Browse the repository at this point in the history
Fix build from sources error
  • Loading branch information
themarpe authored Jul 6, 2022
2 parents c98471e + f8bbd42 commit a6e7319
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,19 @@ set(PROJECT_EXPORT_GROUP "${PROJECT_NAME}Targets")
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --is-inside-work-tree
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE DEPTHAI_DOWNLOADED_SOURCES
OUTPUT_QUIET ERROR_QUIET
RESULT_VARIABLE _git_root_dir_error
OUTPUT_VARIABLE _git_root_dir
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(DEPTHAI_DOWNLOADED_SOURCES ON)
if(_git_root_dir_error EQUAL 0 AND "${_git_root_dir}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
set(DEPTHAI_DOWNLOADED_SOURCES OFF)
endif()
message(DEBUG "Git root dir (${_git_root_dir_error}): ${_git_root_dir}")
message(DEBUG "DepthAI as downloaded sources: ${DEPTHAI_DOWNLOADED_SOURCES}")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
Expand Down
11 changes: 9 additions & 2 deletions shared/depthai-bootloader-shared.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(GIT_FOUND AND NOT DEPTHAI_DOWNLOADED_SOURCES)
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(SUBSTRING ${statusCommit} 0 1 status)
if(${status} STREQUAL "-")
if("${status}" STREQUAL "-")
message(FATAL_ERROR "Submodule 'depthai-bootloader-shared' not initialized/updated. Run 'git submodule update --init --recursive' first")
endif()
endif()
Expand All @@ -49,4 +49,11 @@ if(GIT_FOUND AND NOT DEPTHAI_DOWNLOADED_SOURCES)
else()
set(DEPTHAI_BOOTLOADER_SHARED_COMMIT_FOUND FALSE)
endif()
endif()
endif()

# Make sure files exist
foreach(source_file ${DEPTHAI_BOOTLOADER_SHARED_SOURCES})
if(NOT EXISTS ${source_file})
message(FATAL_ERROR "depthai-bootloader-shared submodule files missing. Make sure to download prepackaged release instead of \"Source code\" on GitHub. Example: depthai-core-vX.Y.Z.tar.gz")
endif()
endforeach()
12 changes: 10 additions & 2 deletions shared/depthai-shared.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if(GIT_FOUND AND NOT DEPTHAI_DOWNLOADED_SOURCES)
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(SUBSTRING ${statusCommit} 0 1 status)
if(${status} STREQUAL "-")
if("${status}" STREQUAL "-")
message(FATAL_ERROR "Submodule 'depthai-shared' not initialized/updated. Run 'git submodule update --init --recursive' first")
endif()
endif()
Expand All @@ -55,4 +55,12 @@ if(GIT_FOUND AND NOT DEPTHAI_DOWNLOADED_SOURCES)
else()
set(DEPTHAI_SHARED_COMMIT_FOUND FALSE)
endif()
endif()
endif()

# Make sure files exist
foreach(source_file ${DEPTHAI_SHARED_SOURCES})
message(STATUS "Checking file: ${source_file}")
if(NOT EXISTS ${source_file})
message(FATAL_ERROR "depthai-shared submodule files missing. Make sure to download prepackaged release instead of \"Source code\" on GitHub. Example: depthai-core-vX.Y.Z.tar.gz")
endif()
endforeach()

0 comments on commit a6e7319

Please sign in to comment.