cmake improve cross documentation

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-03-30 10:30:03 +08:00
parent 9a4fef7ed6
commit 5b479ac2f1
3 changed files with 40 additions and 25 deletions

View file

@ -17,6 +17,8 @@ set(VERSION "${CPACK_PACKAGE_VERSION}")
set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION}) set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'")
# Try to find the current Git hash. # Try to find the current Git hash.
find_package(Git) find_package(Git)
if(GIT_EXECUTABLE) if(GIT_EXECUTABLE)

View file

@ -146,35 +146,20 @@ a "Toolchain file" that you supply to CMake when generating your build files.
CMake will then use the cross compilers and build paths specified in this file CMake will then use the cross compilers and build paths specified in this file
to look for dependencies and such. to look for dependencies and such.
Below is an example of how one of these files might look like: Libwebsockets includes an example toolchain file cross-arm-linux-gnueabihf.cmake
you can use as a starting point.
# The commandline to configure for cross with this would look like
# CMake Toolchain file for crosscompiling on ARM.
#
# This can be used when running cmake in the following way:
# cd build/
# cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/this/file/TC_arm-linux-gcc.cmake
#
set(CROSS_PATH /path/to/cross_environment/uClibc) cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake \
-DWITHOUT_EXTENSIONS=1 -DWITH_SSL=0
# Target operating system name. The example shows how to build with no external cross lib dependencies, you
set(CMAKE_SYSTEM_NAME Linux) need to proide the cross libraries otherwise.
# Name of C compiler. NOTE: start from an EMPTY build directory if you had a non-cross build in there
set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-linux-uclibc-gcc") before the settings will be cached and your changes ignored.
set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-linux-uclibc-g++")
# Where to look for the target environment. (More paths can be added here)
set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")
# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search headers and libraries in the target environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Additional information on cross compilation with CMake: Additional information on cross compilation with CMake:
http://www.vtk.org/Wiki/CMake_Cross_Compiling http://www.vtk.org/Wiki/CMake_Cross_Compiling

View file

@ -0,0 +1,28 @@
#
# CMake Toolchain file for crosscompiling on ARM.
#
# This can be used when running cmake in the following way:
# cd build/
# cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake
#
set(CROSS_PATH /opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.02-01-20130221_linux)
# Target operating system name.
set(CMAKE_SYSTEM_NAME Linux)
# Name of C compiler.
set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabihf-g++")
# Where to look for the target environment. (More paths can be added here)
set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")
# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search headers and libraries in the target environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)