Skip to content

Commit

Permalink
CMakeLists: Introduce AMD64 (to fix x86_64/--native 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 "AMD64" cmake flag, that's set in the `buildme` script
only when compiling for x86_64.

Signed-off-by: Florian Klink <[email protected]>
  • Loading branch information
flokli committed Dec 27, 2020
1 parent 093b30b commit be22dbb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ 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()
# This project is traditionally expecting to be compiled on armv6,7.
# Due to CMake limitations, if the platform (in the host/platform/target
# triplet) this is compiled for differs from that, one of the following targets
# need to be set:
# -DARM64=ON (if compiling for aarch64)
# -DAMD64=ON (if compiling for x86_64)

# broken on anything except ARM32 currently
if(NOT ARM64 AND NOT AMD64)
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 +75,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(NOT ARM64 AND NOT AMD64)
add_subdirectory(interface/khronos)
endif()

Expand All @@ -82,7 +93,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(NOT ARM64 AND NOT AMD64)
add_subdirectory(middleware/openmaxil)
endif()

Expand Down
4 changes: 3 additions & 1 deletion buildme
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
BUILDTYPE=Release
ARCH=$(uname -m)
ARM64=OFF
AMD64=OFF
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake

if [ "$1" = "--debug" ]; then
Expand Down Expand Up @@ -33,10 +34,11 @@ if [ $ARCH = "armv6l" ] || [ $ARCH = "armv7l" ] || [ $ARCH = "aarch64" ]; then
sudo make install
fi
elif [ "$1" = "--native" ]; then
AMD64=ON
# Build natively on the host
mkdir -p build/native/$BUILDSUBDIR
pushd build/native/$BUILDSUBDIR
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../..
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DAMD64=$AMD64../../..
shift
make -j `nproc` $*
else
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(NOT ARM64 AND NOT AMD64)
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(NOT ARM64 AND NOT AMD64)
set (EGL_LIBS brcmGLESv2 brcmEGL)
set (EGL_SOURCES RaspiTex.c RaspiTexUtil.c tga.c)
set (GL_SCENE_SOURCES
Expand Down
2 changes: 1 addition & 1 deletion interface/vmcs_host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_library(vchostif
#add_library(bufman vc_vchi_bufman.c )
set(INSTALL_TARGETS vchostif)

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

0 comments on commit be22dbb

Please sign in to comment.