diff --git a/cmake/toolchain/armv7a-gcc b/cmake/toolchain/armv7a-gcc new file mode 100644 index 0000000..e7911a8 --- /dev/null +++ b/cmake/toolchain/armv7a-gcc @@ -0,0 +1,20 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(TOOLCHAIN_PREFIX armv7a-unknown-linux-gnueabihf) + +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) + +set(CMAKE_FIND_ROOT_PATH "/usr/${TOOLCHAIN_PREFIX};/usr/lib/gcc/${TOOLCHAIN_PREFIX}/;${CMAKE_CURRENT_BINARY_DIR}/deps") + +# modify default behavior of FIND_XXX() commands to +# search for headers/libs in the target environment and +# search for programs in the build host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# Export the chosen compiler via CXX and CC, because it's entirely possible +# one of child build scripts will call out to something that relies on these +# to discover the compiler (or will otherwise choose the wrong one). +set ($ENV{CXX} "${CMAKE_CXX_COMPILER}") +set ($ENV{CC} "${CMAKE_C_COMPILER}") diff --git a/conan/profile/armv7-gcc-linux-release b/conan/profile/armv7-gcc-linux-release new file mode 100644 index 0000000..212f6ac --- /dev/null +++ b/conan/profile/armv7-gcc-linux-release @@ -0,0 +1,23 @@ +toolchain=/usr/armv7a-unknown-linux-gnueabihf +target_host=armv7a-unknown-linux-gnueabihf +cc_compiler=gcc +cxx_compiler=g++ + +[env] +CONAN_CMAKE_FIND_ROOT_PATH=$toolchain +CHOST=$target_host +AR=$target_host-ar +AS=$target_host-as +RANLIB=$target_host-ranlib +CC=$target_host-$cc_compiler +CXX=$target_host-$cxx_compiler +STRIP=$target_host-strip + +[settings] +os=Linux +arch=armv7 +compiler=gcc + +compiler.version=10.2 +compiler.libcxx=libstdc++11 +build_type=Release diff --git a/init.py b/init.py index 453b253..8df75a2 100755 --- a/init.py +++ b/init.py @@ -152,6 +152,20 @@ OPTIONS['mingw'] = Option( ) +# ----------------------------------------------------------------------------- +OPTIONS['pi3'] = Option( + vars={ + 'CMAKE_TOOLCHAIN_FILE': os.path.join( + os.path.dirname(__file__), + 'cmake', 'toolchain', 'armv7a-gcc' + ) + }, + arch="armv7", + compiler='gcc', + platform='linux', +) + + # ----------------------------------------------------------------------------- DEFAULT_OPTION = Option( vars={ @@ -213,6 +227,7 @@ if __name__ == '__main__': accumulated = [f'"-D{key}={val}"' for key, val in accum.vars.items()] + accum.args + conan_build_profile = 'x86_64-gcc-linux-release' conan_host_profile = '-'.join([ accum.arch, accum.compiler, @@ -220,7 +235,6 @@ if __name__ == '__main__': accum.config, ]) - conan_build_profile = conan_host_profile if accum.platform == 'mingw': conan_build_profile = f'x86_64-gcc-linux-{accum.config}'