Skip to content

Commit

Permalink
Fixed cross build for QNX
Browse files Browse the repository at this point in the history
  • Loading branch information
pablorcum authored May 28, 2021
1 parent 32606e5 commit c32ebe6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,23 @@ if (ECAL_THIRDPARTY_BUILD_PROTOBUF)
)
endif()

if (NOT TARGET protoc_imported AND CMAKE_CROSSCOMPILING)
if (NOT TARGET protoc AND CMAKE_CROSSCOMPILING)
# In cross compile scenario, we don't build protoc, so we need
# to find and import it so downstream usage will use the host compiler.

# find_program will search the host paths if CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
# is configured correctly (see toolchain file)
find_program(protoc_path NAMES protoc REQUIRED)
add_executable(protoc_imported IMPORTED)
set_target_properties(protoc_imported PROPERTIES IMPORTED_LOCATION ${protoc_path})
set_target_properties(protoc_imported PROPERTIES IMPORTED_GLOBAL TRUE)
add_executable(protoc IMPORTED)
set_target_properties(protoc PROPERTIES IMPORTED_LOCATION ${protoc_path})
set_target_properties(protoc PROPERTIES IMPORTED_GLOBAL TRUE)

add_executable(protobuf::protoc ALIAS protoc_imported)
set(Protobuf_PROTOC_EXECUTABLE protoc_imported)
add_executable(protobuf::protoc ALIAS protoc)

message(STATUS "protoc has been automatically imported from ${protoc_path} for crosscompiling.")

elseif(NOT TARGET protobuf::protoc)
add_executable(protobuf::protoc ALIAS protoc)
set(Protobuf_PROTOC_EXECUTABLE protoc)
endif()

get_target_property(is_imported protoc IMPORTED)
Expand All @@ -174,6 +175,7 @@ if (ECAL_THIRDPARTY_BUILD_PROTOBUF)
)
endif()

set(Protobuf_PROTOC_EXECUTABLE protoc)
set(Protobuf_VERSION 3.11.4)
endif()

Expand Down

0 comments on commit c32ebe6

Please sign in to comment.