Skip to content

Commit

Permalink
CMakeLists: Introduce ARM32 (to fix x86_64 builds)
Browse files Browse the repository at this point in the history
CMakeLists.txt currently assumes everything not ARM64 to be ARM32. When
compiling on x86_64-linux, this tries to build some binaries that are
arm(32) only.

Some tools make some sense to use even on non-ARM workstations. For
example, `dtmerge` can be used to merge .dtb files with overlays on a
x86_64 machine (while mounting an sdcard for example).

This introduces a "ARM32" variable, that's set in the `buildme` script
only when compiling for ARM32.

Signed-off-by: Florian Klink <[email protected]>
  • Loading branch information
flokli committed Dec 27, 2020
1 parent 093b30b commit 3ebe07b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ SET(PROJECT_VER_PATCH 0)
SET(PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
SET(PROJECT_APIVER "${PROJECT_VER}")

if(ARM64)
set(BUILD_MMAL FALSE)
set(BUILD_MMAL_APPS FALSE)
else()
# broken on non-ARM(64) currently
if(ARM32)
set(BUILD_MMAL TRUE)
set(BUILD_MMAL_APPS TRUE)
else()
set(BUILD_MMAL FALSE)
set(BUILD_MMAL_APPS FALSE)
endif()

set(vmcs_root ${PROJECT_SOURCE_DIR})
get_filename_component(VIDEOCORE_ROOT . ABSOLUTE)

Expand Down Expand Up @@ -66,7 +68,9 @@ endif()
add_subdirectory(interface/vcos)
add_subdirectory(interface/vmcs_host)
add_subdirectory(interface/vchiq_arm)
if(NOT ARM64)

# The khronos libraries include arm32 assembly
if(ARM32)
add_subdirectory(interface/khronos)
endif()

Expand All @@ -82,7 +86,8 @@ if(BUILD_MMAL_APPS)
add_subdirectory(host_applications/android/apps/vidtex)
endif(BUILD_MMAL_APPS)

if(NOT ARM64)
# ARM32 only, as it needs the khronos libraries
if(ARM32)
add_subdirectory(middleware/openmaxil)
endif()

Expand Down
6 changes: 4 additions & 2 deletions buildme
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
BUILDTYPE=Release
ARCH=$(uname -m)
ARM32=ON
ARM64=OFF
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake

Expand All @@ -10,6 +11,7 @@ if [ "$1" = "--debug" ]; then
fi

if [ "$1" = "--aarch64" ]; then
ARM32=OFF
ARM64=ON
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/aarch64-linux-gnu.cmake
shift
Expand All @@ -21,7 +23,7 @@ if [ $ARCH = "armv6l" ] || [ $ARCH = "armv7l" ] || [ $ARCH = "aarch64" ]; then
# Native compile on the Raspberry Pi
mkdir -p build/raspberry/$BUILDSUBDIR
pushd build/raspberry/$BUILDSUBDIR
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../..
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM32=$ARM32 -DARM64=$ARM64 ../../..
if [ $ARCH = "armv6l" ]; then
make
else
Expand All @@ -43,7 +45,7 @@ else
# Cross compile on a more capable machine
mkdir -p build/arm-linux/$BUILDSUBDIR
pushd build/arm-linux/$BUILDSUBDIR
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../..
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM32=$ARM32 -DARM64=$ARM64 ../../..
make -j `nproc`

if [ "$1" != "" ]; then
Expand Down
2 changes: 1 addition & 1 deletion host_applications/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ add_subdirectory(libs/bcm_host)
add_subdirectory(apps/gencmd)
add_subdirectory(apps/tvservice)
add_subdirectory(apps/vcmailbox)
if(NOT ARM64)
if(ARM32)
add_subdirectory(apps/raspicam)
add_subdirectory(libs/sm)
add_subdirectory(apps/smem)
Expand Down
2 changes: 1 addition & 1 deletion host_applications/linux/apps/raspicam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set (COMMON_SOURCES
RaspiGPS.c
libgps_loader.c)

if(NOT ARM64)
if(ARM32)
set (EGL_LIBS brcmGLESv2 brcmEGL)
set (EGL_SOURCES RaspiTex.c RaspiTexUtil.c tga.c)
set (GL_SCENE_SOURCES
Expand Down
16 changes: 8 additions & 8 deletions interface/vmcs_host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ add_library(vchostif
#add_library(bufman vc_vchi_bufman.c )
set(INSTALL_TARGETS vchostif)

if(NOT ARM64)
# OpenMAX/IL component service
add_library(vcilcs
vcilcs.c vcilcs_in.c vcilcs_out.c vcilcs_common.c)

# ILCS pulls in EGL for the ILCS/EGL surface API support
target_link_libraries(vcilcs brcmEGL brcmGLESv2 khrn_client vchiq_arm vcos)
set(INSTALL_TARGETS ${INSTALL_TARGETS} vcilcs)
if(ARM32 OR ARM64)
# OpenMAX/IL component service
add_library(vcilcs
vcilcs.c vcilcs_in.c vcilcs_out.c vcilcs_common.c)

# ILCS pulls in EGL for the ILCS/EGL surface API support
target_link_libraries(vcilcs brcmEGL brcmGLESv2 khrn_client vchiq_arm vcos)
set(INSTALL_TARGETS ${INSTALL_TARGETS} vcilcs)
endif()

# vchostif needs ilcore as well (vmcs_main pulls it in)
Expand Down

0 comments on commit 3ebe07b

Please sign in to comment.