Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Glog library to the toolchain #3

Closed
ErmaEnergy opened this issue Apr 4, 2023 · 1 comment
Closed

Adding Glog library to the toolchain #3

ErmaEnergy opened this issue Apr 4, 2023 · 1 comment

Comments

@ErmaEnergy
Copy link

ErmaEnergy commented Apr 4, 2023

Hi !

Thanks a lot for your work, it helped me a lot to finally get into cross compile world.

I need to add a library (GLog) into my project but I'm struggling to make it work.
In the CMakeLists.txt of Glog, I added :

# Cross-compilation system information
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# The sysroot contains all the libraries we might need to link against and 
# possibly headers we need for compilation
set(CMAKE_SYSROOT /var/lib/schroot/chroots/schroot-name-armhf)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
set(CMAKE_STAGING_PREFIX $ENV{HOME}/RPi-dev/staging-armv6-rpi)

# Set the compilers for C, C++ and Fortran
set(RPI_GCC_TRIPLE "armv6-rpi-linux-gnueabihf")
set(CMAKE_C_COMPILER ${RPI_GCC_TRIPLE}-gcc CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${RPI_GCC_TRIPLE}-g++ CACHE FILEPATH "C++ compiler")
set(CMAKE_Fortran_COMPILER ${RPI_GCC_TRIPLE}-gfortran CACHE FILEPATH "Fortran compiler")

# Set the architecture-specific compiler flags
set(ARCH_FLAGS "-mcpu=arm1176jzf-s")
set(CMAKE_C_FLAGS_INIT ${ARCH_FLAGS})
set(CMAKE_CXX_FLAGS_INIT ${ARCH_FLAGS})
set(CMAKE_Fortran_FLAGS_INIT ${ARCH_FLAGS})

# Don't look for programs in the sysroot (these are ARM programs, they won't run
# on the build machine)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Only look for libraries, headers and packages in the sysroot, don't look on 
# the build machine
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf)

It got Build without any error, but when I add just a little 'find_package (glog REQUIRED)' in the CMakeLists.txt of my Project, I get:

CMake Error at CMakeLists.txt:11 (find_package):By not providing "Findglog.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glog", but
CMake did not find one.

Could not find a package configuration file provided by "glog" with any of
the following names:

  glogConfig.cmake
  glog-config.cmake

Add the installation prefix of "glog" to CMAKE_PREFIX_PATH or set
"glog_DIR" to a directory containing one of the above files.  If "glog"
provides a separate development package or SDK, be sure it has been
installed.

Any clue ?

Best regards

@tttapa
Copy link
Owner

tttapa commented Apr 17, 2023

In the CMakeLists.txt of Glog, I added :

Those lines don't belong in a CMakeLists file, they go in a separate toolchain file. See https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html and https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html for more information.

Any clue ?

I'm afraid I can't really help without seeing the full CMake invocations (of the Glog configuration, build, and installation, and the same for your own project), CMakeLists.txt file, toolchain file, and directory layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants