Browse Source

Refactor to avoid hard-coding the library arch for Debian distro.
Instead, assume the GCC (cross-)compiler toolchain will have the "--enable-multiarch" enabled and the toolchain has a triplet matching the CMAKE_LIBRARY_ARCHITECTURE_REGEX which is set to "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*" as of this writing. If so, CMake will automatically initialize the CMAKE_LIBRARY_ARCHITECTURE with a right value and CMake will use it when searching for libraries, not requiring the build script to spell out the extra path suffixes manually.

Yao Wei Tjong 姚伟忠 5 years ago
parent
commit
0b9c49cab8

+ 1 - 1
CMake/Modules/FindDRM.cmake

@@ -28,7 +28,7 @@
 #
 #
 
 
 find_path (DRM_INCLUDE_DIRS NAMES drm.h PATH_SUFFIXES libdrm DOC "DirectRenderingManager include directory")
 find_path (DRM_INCLUDE_DIRS NAMES drm.h PATH_SUFFIXES libdrm DOC "DirectRenderingManager include directory")
-find_library (DRM_LIBRARIES NAMES drm PATH_SUFFIXES aarch64-linux-gnu DOC "DirectRenderingManager library")
+find_library (DRM_LIBRARIES NAMES drm DOC "DirectRenderingManager library")
 
 
 include (FindPackageHandleStandardArgs)
 include (FindPackageHandleStandardArgs)
 find_package_handle_standard_args (DRM REQUIRED_VARS DRM_LIBRARIES DRM_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Direct Rendering Manager development library")
 find_package_handle_standard_args (DRM REQUIRED_VARS DRM_LIBRARIES DRM_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Direct Rendering Manager development library")

+ 1 - 1
CMake/Modules/FindGBM.cmake

@@ -28,7 +28,7 @@
 #
 #
 
 
 find_path (GBM_INCLUDE_DIRS NAMES gbm.h DOC "GenericBufferManagement include directory")
 find_path (GBM_INCLUDE_DIRS NAMES gbm.h DOC "GenericBufferManagement include directory")
-find_library (GBM_LIBRARIES NAMES gbm PATH_SUFFIXES aarch64-linux-gnu DOC "GenericBufferManagement library")
+find_library (GBM_LIBRARIES NAMES gbm DOC "GenericBufferManagement library")
 
 
 include (FindPackageHandleStandardArgs)
 include (FindPackageHandleStandardArgs)
 find_package_handle_standard_args (GBM REQUIRED_VARS GBM_LIBRARIES GBM_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Direct Generic Buffer Management development library")
 find_package_handle_standard_args (GBM REQUIRED_VARS GBM_LIBRARIES GBM_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Direct Generic Buffer Management development library")

+ 1 - 1
CMake/Modules/FindVideoCore.cmake

@@ -33,7 +33,7 @@ set (VIDEOCORE_INC_SEARCH_PATH /opt/vc/include)
 set (VIDEOCORE_LIB_SEARCH_PATH /opt/vc/lib)
 set (VIDEOCORE_LIB_SEARCH_PATH /opt/vc/lib)
 
 
 find_path (VIDEOCORE_INCLUDE_DIRS bcm_host.h PATHS ${VIDEOCORE_INC_SEARCH_PATH} PATH_SUFFIXES vc DOC "Broadcom VideoCore include directory")
 find_path (VIDEOCORE_INCLUDE_DIRS bcm_host.h PATHS ${VIDEOCORE_INC_SEARCH_PATH} PATH_SUFFIXES vc DOC "Broadcom VideoCore include directory")
-find_library (VIDEOCORE_LIBRARIES bcm_host PATHS ${VIDEOCORE_LIB_SEARCH_PATH} PATH_SUFFIXES vc aarch64-linux-gnu DOC "Broadcom VideoCore BCM_HOST library")
+find_library (VIDEOCORE_LIBRARIES bcm_host PATHS ${VIDEOCORE_LIB_SEARCH_PATH} PATH_SUFFIXES vc DOC "Broadcom VideoCore BCM_HOST library")
 
 
 include (FindPackageHandleStandardArgs)
 include (FindPackageHandleStandardArgs)
 find_package_handle_standard_args (VideoCore REQUIRED_VARS VIDEOCORE_LIBRARIES VIDEOCORE_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Broadcom VideoCore firmware")
 find_package_handle_standard_args (VideoCore REQUIRED_VARS VIDEOCORE_LIBRARIES VIDEOCORE_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Broadcom VideoCore firmware")

+ 5 - 8
CMake/Modules/UrhoCommon.cmake

@@ -123,18 +123,15 @@ include (CheckHost)
 include (CheckCompilerToolchain)
 include (CheckCompilerToolchain)
 
 
 # Extra linker flags for linking against indirect dependencies (linking shared lib with dependencies)
 # Extra linker flags for linking against indirect dependencies (linking shared lib with dependencies)
-if (RPI)
-    if (NOT NATIVE_64BIT)
-        # Extra linker flags for Raspbian because it installs VideoCore libraries in the "/opt/vc/lib" directory (no harm in doing so for other distros)
-        set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CMAKE_SYSROOT}/opt/vc/lib\"")      # CMAKE_SYSROOT is empty when not cross-compiling
-    else ()
-        set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu\"")
-    endif ()
+if (RPI AND NOT RPI_ABI STREQUAL RPI4)
+    # Extra linker flags for legacy Raspbian because it installs VideoCore libraries in the "/opt/vc/lib" directory (no harm in doing so for other distros)
+    set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CMAKE_SYSROOT}/opt/vc/lib\"")      # CMAKE_SYSROOT is empty when not cross-compiling
 elseif (APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0)
 elseif (APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0)
     set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-no_weak_imports")
     set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-no_weak_imports")
 endif ()
 endif ()
-if (ARM AND CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_CROSSCOMPILING)
+if (ARM AND CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_CROSSCOMPILING AND CMAKE_LIBRARY_ARCHITECTURE)
     # Cannot do this in the toolchain file because CMAKE_LIBRARY_ARCHITECTURE is not yet defined when CMake is processing toolchain file
     # Cannot do this in the toolchain file because CMAKE_LIBRARY_ARCHITECTURE is not yet defined when CMake is processing toolchain file
+    # Probably don't need this in the future when the linker from the cross-compiling toolchain has the '129_multiarch_libpath.patch' applied to upstream
     set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}\":\"${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}\"")
     set (INDIRECT_DEPS_EXE_LINKER_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}\":\"${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}\"")
 endif ()
 endif ()
 set (CMAKE_REQUIRED_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
 set (CMAKE_REQUIRED_FLAGS "${INDIRECT_DEPS_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")