CCMake doesn't automatically found the Toolchain file where CMake does

Hi,

I saw a strange behavior between cmake and ccmake.

CMake detect the Toolchain file whereas CCMake doesn’t.

Do you have any idea what’s the difference ?

Thanks for your help :slight_smile:

When running CMake :

cmake -L -G Ninja -C /home/clement/project/config/cmake/default.cmake /home/clement/project
loading initial cache file /home/clement/project/config/cmake/default.cmake
Toolchain file defaulted to '/opt/poky/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake’
– The C compiler identification is GNU 9.2.0
– The CXX compiler identification is GNU 9.2.0
– Check for working C compiler: /opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
– Check for working C compiler: /opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++
– Check for working CXX compiler: /opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Ccache found!
– Configuring for CPack…
– Looking for pthread.h
– Looking for pthread.h - found
– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
– Check if compiler accepts -pthread
– Check if compiler accepts -pthread - yes
– Found Threads: TRUE
– Found OpenCV: /opt/poky/sysroots/aarch64-poky-linux/usr (found version “4.2.0”)

When running CCMake then Configure:

ccmake -L -G Ninja -C /home/clement/project/config/cmake/default.cmake /home/clement/project
loading initial cache file /home/clement/project/config/cmake/default.cmake
NO TOOLCHAIN FILE HERE
The C compiler identification is GNU 9.2.0
The CXX compiler identification is GNU 9.2.0
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: /opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Ccache found!
Configuring for CPack…
Looking for pthread.h
Looking for pthread.h - found
Performing Test CMAKE_HAVE_LIBC_PTHREAD
Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
Check if compiler accepts -pthread
Check if compiler accepts -pthread - yes
Found Threads: TRUE
CMake Error at CMakeLists.txt:11 (find_package):
By not providing “FindOpenCV.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “OpenCV”, but
CMake did not find one.

Could not find a package configuration file provided by “OpenCV” with any
of the following names:

 OpenCVConfig.cmake
 opencv-config.cmake

Add the installation prefix of “OpenCV” to CMAKE_PR

What does this file look like?

 /home/clement/project/config/cmake/default.cmake

Hi @anon45792294 ,

This file unset and set some CACHE variable.

> # Enable OpenCV
> unset(CONFIG_OPENCV CACHE)
> option(CONFIG_OPENCV "" ON)
> 
> # Disable camera
> unset(CONFIG_CAMERA CACHE)
> option(CONFIG_CAMERA "" OFF)
> 
> # Disable ML
> unset(CONFIG_NEURAL CACHE)
> option(CONFIG_NEURAL "" OFF)
> 
> # Disable viz
> unset(CONFIG_VIZ CACHE)
> option(CONFIG_VIZ "" OFF)
> 
> # Enable PCAP
> unset(CONFIG_PCAP CACHE)
> option(CONFIG_PCAP "" ON)
> 
> # Disable SQL
> unset(CONFIG_SQL CACHE)
> option(CONFIG_SQL "" OFF)
> 
> # Enable gRPC
> unset(CONFIG_GRPC CACHE)
> option(CONFIG_GRPC "" ON)

How are you setting the default toolchain?

Hi @YMba9g8j9CJp0wLoQf5y,

Yes sorry I forget to say this but before calling cmake I source a generated file by poky.

$> . /opt/poky/environment-setup-aarch64-poky-linux

> # Check for LD_LIBRARY_PATH being set, which can break SDK and generally is a bad practice
> # http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80
> # http://xahlee.info/UnixResource_dir/_/ldpath.html
> # Only disable this check if you are absolutely know what you are doing!
> if [ ! -z "$LD_LIBRARY_PATH" ]; then
>     echo "Your environment is misconfigured, you probably need to 'unset LD_LIBRARY_PATH'"
>     echo "but please check why this was set in the first place and that it's safe to unset."
>     echo "The SDK will not operate correctly in most cases when LD_LIBRARY_PATH is set."
>     echo "For more references see:"
>     echo "  http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80"
>     echo "  http://xahlee.info/UnixResource_dir/_/ldpath.html"
>     return 1
> fi
> export SDKTARGETSYSROOT=/opt/poky/sysroots/aarch64-poky-linux
> export PATH=/opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin:/opt/poky/sysroots/x86_64-pokysdk-linux/usr/sbin:/opt/poky/sysroots/x86_64-pokysdk-linux/bin:/opt/poky/sysroots/x86_64-pokysdk-linux/sbin:/opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/../x86_64-pokysdk-linux/bin:/opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux:/opt/poky/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux-musl:$PATH
> export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT
> export PKG_CONFIG_PATH=$SDKTARGETSYSROOT/usr/lib/pkgconfig:$SDKTARGETSYSROOT/usr/share/pkgconfig
> export CONFIG_SITE=/opt/poky/site-config-aarch64-poky-linux
> export OECORE_NATIVE_SYSROOT="/opt/poky/sysroots/x86_64-pokysdk-linux"
> export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"
> export OECORE_ACLOCAL_OPTS="-I /opt/poky/sysroots/x86_64-pokysdk-linux/usr/share/aclocal"
> export OECORE_BASELIB="lib"
> export OECORE_TARGET_ARCH="aarch64"
> export OECORE_TARGET_OS="linux"
> unset command_not_found_handle
> export CC="aarch64-poky-linux-gcc  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
> export CXX="aarch64-poky-linux-g++  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
> export CPP="aarch64-poky-linux-gcc -E  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
> export AS="aarch64-poky-linux-as "
> export LD="aarch64-poky-linux-ld  --sysroot=$SDKTARGETSYSROOT"
> export GDB=aarch64-poky-linux-gdb
> export STRIP=aarch64-poky-linux-strip
> export RANLIB=aarch64-poky-linux-ranlib
> export OBJCOPY=aarch64-poky-linux-objcopy
> export OBJDUMP=aarch64-poky-linux-objdump
> export READELF=aarch64-poky-linux-readelf
> export AR=aarch64-poky-linux-ar
> export NM=aarch64-poky-linux-nm
> export M4=m4
> export TARGET_PREFIX=aarch64-poky-linux-
> export CONFIGURE_FLAGS="--target=aarch64-poky-linux --host=aarch64-poky-linux --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"
> export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
> export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
> export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now"
> export CPPFLAGS=""
> export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"
> export OECORE_DISTRO_VERSION="pokysdk-1.0.0"
> export OECORE_SDK_VERSION="pokysdk-1.0.0"
> export ARCH=arm64
> export CROSS_COMPILE=aarch64-poky-linux-
> 
> # Append environment subscripts
> if [ -d "$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
>     for envfile in $OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
> 	    . $envfile
>     done
> fi
> if [ -d "$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then
>     for envfile in $OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do
> 	    . $envfile
>     done
> fi

latest lines will call cmake.sh

export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake"
export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`"

and openssl.sh

export OPENSSL_CONF="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-1.1/openssl.cnf"