Conan and Raspberry Pico, how to use together? - cmake

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. :(

Related

Unable to build flatc compiler flatbuffer v1.3.0

We are using flatbuffer v1.3.0 and seeing error building flatc compiler.
Same error for flatbuffer version v1.3.0 to v1.12.1
Build is successful for version 2.0.0
Should we use a particular version of make to build the flatc compiler? If so how to do it?
Steps
git clone https://github.com/google/flatbuffers/tree/v1.3.0
cd flatbuffers
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -Success
make --Error
Versions installed on MacOS BigSur Version 11.6
$ cmake --version
cmake version 3.19.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- 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
-- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/abcd/Documents/FlatBuffer/flatbuffers
$ make
Scanning dependencies of target flatc
[ 2%] Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.o
In file included from /Users/abcd/Documents/FlatBuffer/flatbuffers/src/idl_parser.cpp:28:
In file included from /Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/idl.h:25:
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1086:25: error: definition of implicit copy constructor for 'TableKeyComparator<reflection::Object>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
TableKeyComparator& operator= (const TableKeyComparator&);
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1100:27: note: in implicit copy constructor for 'flatbuffers::FlatBufferBuilder::TableKeyComparator<reflection::Object>' first required here
std::sort(v, v + len, TableKeyComparator<T>(buf_));
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1113:12: note: in instantiation of function template specialization 'flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables<reflection::Object>' requested here
return CreateVectorOfSortedTables(v->data(), v->size());
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/src/idl_parser.cpp:2008:35: note: in instantiation of function template specialization 'flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables<reflection::Object>' requested here```
Flatbuffer requires a specific version of clang to compile the 1.12.1.
Installing the required version.
sudo apt-get install clang-6.0 lld-6.0 clang-tidy-6.0
use update-alternatives to link the clang.
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 10
sudo update-alternatives --install /usr/bin/clang++ clang++
/usr/bin/clang++-6.0 10

Compile FreeCAD on macOS Big Sur 11.5.1 with Homebrew, error finding XercesC files

I’m stuck compiling FC on macOS Big Sur. The build breaks with an error not finding certain XercesC libraries. But these libraries are installed and the path is even found by the CMake preparation process.
I postet this issue in the FreeCAD forum under https://forum.freecadweb.org/viewtopic.php?f=4&t=60663, but found no help. I would appreciate if anyone here at StackOverflow could verify this error or better yet have a hint for a solution. Thanks in advance.
System Info:
macOS Big Sur version 11.5.1
Homebrew version 3.2.5-15-g13d3eab
FreeCAD Version from latest master, see https://github.com/FreeCAD/FreeCAD
Complete steps for the build prozess:
# install freecad dependencies via homebrew
brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad --with-packaging-utils
# Freecad source is located in folder freecad-source/
# setup the build folder and change into newly created folder
mkdir -p freecad-build
cd freecad-build
# export path to installed dependencies
export PREFIX_PATH="\
/usr/local/opt/qt5152/lib/cmake;\
/usr/local/opt/nglib/Contents/Resources;\
/usr/local/opt/vtk#8.2.0/lib/cmake;\
/usr/local/opt/opencascade#7.5.0/lib/cmake;\
/usr/local/opt/med-file/share/cmake;\
/usr/local/opt/shiboken2/lib/cmake;\
/usr/local/opt/pyside2/lib/cmake;\
/usr/local/opt/coin#4.0.0;\
/usr/local/opt/boost#1.75.0/lib/cmake;\
/usr/local/opt/boost-python3#1.75.0/lib/cmake"
# initiate build instructions
cmake \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_VERBOSE_MAKEFILE=OFF \
-Wno-dev \
-DBUILD_TESTING=OFF \
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
-DBUILD_QT5=ON \
-DUSE_PYTHON3=1 \
-DCMAKE_CXX_STANDARD=14 \
-DBUILD_ENABLE_CXX_STD:STRING=C++14 \
-DBUILD_FEM_NETGEN=1 \
-DBUILD_FEM=1 \
-DBUILD_FEM_NETGEN:BOOL=ON \
-DBUILD_WEB=ON \
-DFREECAD_USE_EXTERNAL_KDL=ON \
-DPYTHON_EXECUTABLE=/usr/local/opt/python3.9/bin/python3 \
-DPYTHON_INCLUDE_DIR=/usr/local/opt/python3.9/Frameworks/Python.framework/Headers \
-DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
-DFREECAD_CREATE_MAC_APP=1 \
-DCMAKE_INSTALL_PREFIX="./.." \
../freecad-source
The CMake process ends successfully with the following summary report. Note here, that XercesC is correctly found under
-- XercesC: 3.2.3 [/usr/local/lib/libxerces-c.dylib] [/usr/local/include]:
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Compiler: AppleClang, version: 12.0.5.12050022
-- Looking for GL/gl.h
-- Looking for GL/gl.h - not found
-- Looking for C++ include istream
-- Looking for C++ include istream - found
-- Looking for C++ include ostream
-- Looking for C++ include ostream - found
-- Looking for C++ include fstream
-- Looking for C++ include fstream - found
-- Looking for C++ include sstream
-- Looking for C++ include sstream - found
-- Looking for C++ include ios
-- Looking for C++ include ios - found
-- Looking for C++ include iostream
-- Looking for C++ include iostream - found
-- Looking for C++ include iomanip
-- Looking for C++ include iomanip - found
-- Looking for C++ include iostream
-- Looking for C++ include iostream - found
-- Check for STD namespace
-- Check for STD namespace - found
-- Force BOOST_PP_VARIADICS=1 for clang
-- prefix: /Users/dirkolbrich/Freecad
-- bindir: bin
-- datadir: share
-- docdir: share/doc/FreeCAD
-- includedir: include
-- libdir: lib
-- cmake: 3.21.1
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
=====================================================
Doxygen not found, will not build documentation.
=====================================================
-- Detected Homebrew install at /usr/local
-- Found Python3: /usr/local/bin/python3.9 (found version "3.9.6") found components: Interpreter Development Development.Module Development.Embed
-- Found XercesC: /usr/local/lib/libxerces-c.dylib (found version "3.2.3")
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libz.tbd (found version "1.2.11")
# lots of other setup stuff deleted for clarity
#
#
==============
Summary report
==============
-- Build type: Release
-- Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (12.0.5.12050022)
-- Flags: -Wall -Wextra -Wpedantic -Wno-write-strings -Wno-undefined-var-template
-- Standard: Requires C++14
-- Python: 3.9.6 [/usr/local/bin/python3.9] [.cpython-39-darwin]
-- PCL: not enabled
-- pybind11: not enabled
-- Boost: 1.75.0 (1.75.0)
-- XercesC: 3.2.3 [/usr/local/lib/libxerces-c.dylib] [/usr/local/include]
-- ZLIB: 1.2.11
-- PyCXX: 6.2.8 [/Users/dirkolbrich/Freecad/freecad-source/src]
-- OCC: 7.5.0 [TKFillet;TKMesh;TKernel;TKG2d;TKG3d;TKMath;TKIGES;TKSTL;TKShHealing;TKXSBase;TKBool;TKBO;TKBRep;TKTopAlgo;TKGeomAlgo;TKGeomBase;TKOffset;TKPrim;TKSTEPBase;TKSTEPAttr;TKSTEP209;TKSTEP;TKHLR;TKFeat] [/usr/local/opt/opencascade#7.5.0/lib] [/usr/local/opt/opencascade#7.5.0/include/opencascade]
-- SMESH: build internal
-- MEDFile: 4.0.0 [/usr/local/lib/libmedC.dylib;/usr/local/lib/libmed.dylib] [/usr/local/include]
-- HDF5: 1.12.1
-- VTK: 8.2.0
-- NETGEN: 6.2.2101 (6.2.2101) [-DNO_PARALLEL_THREADS;-DOCCGEOMETRY;-DNETGEN_VERSION=395829] [] [/usr/local/opt/nglib/Contents/Resources/include/include;/usr/local/opt/nglib/Contents/Resources/include] [nglib] [/usr/local/opt/nglib/Contents/Resources/include/include;/usr/local/opt/nglib/Contents/Resources/include]
-- SWIG: 4.0.2
-- Eigen3 3.3.9
-- Qt5Core: 5.15.2
-- Qt5Network: 5.15.2
-- Qt5Xml: 5.15.2
-- Qt5XmlPatterns: 5.15.2
-- Qt5Widgets: 5.15.2
-- Qt5PrintSupport: 5.15.2
-- Qt5OpenGL: 5.15.2
-- Qt5Svg: 5.15.2
-- Qt5UiTools: 5.15.2
-- Qt5Concurrent: 5.15.2
-- Qt5WebEngineWidgets: 5.15.2
-- Shiboken2: 5.15.2 [/usr/local/opt/shiboken2/lib/cmake/Shiboken2-5.15.2] [/usr/local/opt/shiboken2/include/shiboken2;/usr/local/opt/python3.9/Frameworks/Python.framework/Headers]
-- PySide2: 5.15.2 [/usr/local/opt/pyside2/include/PySide2]
-- PySide2Tools: [/usr/local/bin/uic] [/usr/local/bin/rcc]
-- Freetype: 2.11.0
-- OpenGL: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework
-- OpenGLU: [/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework][/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework]
-- Coin3D: 4.0.0 [/usr/local/opt/coin#4.0.0/lib/libCoin.dylib] [/usr/local/opt/coin#4.0.0/include]
-- Pivy: 0.6.5
-- SPNAV: [SPNAV_LIBRARY-NOTFOUND] [SPNAV_INCLUDE_DIR-NOTFOUND]
-- Matplotlib: 2.1.1
-- Rift: not enabled (BUILD_VR)
-- Doxygen: not found
=================================================
Now run 'cmake --build /Users/dirkolbrich/Freecad/freecad-build' to build FreeCAD
=================================================
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/dirkolbrich/Freecad/freecad-build
Now I start the build process with the following steps:
# set path to icu4c
# see https://forum.freecadweb.org/viewtopic.php?p=507588#p507588
export LIBRARY_PATH="/usr/local/opt/icu4c/lib"
#start the build according to the last line of the cmake summary report
cmake --build /Users/dirkolbrich/freecad/freecad-build/release
The build errors shortly before finish with an error of not finding the XercesC library files:
[ 91%] Building CXX object src/Mod/Measure/App/CMakeFiles/Measure.dir/AppMeasure.cpp.o
In file included from /Users/dirkolbrich/freecad/freecad-source/src/Mod/Measure/App/AppMeasure.cpp:32:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/Mod/Measure/App/Measurement.h:29:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/App/DocumentObject.h:28:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/App/TransactionalObject.h:27:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/App/ExtensionContainer.h:33:
/Users/dirkolbrich/freecad/freecad-source/src/Base/Reader.h:32:10: fatal error: 'xercesc/framework/XMLPScanToken.hpp' file not found
#include <xercesc/framework/XMLPScanToken.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/Mod/Measure/App/CMakeFiles/Measure.dir/AppMeasure.cpp.o] Error 1
make[1]: *** [src/Mod/Measure/App/CMakeFiles/Measure.dir/all] Error 2
make: *** [all] Error 2
The not found files exist under the specified path at /usr/local/include/xercesc/framework/XMLPScanToken.hpp according to the summary report and verified manually.
Even adding -DXERCESC_INCLUDE_DIR=/usr/include/xercesc to the cmake command does not help.
There is a typo in the build script.
The final report prints XercesC_INCLUDE_DIRS,
but the CMakeLists.txt for that subdirectory uses XERCESC_INCLUDE_DIR.
I suggest you fix the typo (to XercesC_INCLUDE_DIRS) in src/Mod/Measure/App/CMakeLists.txt and file a pull request.

why 'target_link_libraries' command is not working? (cplex)

I tried to compile an project with cmake command(all implementation is written by other people. my job is just compile and run.)
error messages after cmake
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- 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
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: bad revision 'HEAD'
-- 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 LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.10")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- CPLEX Library: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic/libcplex.a
-- ILOCPLEX Library: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic/libilocplex.a
-- CONCERT Library: /opt/ibm/ILOG/CPLEX_Studio1210/concert/lib/x86-64_linux/static_pic/libconcert.a
-- CPLEX Bin Dir: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/bin/x86-64_linux
-- Found CPLEX: /opt/ibm/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic/libcplex.a
-- Configuring done
CMake Error at cpxutils/CMakeLists.txt:25 (add_executable):
Target "cpx_solver" links to target "Cplex::Cplex" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
CMake Error at cpxutils/CMakeLists.txt:13 (add_library):
Target "cpxutils" links to target "Cplex::Cplex" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
CMake Error at feaspump/CMakeLists.txt:17 (add_executable):
Target "fp2" links to target "Cplex::Cplex" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
CMake Error at feaspump/CMakeLists.txt:5 (add_library):
Target "fp" links to target "Cplex::Cplex" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
and this is cpxutils/CMakeLists.txt file.
cmake_minimum_required(VERSION 3.6)
# Find CPLEX library
find_package(CPLEX)
# Export CPLEX_FOUND for CMakeLists.txt files in other subdirectories
set(CPLEX_FOUND ${CPLEX_FOUND} PARENT_SCOPE)
if (CPLEX_FOUND)
# Define libcpxutils
add_library(cpxutils STATIC cpxutils.cpp cpxmacro.cpp model.cpp gomory.cpp cpxapp.cpp)
target_include_directories(cpxutils PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(cpxutils PUBLIC utils Cplex::Cplex)
add_library(Cpxutils::Lib ALIAS cpxutils)
# Define cpx_solver executable
add_executable(cpx_solver EXCLUDE_FROM_ALL cpx_solver.cpp)
target_include_directories(cpx_solver PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(cpx_solver PUBLIC utils Cpxutils::Lib)
else()
message(WARNING "Disabling CPXUTILS subproject")
endif()
i don't know why cannot find target despite CPLEX package is found.
i'm using WSL1 (Ubuntu) environment.
↑ problem solved. thanks for #Tsyvarev.
=== additional problem ===
Even though cmake commad works without any error, I cant find execution file. So I checked 'CMakeError.log' file then, there are some error.
This is CMakeError.log file.
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_92254/fast && /usr/bin/make -f CMakeFiles/cmTC_92254.dir/build.make CMakeFiles/cmTC_92254.dir/build
make[1]: Entering directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_92254.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD -o CMakeFiles/cmTC_92254.dir/src.c.o -c /mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_92254
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_92254.dir/link.txt --verbose=1
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD CMakeFiles/cmTC_92254.dir/src.c.o -o cmTC_92254
/usr/bin/ld: CMakeFiles/cmTC_92254.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x63): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_92254.dir/build.make:87: cmTC_92254] Error 1
make[1]: Leaving directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_92254/fast] Error 2
Source file was:
#include <pthread.h>
void* test_func(void* data)
{
return data;
}
int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);
return 0;
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_8ae2b/fast && /usr/bin/make -f CMakeFiles/cmTC_8ae2b.dir/build.make CMakeFiles/cmTC_8ae2b.dir/build
make[1]: Entering directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8ae2b.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_8ae2b.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_8ae2b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8ae2b.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_8ae2b.dir/CheckFunctionExists.c.o -o cmTC_8ae2b -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_8ae2b.dir/build.make:87: cmTC_8ae2b] Error 1
make[1]: Leaving directory '/mnt/c/Users/aero5010/Desktop/CBC+FP/CBC+FP/fp2/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_8ae2b/fast] Error 2
I think this is why i cant find execution file. But I dont know why this error occured despite pthread library is installed well...
** thank you for every advice about Stackoverflow Manners.

Cmake not changing build flags

Consider the following simple openMP program:
program hello
use OMP_LIB
implicit none
integer :: nthreads, tid
!$OMP PARALLEL PRIVATE(nthreads, tid)
tid = omp_get_thread_num()
nthreads = omp_get_num_threads()
! print *, "hello"
print *,"Thread:", tid, "of", nthreads
!$OMP END PARALLEL
end program hello
when i compile it as
gfortran -fopenmp hello.90 -o hello.x
I get output as:
Thread: 2 of 4
Thread: 1 of 4
Thread: 0 of 4
Thread: 3 of 4
as expected.
Now if i consider the following CMakeLists.txt file
cmake_minimum_required(VERSION 2.8.9)
project (hello Fortran)
enable_language(Fortran)
IF(NOT CMAKE_BUILD_TYPE)
message("NO BUILD TYPE PROVIDED")
message("DEFAULT BUILD TYPE SET TO 'Release'")
set(CMAKE_BUILD_TYPE 'Release')
ENDIF()
IF(${CMAKE_BUILD_TYPE} MATCHES RELEASE OR ${CMAKE_BUILD_TYPE} MATCHES Release)
message("MAKING RELEASE BUILD")
set(CMAKE_Fortran_FLAGS_RELEASE "-fopenmp")
message("FLAGS: ${CMAKE_Fortran_FLAGS_RELEASE}")
ENDIF()
add_executable(hello.x hello.f90)
Considering above file is right, it should add omp flag to make file and hence compile and run same, however
$ mkdir build; cd build
$ cmake ..
-- The Fortran compiler identification is GNU 6.1.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Check for working Fortran compiler: /usr/local/bin/gfortran
-- Check for working Fortran compiler: /usr/local/bin/gfortran - works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/local/bin/gfortran supports Fortran 90
-- Checking whether /usr/local/bin/gfortran supports Fortran 90 - yes
NO BUILD TYPE PROVIDED
DEFAULT BUILD TYPE SET TO 'Release'
MAKING RELEASE BUILD
FLAGS: -fopenmp
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/user/Programs/omp/build
$
$ make
Scanning dependencies of target hello.x
[ 50%] Building Fortran object CMakeFiles/hello.x.dir/hello.f90.o
[100%] Linking Fortran executable hello.x
Undefined symbols for architecture x86_64:
"_omp_get_num_threads_", referenced from:
_MAIN__ in hello.f90.o
"_omp_get_thread_num_", referenced from:
_MAIN__ in hello.f90.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [hello.x] Error 1
make[1]: *** [CMakeFiles/hello.x.dir/all] Error 2
Which is same as missing -fopenmp flag. How to add it?
The set command for CMAKE_BUILD_TYPE take a "non-string" argument apparently.
Changing
set(CMAKE_BUILD_TYPE 'Release')
to
set(CMAKE_BUILD_TYPE Release)
solved the problem for me. I first dug into the cache system to understand why your setting would not work and there was no reason. I found a CMAKE_Fortran_FLAGS_'Release' entry in ccmake and looked again at the variable CMAKE_BUILD_TYPE in the docs, and it takes values empty, Debug, Release, RelWithDebInfo, MinSizeRel (which I understood as being unquoted).

cmake unable to find libstdc++

(Using elementaryOS/Ubuntu)
I'm cross-compiling x265 and I encouraged annoying problem. For some reason cmake doesn't want to accept -static-libstdc++, because ld is apparently unable to find it. Cmake is built from Source Code, working pretty well without -static-libstdc++, if I then copy libstdc++-6.dll from mingw-w64 libs to folder with x265.exe, it works well, but I want it to build with it. mingw was built with this script and contains these libraries, but I don't know where is ld looking for them.
Here is output of cmake attempt:
-- cmake version 3.5.0-rc1
-- The C compiler identification is GNU 5.2.0
-- The CXX compiler identification is GNU 5.2.0
-- Check for working C compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-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: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++ -- broken
CMake Error at /usr/local/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler
"/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++" is not
able to compile a simple test program.
It fails with the following output:
Change Dir: /home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_e7611/fast"
/usr/bin/make -f CMakeFiles/cmTC_e7611.dir/build.make
CMakeFiles/cmTC_e7611.dir/build
make[1]: Entering directory
`/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_e7611.dir/testCXXCompiler.cxx.obj
/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-static-libgcc -static-libstdc++ -o
CMakeFiles/cmTC_e7611.dir/testCXXCompiler.cxx.obj -c
/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_e7611.exe
/usr/local/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_e7611.dir/link.txt --verbose=1
/usr/local/bin/cmake -E remove -f CMakeFiles/cmTC_e7611.dir/objects.a
/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-ar cr
CMakeFiles/cmTC_e7611.dir/objects.a #CMakeFiles/cmTC_e7611.dir/objects1.rsp
/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-static-libgcc -static-libstdc++ -Wl,--whole-archive
CMakeFiles/cmTC_e7611.dir/objects.a -Wl,--no-whole-archive -o
cmTC_e7611.exe -Wl,--out-implib,libcmTC_e7611.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
#CMakeFiles/cmTC_e7611.dir/linklibs.rsp
/home/myname/mingw-w64/mingw-w64-x86_64/lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld:
cannot find -lstdc++
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_e7611.exe] Error 1
make[1]: Leaving directory
`/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp'
make: *** [cmTC_e7611/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:19 (project)
-- Configuring incomplete, errors occurred!
See also "/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeOutput.log".
See also "/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeError.log".
make: *** No targets specified and no makefile found. Stop.
Cmake is run like code below.
cmake -DCMAKE_C_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc' -DCMAKE_CXX_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++' -DCMAKE_RC_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-windres' -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_TOOLCHAIN_FILE='/home/myname/x265/build/linux/build.cmake' ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
make ${MAKEFLAGS}
build.cmake file is not much important here, but it contains:
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_ASM_YASM_COMPILER yasm)
Any ideas how to make -static-libstdc++ work? I tried linking it in many folders, but I couldn't find out where is ld looking for it.
I managed to solve this. Source of my confusion was the fact that you can use -static-libgcc, so I thought even -static-libstdc++ should work. The problem was that there indeed were libraries, but not the .a files for libstdc++. These can be disabled using this parameter when using the script. Then both -static-lib options work well.
bash ./mingw-w64-build-3.6.7 --disable-shared