Some CMake updates to build correctly on Raspberry Pi.

Also some other general CMake cleanups.
This commit is contained in:
Leon Styhre 2021-07-08 18:05:32 +02:00
parent a62be38c85
commit 9a53ad0463
2 changed files with 21 additions and 57 deletions

View file

@ -14,8 +14,6 @@ set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Show verbose compiler output" FORCE)
# Package type to use for CPack on Linux. # Package type to use for CPack on Linux.
set(LINUX_CPACK_GENERATOR "DEB" CACHE STRING "CPack generator, DEB or RPM") set(LINUX_CPACK_GENERATOR "DEB" CACHE STRING "CPack generator, DEB or RPM")
set(VLC_PLAYER OFF CACHE BOOL "Whether to build with the VLC video player")
# Add local find modules to the CMake path. # Add local find modules to the CMake path.
list(APPEND CMAKE_MODULE_PATH list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utils ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utils
@ -26,38 +24,24 @@ option(GLES "Set to ON if targeting Embedded OpenGL" ${GLES})
option(GL "Set to ON if targeting Desktop OpenGL" ${GL}) option(GL "Set to ON if targeting Desktop OpenGL" ${GL})
option(RPI "Set to ON to enable Raspberry Pi specific build" ${RPI}) option(RPI "Set to ON to enable Raspberry Pi specific build" ${RPI})
option(CEC "Set to ON to enable CEC" ${CEC}) option(CEC "Set to ON to enable CEC" ${CEC})
option(VLC_PLAYER "Set to ON to build the VLC-based video player" ${VLC_PLAYER})
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
# OpenGL setup. # OpenGL setup.
if(GLES)
set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used")
elseif(GL)
set(GLSystem "Desktop OpenGL" CACHE STRING "The OpenGL system to be used")
# Check if we're running on a Raspberry Pi. # Check if we're running on a Raspberry Pi.
elseif(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/bcm_host.h") if(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/bcm_host.h")
MESSAGE("bcm_host.h found") message("-- Building on a Raspberry Pi (bcm_host.h found)")
set(BCMHOST found) # Setting BCMHOST seems to break OpenGL ES on the RPi 4?
#set(BCMHOST found)
# Simply set RPI instead to enable the RPi-specific parts of the code.
set(RPI ON)
set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used")
elseif(GLES)
# Check if we're running on OSMC Vero4K.
elseif(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vero3/lib/libMali.so")
MESSAGE("libMali.so found")
set(VERO4K found)
set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used")
# Check if we're running on olinuxino / odroid / etc.
elseif(EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/libMali.so" OR
EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf/libMali.so" OR
EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/aarch64-linux-gnu/libMali.so" OR
EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf/mali-egl/libmali.so" OR
EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf/libmali.so")
MESSAGE("libMali.so found")
set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used")
else() else()
set(GLSystem "Desktop OpenGL" CACHE STRING "The OpenGL system to be used") set(GLSystem "Desktop OpenGL" CACHE STRING "The OpenGL system to be used")
endif(GLES) endif()
set_property(CACHE GLSystem PROPERTY STRINGS "Desktop OpenGL" "Embedded OpenGL") set_property(CACHE GLSystem PROPERTY STRINGS "Desktop OpenGL" "Embedded OpenGL")
@ -80,7 +64,7 @@ if(NOT WIN32)
find_package(Pugixml REQUIRED) find_package(Pugixml REQUIRED)
find_package(RapidJSON REQUIRED) find_package(RapidJSON REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
if(VLC_PLAYER OR RPI) if(VLC_PLAYER)
find_package(VLC REQUIRED) find_package(VLC REQUIRED)
endif() endif()
endif() endif()
@ -193,11 +177,6 @@ endif()
if(DEFINED BCMHOST OR RPI) if(DEFINED BCMHOST OR RPI)
add_definitions(-D_RPI_) add_definitions(-D_RPI_)
add_definitions(-DBUILD_VLC_PLAYER)
endif()
if(DEFINED VERO4K)
add_definitions(-D_VERO4K_)
endif() endif()
if(DEFINED libCEC_FOUND) if(DEFINED libCEC_FOUND)
@ -240,7 +219,7 @@ set(COMMON_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/external/CImg ${CMAKE_CURRENT_SOURCE_DIR}/external/CImg
${CMAKE_CURRENT_SOURCE_DIR}/external/nanosvg/src ${CMAKE_CURRENT_SOURCE_DIR}/external/nanosvg/src
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src) ${CMAKE_CURRENT_SOURCE_DIR}/es-core/src)
if(VLC_PLAYER OR RPI) if(VLC_PLAYER)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${VLC_INCLUDE_DIR}) set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${VLC_INCLUDE_DIR})
endif() endif()
@ -250,7 +229,6 @@ if(WIN32)
if(NOT EXISTS ${WIN32_INCLUDE_DIR}) if(NOT EXISTS ${WIN32_INCLUDE_DIR})
message(SEND_ERROR "Can't find WIN32 include directory: ${WIN32_INCLUDE_DIR}") message(SEND_ERROR "Can't find WIN32 include directory: ${WIN32_INCLUDE_DIR}")
endif() endif()
#include_directories(${WIN32_INCLUDE_DIR})
endif() endif()
# Temporary solution until the VLC find module has been updated to work properly on macOS. # Temporary solution until the VLC find module has been updated to work properly on macOS.
@ -278,17 +256,6 @@ if(DEFINED BCMHOST)
"${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vcos" "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vcos"
"${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vmcs_host/linux" "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vmcs_host/linux"
"${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vcos/pthreads") "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/interface/vcos/pthreads")
# Add Vero4k include directory.
elseif(DEFINED VERO4K)
list(APPEND COMMON_INCLUDE_DIRS "${CMAKE_FIND_ROOT_PATH}/opt/vero3/include")
else()
# Add OpenGL include directory.
if(${GLSystem} MATCHES "Desktop OpenGL")
list(APPEND COMMON_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
else()
# Add OpenGL ES include directory.
list(APPEND COMMON_INCLUDE_DIRS ${OPENGLES_INCLUDE_DIR})
endif()
endif() endif()
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
@ -302,7 +269,7 @@ if(NOT WIN32)
${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARIES}
${PUGIXML_LIBRARIES} ${PUGIXML_LIBRARIES}
${SDL2_LIBRARY}) ${SDL2_LIBRARY})
if(VLC_PLAYER OR RPI) if(VLC_PLAYER)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${VLC_LIBRARIES}) set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${VLC_LIBRARIES})
endif() endif()
elseif(WIN32) elseif(WIN32)
@ -382,16 +349,13 @@ endif()
if(DEFINED BCMHOST) if(DEFINED BCMHOST)
link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib") link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vc/lib")
list(APPEND COMMON_LIBRARIES bcm_host brcmEGL ${OPENGLES_LIBRARIES}) list(APPEND COMMON_LIBRARIES bcm_host brcmEGL ${OPENGLES_LIBRARIES})
elseif(DEFINED VERO4K) endif()
link_directories("${CMAKE_FIND_ROOT_PATH}/opt/vero3/lib")
list(APPEND COMMON_LIBRARIES EGL ${OPENGLES_LIBRARIES})
else()
if(${GLSystem} MATCHES "Desktop OpenGL") if(${GLSystem} MATCHES "Desktop OpenGL")
list(APPEND COMMON_LIBRARIES ${OPENGL_LIBRARIES}) list(APPEND COMMON_LIBRARIES ${OPENGL_LIBRARIES})
else() else()
list(APPEND COMMON_LIBRARIES EGL ${OPENGLES_LIBRARIES}) list(APPEND COMMON_LIBRARIES EGL ${OPENGLES_LIBRARIES})
endif() endif()
endif()
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
# Build directories. # Build directories.

View file

@ -332,7 +332,7 @@ else()
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://es-de.org") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://es-de.org")
set(CPACK_DEBIAN_PACKAGE_SECTION "games") set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
if(VLC_PLAYER OR RPI) if(VLC_PLAYER)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "vlc") set(CPACK_DEBIAN_PACKAGE_DEPENDS "vlc")
endif() endif()
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)