Getting error in Cmake step in Dockerfile installation - cmake

I am new to Docker container and kubenetes cluster. I am trying to run following section of command using buildah
##install cmake
USER root
RUN apt-get update && apt-get -y install cmake
USER ${user}
WORKDIR $HOME
## bustools_dev
RUN git clone https://github.com/Yenaled/bustools.git && \
cd bustools && \
mkdir build && \
cd build
RUN cmake ../
RUN make
RUN cd src
RUN mv bustools bustools_dev
RUN ENV PATH=$HOME/bustools/build/src/:${PATH}
but get the following error. What am I missing here?
STEP 17: WORKDIR $HOME
WARN[0002] SHELL is not supported for OCI image format, [/bin/bash -o pipefail -c] will be ignored. Must use `docker` format
--> 770a1b90326
STEP 18: RUN git clone https://github.com/Yenaled/bustools.git && cd bustools && mkdir build && cd build
Cloning into 'bustools'...
WARN[0005] SHELL is not supported for OCI image format, [/bin/bash -o pipefail -c] will be ignored. Must use `docker` format
--> 2b87555e927
STEP 19: RUN cmake ../
CMake Error: The source directory "/home" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
error building at STEP "RUN cmake ../": error while running runtime: exit status 1
ERRO[0111] exit status 1

I'd simplify the Dockerfile to avoid the issues with the WORKDIR setup that I think are the cause of the problem:
FROM debian:11
RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends --quiet \
ca-certificates \
cmake \
git \
g++ \
make \
libzip-dev \
&& apt-get clean all
WORKDIR /usr/local/src
RUN git clone https://github.com/Yenaled/bustools.git
RUN mkdir -p /usr/local/src/bustools/build
RUN cd /usr/local/src/bustools/build \
&& cmake .. \
&& make
[...]
Output
[...]
STEP 3/6: WORKDIR /usr/local/src
--> ffb056fd5b3
STEP 4/6: RUN git clone https://github.com/Yenaled/bustools.git
Cloning into 'bustools'...
--> 83afa44c5c8
STEP 5/6: RUN mkdir -p /usr/local/src/bustools/build
--> 2e6ed328088
STEP 6/6: RUN cd /usr/local/src/bustools/build && cmake .. && make
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - 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: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
release mode
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/src/bustools/build
Scanning dependencies of target bustools_core
[ 4%] Building CXX object src/CMakeFiles/bustools_core.dir/BUSData.cpp.o
[ 8%] Building CXX object src/CMakeFiles/bustools_core.dir/Common.cpp.o
[ 13%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_capture.cpp.o
[ 17%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_clusterhist.cpp.o
[ 21%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_collapse.cpp.o
[ 26%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_correct.cpp.o
[ 30%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_count.cpp.o
[ 34%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_extract.cpp.o
[ 39%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_inspect.cpp.o
[ 43%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_linker.cpp.o
[ 47%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_main.cpp.o
[ 52%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_mash.cpp.o
[ 56%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_merge.cpp.o
[ 60%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_predict.cpp.o
[ 65%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_project.cpp.o
[ 69%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_sort.cpp.o
[ 73%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_text.cpp.o
[ 78%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_umicorrect.cpp.o
[ 82%] Building CXX object src/CMakeFiles/bustools_core.dir/bustools_whitelist.cpp.o
[ 86%] Building C object src/CMakeFiles/bustools_core.dir/roaring.c.o
[ 91%] Linking CXX static library libbustools_core.a
[ 91%] Built target bustools_core
Scanning dependencies of target bustools
[ 95%] Building CXX object src/CMakeFiles/bustools.dir/bustools_main.cpp.o
[100%] Linking CXX executable bustools
[100%] Built target bustools
--> b08bc457b5f

Related

Install directory inside the github action runner for cmake install target

I want to use the command make install inside a github runner. Before I can use it I have to set the install directory path, but I don't know it. Can anyone help me?
The steps in the workflow for the cmake look like:
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DBUILD_EXAMPLES=OFF -DBUILD_FORTRAN_MODULE=OFF -CMAKE_BUILD_PREFIX=<path-to-the-install-dir>
- name: Build
run: cmake --build ${{github.workspace}}/build
- name: Install
run: make install
When I use as install dir /home/runner/work/ I get this error in the CI:
Run cmake -B /home/runner/work/xxx/xxx/build -DBUILD_EXAMPLES=OFF -DBUILD_FORTRAN_MODULE=OFF -CMAKE_BUILD_PREFIX=/home/runner/work/
cmake -B /home/runner/work/xxx/xxx/build -DBUILD_EXAMPLES=OFF -DBUILD_FORTRAN_MODULE=OFF -CMAKE_BUILD_PREFIX=/home/runner/work/
shell: /usr/bin/bash -e {0}
loading initial cache file MAKE_BUILD_PREFIX=/home/runner/work/
CMake Error: Error processing file: /home/runner/work/xxx/xxx/MAKE_BUILD_PREFIX=/home/runner/work
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring incomplete, errors occurred!
See also "/home/runner/work/xxx/xxx/build/CMakeFiles/CMakeOutput.log".
Error: Process completed with exit code 1.
The problem was that the command make install was called in wrong directory. make install has to be called inside the build directory.
Code works:
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DBUILD_EXAMPLES=OFF -DBUILD_FORTRAN_MODULE=OFF -DCMAKE_INSTALL_PREFIX=/home/runner/work/
- name: Build
run: cmake --build ${{github.workspace}}/build
- name: Install
run: cd build && make install

cmake cross-compilation toolchain confusion

TL;DR: Why moving stuff around from the CMakeLists.txt to a dedicated toolchain file plays a role for find_package?
Trying to cross-compile with cmake and compile/link against pthread, I have the following dummy source file and CMakeLists.txt which work as expected together:
main.cc
#include <iostream>
#include <bits/c++config.h> // needed in the real world
int main()
{
std::cout << "Hello World !\n";
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(test VERSION 0.0.1)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_COMPILER_TARGET arm-linux-gnueabihf)
add_compile_options(-mtune=cortex-a9)
add_compile_definitions(_ARM_GCC_)
# Looking for cross compiler includes; maybe looking for rootfs-like stuff would be better
file(GLOB cross_includes LIST_DIRECTORIES true "/usr/arm-linux-gnueabihf/include/c++/*/arm-linux-gnueabihf/")
include_directories(SYSTEM ${cross_includes})
include_directories(SYSTEM /usr/arm-linux-gnueabihf/include)
find_package(Threads REQUIRED) # Not strictly necessary in this example but needed in the real world
add_executable(test main.cc)
Test:
$> rm -rf build/ && cmake -B build/ && make VERBOSE=1 -C build/
-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - 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: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jp/sandbox/so/cmake/build
make: Entering directory '/home/jp/sandbox/so/cmake/build'
/usr/bin/cmake -S/home/jp/sandbox/so/cmake -B/home/jp/sandbox/so/cmake/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/jp/sandbox/so/cmake/build/CMakeFiles /home/jp/sandbox/so/cmake/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/jp/sandbox/so/cmake/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory '/home/jp/sandbox/so/cmake/build'
cd /home/jp/sandbox/so/cmake/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/jp/sandbox/so/cmake /home/jp/sandbox/so/cmake /home/jp/sandbox/so/cmake/build /home/jp/sandbox/so/cmake/build /home/jp/sandbox/so/cmake/build/CMakeFiles/test.dir/DependInfo.cmake --color=
Dependee "/home/jp/sandbox/so/cmake/build/CMakeFiles/test.dir/DependInfo.cmake" is newer than depender "/home/jp/sandbox/so/cmake/build/CMakeFiles/test.dir/depend.internal".
Dependee "/home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/jp/sandbox/so/cmake/build/CMakeFiles/test.dir/depend.internal".
Scanning dependencies of target test
make[2]: Leaving directory '/home/jp/sandbox/so/cmake/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory '/home/jp/sandbox/so/cmake/build'
[ 50%] Building CXX object CMakeFiles/test.dir/main.cc.o
/usr/bin/clang++ --target=arm-linux-gnueabihf -D_ARM_GCC_ -isystem /usr/arm-linux-gnueabihf/include/c++/10/arm-linux-gnueabihf -isystem /usr/arm-linux-gnueabihf/include -g -mtune=cortex-a9 -std=c++17 -o CMakeFiles/test.dir/main.cc.o -c /home/jp/sandbox/so/cmake/main.cc
[100%] Linking CXX executable test
/usr/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/clang++ --target=arm-linux-gnueabihf -g -rdynamic CMakeFiles/test.dir/main.cc.o -o test
make[2]: Leaving directory '/home/jp/sandbox/so/cmake/build'
[100%] Built target test
make[1]: Leaving directory '/home/jp/sandbox/so/cmake/build'
/usr/bin/cmake -E cmake_progress_start /home/jp/sandbox/so/cmake/build/CMakeFiles 0
make: Leaving directory '/home/jp/sandbox/so/cmake/build'
So far, everything works fine.
Now, the tricky part: I'd like to put the cross-compilation specific stuff in a toolchain.cmake file
toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_COMPILER_TARGET arm-linux-gnueabihf)
add_compile_options(-mtune=cortex-a9)
add_compile_definitions(_ARM_GCC_)
# Looking for cross compiler includes; maybe looking for rootfs-like stuff would be better
file(GLOB cross_includes LIST_DIRECTORIES true "/usr/arm-linux-gnueabihf/include/c++/*/arm-linux-gnueabihf/")
include_directories(SYSTEM ${cross_includes})
include_directories(SYSTEM /usr/arm-linux-gnueabihf/include)
new CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(test VERSION 0.0.1)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Threads REQUIRED) # Not strictly necessary in this example but needed in the real world
add_executable(test main.cc)
Test:
$> rm -rf build/ && cmake -B build/ -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake && make VERBOSE=1 -C build/
-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - 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: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.18/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeOutput.log".
See also "/home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeError.log".
Actually, cmake finds pthread.h but clang cannot compile it (wrong floating point abi used; stubs-hard.h should be included)
build/CMakeFiles/CMakeError.log
Determining if the include file pthread.h exists failed with the following output:
Change Dir: /home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake cmTC_76e89/fast && /usr/bin/gmake -f CMakeFiles/cmTC_76e89.dir/build.make CMakeFiles/cmTC_76e89.dir/build
gmake[1]: Entering directory '/home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_76e89.dir/CheckIncludeFile.c.o
/usr/bin/clang -D_ARM_GCC_ -isystem /usr/arm-linux-gnueabihf/include/c++/10/arm-linux-gnueabihf -isystem /usr/arm-linux-gnueabihf/include/gnu -isystem /usr/arm-linux-gnueabihf/include -mtune=cortex-a9 -o CMakeFiles/cmTC_76e89.dir/CheckIncludeFile.c.o -c /home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
In file included from /home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:
In file included from /usr/arm-linux-gnueabihf/include/pthread.h:21:
In file included from /usr/arm-linux-gnueabihf/include/features.h:485:
/usr/arm-linux-gnueabihf/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-soft.h' file not found
# include <gnu/stubs-soft.h>
^~~~~~~~~~~~~~~~~~
1 error generated.
gmake[1]: *** [CMakeFiles/cmTC_76e89.dir/build.make:85: CMakeFiles/cmTC_76e89.dir/CheckIncludeFile.c.o] Error 1
gmake[1]: Leaving directory '/home/jp/sandbox/so/cmake/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_76e89/fast] Error 2
Some more Info:
I made sure the toolchain.cmake is considered (triggered a parse error to check)
$> cat toolchain.cmake CMakeLists.txt
produces the same output as the "original" CMakeLists.txt
pthread.h can be found on my System at the following locations:
$> find /usr/ -name pthread.h
/usr/arm-linux-gnueabi/include/pthread.h
/usr/arm-linux-gnueabihf/include/pthread.h
/usr/include/newlib/pthread.h /usr/include/pthread.h
As #Tsyvarev pointed out, the CMakeError.log contained useful information (the question was edited with its content).
The issue:
cmake finds pthread.h but clang cannot compile it
...
/usr/arm-linux-gnueabihf/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-soft.h' file not found
...
The clang invocation is interesting because of "/usr/bin/clang" (expected clang++) and no -target flag used
The solution:
Tell cmake to also use a specific -target flag for C cross-compilers supoorting it:
Add the following in target.cmake
set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabihf)
(Same target as CMAKE_CXX_COMPILER_TARGET)

Is it possible to call a custom CMake function when library is linked?

Let's say I have a library A and a project B which uses A.
project(libA)
function(calledWhenLink target)
message(STATUS Hi ${target}) # Should print "Hi exeB"
endfunction()
add_library(libA INTERFACE)
project(exeB)
find_package(A REQUIRED)
target_link_library(exeB libA)
Is it possible to automatically call calledWhenLink() when the executable links to the library ?
Reasoning: As said in a comment, the original problem is that VTK needs to call CMake vtk_module_autoinit. My library uses VTK, and it seems better for all the samples to automatically call this when linked to the lib instead of copy paste the code in each CMakeLists. The problem is that vtk_module_autoinit is not working when called with the lib target instead ot the exe in my tests.
Yes, it is possible to run arbitrary CMake code at build time. However, it is not at all clear what you're really trying to do, so this might not be a good approach.
Here's a minimal example:
cmake_minimum_required(VERSION 3.21)
project(example)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post-link.cmake" [[
message(STATUS "Hi ${target}")
]])
add_executable(exeB main.cpp)
add_custom_command(
TARGET exeB POST_BUILD
COMMAND "${CMAKE_COMMAND}"
-Dtarget=exeB
-P "${CMAKE_CURRENT_BINARY_DIR}/post-link.cmake"
)
Test interaction:
alex#alex-ubuntu:~/test$ cmake -G Ninja -S . -B build
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - 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: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/build
alex#alex-ubuntu:~/test$ cmake --build build/ --verbose
[1/2] /usr/bin/c++ -MD -MT CMakeFiles/exeB.dir/main.cpp.o -MF CMakeFiles/exeB.dir/main.cpp.o.d -o CMakeFiles/exeB.dir/main.cpp.o -c /home/alex/test/main.cpp
[2/2] : && /usr/bin/c++ CMakeFiles/exeB.dir/main.cpp.o -o exeB && cd /home/alex/test/build && /usr/bin/cmake -Dtarget=exeB -P /home/alex/test/build/post-link.cmake
-- Hi exeB

Conan and Raspberry Pico, how to use together?

Good morning!
I'm rewriting this question because, after a lot of reading and try-fails, I go further on that but I get staked again.
What I'm trying to accomplice here is: Use Conan as a Package manager for the embedded device "Raspberry PICO" from my Mac (with CLion)
The change from the previous question is that now I'm creating a package and I do not use only the "standalone" packages manager.
This "package" is on github.com. To install and try to compile it, you will need also the Pico SDK.
Some facts:
The new c++ project without Conan but with SDK is compiling and working on an embedded device.
The Conan project without Pico SDK is compiling correctly.
I really tried every possible configuration on the profile file and there are two mainly configuration profiles that brings to two different errors during build:
The first one is without any environments. This is because on CLion I'm not adding any environment and the project itself (without conan, but oblivious with SDK for pico) is builder correctly.
[settings]
os_build=Macos
arch_build=x86_64
os=Linux
arch=armv7
# os=Macos
# arch=x86_64
# compiler=apple-clang
compiler=gcc
# compiler.version=12.0
compiler.version=9.2
# compiler.libcxx=libc++
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
ps. The commented lines are additional tests that resolve on the same result after conan build ..
The error is this:
jure.prah#MacBook-Pro-di-Jure conan-blink-mosfet % conan build .
Using lockfile: '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/conan.lock'
Using cached profile from lockfile
conanfile.py (blink/0.1): Calling build()
conanfile.py (blink/0.1): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/package" "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/src"
Using PICO_SDK_PATH from environment ('/Users/jure.prah/CLionProjects/pico-sdk')
PICO_SDK_PATH is /Users/jure.prah/CLionProjects/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
-- Defaulting build type to 'Release' since not specified.
Using Conan toolchain through /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake.
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Setting BUILD_SHARED_LIBS= OFF
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- The ASM compiler identification is Clang
-- Found assembler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Detecting C compiler ABI info
Using Conan toolchain through .
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
Using Conan toolchain through .
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Defaulting PICO target board to pico since not specified.
Using board configuration from /Users/jure.prah/CLionProjects/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9 (found version "3.9.6") found components: Interpreter
TinyUSB available at /Users/jure.prah/CLionProjects/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; adding USB support.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release
conanfile.py (blink/0.1): CMake command: cmake --build '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release'
[ 25%] Building CXX object CMakeFiles/blink.dir/blink.cpp.o
[ 50%] Linking CXX static library libblink.a
[ 50%] Built target blink
Scanning dependencies of target bs2_default
[ 75%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.o
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:89:1: error: unknown directive
.syntax unified
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:90:1: error: unknown directive
.cpu cortex-m0plus
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:91:1: error: unknown directive
.thumb
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:93:15: error: unexpected token in '.section' directive
.section .text
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:101:1: error: unknown directive
.type _stage2_boot,%function
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:102:1: error: unknown directive
.thumb_func
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:104:11: error: unknown token in expression
push {lr}
^
[...]
^
/Users/jure.prah/CLionProjects/pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:285:1: error: unknown directive
.ltorg
^
make[2]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.o] Error 1
make[1]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/all] Error 2
make: *** [all] Error 2
ERROR: conanfile.py (blink/0.1): Error in build() method, line 40
cmake.build()
ConanException: Error 2 while executing cmake --build '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release'
The second profile configuration is based on the example from conan.com (thanks to #uilianres) and sets the environments.:
toolchain_path=/usr/local/bin
toolchain=arm-none-eabi
[settings]
os_build=Macos
arch_build=x86_64
#os=Macos
#arch=x86_64
os=Linux
arch=armv7
compiler=apple-clang
# compiler=gcc
compiler.version=12.0
# compiler.version=9.2
compiler.libcxx=libc++
# compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CONAN_CMAKE_FIND_ROOT_PATH=$toolchain_path/
AR=$toolchain-ar
AS=$toolchain-as
CC=$toolchain-gcc
CXX=$toolchain-g++
STRIP=$toolchain-strip
Using command conan build . resolve on different error:
jure.prah#MacBook-Pro-di-Jure conan-blink-mosfet % conan build .
Using lockfile: '/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/conan.lock'
Using cached profile from lockfile
conanfile.py (blink/0.1): Calling build()
conanfile.py (blink/0.1): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/package" "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/src"
Using PICO_SDK_PATH from environment ('/Users/jure.prah/CLionProjects/pico-sdk')
PICO_SDK_PATH is /Users/jure.prah/CLionProjects/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
-- Defaulting build type to 'Release' since not specified.
Using Conan toolchain through /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake.
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Setting BUILD_SHARED_LIBS= OFF
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/bin/arm-none-eabi-gcc
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Detecting C compiler ABI info
Using Conan toolchain through .
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/bin/arm-none-eabi-gcc
Using Conan toolchain through .
-- Check for working C compiler: /usr/local/bin/arm-none-eabi-gcc - broken
CMake Error at /usr/local/Cellar/cmake/3.21.0/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/local/bin/arm-none-eabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_69910/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_69910.dir/build.make CMakeFiles/cmTC_69910.dir/build
Building C object CMakeFiles/cmTC_69910.dir/testCCompiler.c.o
/usr/local/bin/arm-none-eabi-gcc -D_GLIBCXX_USE_CXX11_ABI=0 -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -fPIE -o CMakeFiles/cmTC_69910.dir/testCCompiler.c.o -c /Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_69910
/usr/local/Cellar/cmake/3.21.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_69910.dir/link.txt --verbose=1
/usr/local/bin/arm-none-eabi-gcc -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_69910.dir/testCCompiler.c.o -o cmTC_69910
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol arch_paths_first; defaulting to 0000000000008018
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_69910] Error 1
make: *** [cmTC_69910/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:5 (project)
-- Configuring incomplete, errors occurred!
See also "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeOutput.log".
See also "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/Release/CMakeFiles/CMakeError.log".
ERROR: conanfile.py (blink/0.1): Error in build() method, line 39
cmake.configure()
ConanException: Error 1 while executing cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/package" "/Users/jure.prah/CLionProjects/rpi-pico/conan-blink-mosfet/src"
Also here I did all the variants and tests, but everything leads to this error. Besides, I checked the toolchain paths and there are correct.
I'm completely lost now. :(

CMake: find Armadillo library installed in a custom location

No root access on cluster, install Armadillo with
make install DEST_DIR=/home/my_id/include
and now I have no idea how to do find_package(ARMADILLO REQUIRED) to set ${ARMADILLO_INCLUDE_DIRS} and${ARMADILLO_LIBRARIES}.
use CMAKE_LIBRARY_PATH and/or CMAKE_PREFIX_PATH environment variables to specify additional paths where to look for libraries and headers.
Also see cmake - find_library - custom library location but all the answers there suggest to edit CMakeLists.txt that could be slightly inconvenient sometimes.
Edit: Here's the complete working example:
alex#rhyme /var/tmp $ tar zxf armadillo-6.500.4.tar.gz
alex#rhyme /var/tmp $ cd armadillo-6.500.4
alex#rhyme /var/tmp/armadillo-6.500.4 $ mkdir build
alex#rhyme /var/tmp/armadillo-6.500.4 $ cd build
alex#rhyme tmp/armadillo-6.500.4/build $ cmake ..
-- Configuring Armadillo 6.500.4
...
-- CMAKE_INSTALL_PREFIX = /usr
-- INSTALL_LIB_DIR = /usr/lib64
-- INSTALL_INCLUDE_DIR = /usr/include
-- INSTALL_DATA_DIR = /usr/share
-- INSTALL_BIN_DIR = /usr/bin
-- Generating '/var/tmp/armadillo-6.500.4/build/ArmadilloConfig.cmake'
-- Generating '/var/tmp/armadillo-6.500.4/build/ArmadilloConfigVersion.cmake'
-- Generating '/var/tmp/armadillo-6.500.4/build/InstallFiles/ArmadilloConfig.cmake'
-- Generating '/var/tmp/armadillo-6.500.4/build/InstallFiles/ArmadilloConfigVersion.cmake'
-- Configuring done
-- Generating done
-- Build files have been written to: /var/tmp/armadillo-6.500.4/build
alex#rhyme tmp/armadillo-6.500.4/build $ make -j4
Scanning dependencies of target armadillo
[100%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper.cpp.o
Linking CXX shared library libarmadillo.so
[100%] Built target armadillo
alex#rhyme tmp/armadillo-6.500.4/build $ make install DESTDIR=/var/tmp/armadillo
[100%] Built target armadillo
Install the project...
-- Install configuration: ""
-- Installing: /var/tmp/armadillo/usr/include
-- Installing: /var/tmp/armadillo/usr/include/armadillo_bits
-- Installing: /var/tmp/armadillo/usr/include/armadillo_bits/spop_htrans_bones.hpp
...
-- Installing: /var/tmp/armadillo/usr/include/armadillo_bits/subview_elem2_bones.hpp
-- Installing: /var/tmp/armadillo/usr/include/armadillo
-- Installing: /var/tmp/armadillo/usr/lib64/libarmadillo.so.6.500.4
-- Installing: /var/tmp/armadillo/usr/lib64/libarmadillo.so.6
-- Installing: /var/tmp/armadillo/usr/lib64/libarmadillo.so
-- Installing: /var/tmp/armadillo/usr/share/Armadillo/CMake/ArmadilloLibraryDepends.cmake
-- Installing: /var/tmp/armadillo/usr/share/Armadillo/CMake/ArmadilloLibraryDepends-noconfig.cmake
-- Installing: /var/tmp/armadillo/usr/share/Armadillo/CMake/ArmadilloConfig.cmake
-- Installing: /var/tmp/armadillo/usr/share/Armadillo/CMake/ArmadilloConfigVersion.cmake
alex#rhyme tmp/armadillo-6.500.4/build $ cd ../../
alex#rhyme /var/tmp $ mkdir test_armadillo_project
alex#rhyme /var/tmp $ cd test_armadillo_project
alex#rhyme /var/tmp/test_armadillo_project $ cat >CMakeLists.txt <<EOF
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
FIND_PACKAGE(Armadillo REQUIRED)
EOF
Now we're trying to build the package w/o specifying its location. CMake expectedly fails:
alex#rhyme /var/tmp/test_armadillo_project $ cmake .
-- The C compiler identification is GNU 5.3.1
-- The CXX compiler identification is GNU 5.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/CMake/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find Armadillo (missing: ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/CMake/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
/usr/share/CMake/Modules/FindArmadillo.cmake:92 (find_package_handle_standard_args)
CMakeLists.txt:3 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "/var/tmp/test_armadillo_project/CMakeFiles/CMakeOutput.log".
Now we're specifying the custom path via environment variable:
alex#rhyme /var/tmp/test_armadillo_project $ CMAKE_PREFIX_PATH=/var/tmp/armadillo/usr cmake .
-- Found Armadillo: /var/tmp/armadillo/usr/lib64/libarmadillo.so (found version "6.500.4")
-- Configuring done
-- Generating done
-- Build files have been written to: /var/tmp/test_armadillo_project
I'm pretty sure I could set CMAKE_PREFIX_PATH right in CMakeLists.txt and it would work just as with environment variable above.