cmake of "libarchive" fails on OSX Maverick - xcode

I'm trying to compile libarchive using cmake -G Xcode libarchive according to the official build instructions
I ve cmake 2.8.12 installed via mac port and use the current CMakeList.txt
cmake -G Xcode libarchive outputs
-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:177 (SET_TARGET_PROPERTIES):
set_target_properties called with incorrect number of arguments.
CMake Error at CMakeLists.txt:193 (INSTALL_MAN):
Unknown CMake command "INSTALL_MAN".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 2.8)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

Configure from the top-level directory (the one containing the README file):
$ cmake -G Xcode .
the subsidiary CMakeLists.txt files in various directories are not complete and cannot be used by themselves.

Related

How can I make homebrew's cmake to use system clang

OS: MacOS 12.4
Installed cmake with
brew install cmake
cmake version 3.23.3
Installed clang with
xcode-select --install
clang++ version is 13.1.6
Trying to build ccls:
git clone https://github.com/MaskRay/ccls.git
mkdir build && cd build
cmake ..
And getting following output
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- The C compiler identification is AppleClang 13.1.6.13160021
-- 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
-- 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
-- Setting build type to 'Release' as none was specified.
CMake Error at CMakeLists.txt:72 (find_package):
By not providing "FindClang.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Clang", but
CMake did not find one.
Could not find a package configuration file provided by "Clang" with any of
the following names:
ClangConfig.cmake
clang-config.cmake
Add the installation prefix of "Clang" to CMAKE_PREFIX_PATH or set
"Clang_DIR" to a directory containing one of the above files. If "Clang"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/Users/umed/projects/MaskRay/ccls/build/CMakeFiles/CMakeOutput.log".
See also "/Users/umed/projects/MaskRay/ccls/build/CMakeFiles/CMakeError.log".
Is there anyway to make brew's cmake work with system clang?
The question is not correct. CMake uses the system clang successfully, but it can't find clang libraries required by the project.
The Build manual lists the requirements, one of them is
Clang+LLVM headers and libraries, version >= 7
You get errors because you have not provided that dependency.
brew install llvm#13

Handling a version mismatch of the compiler version between conan and CMake

I am developing on macOS with Apple-clang v12 being the default compiler via the Xcode installation. Since valgrind still does not support Big Sur and the Apple version does not support Google Sanitizers I have to manually install llvm v11.1 via homebrew to leverage Google Sanitizers to have any memory leak detection tool enabled.
Unfortunately this causes some issues with conan and its integration with CMake and CLion, my IDE. Since my dependencies do not provide binaries for my architecture using clang instead of Apple-clang they have to built locally. Unfortunately conan and CMake error when invoking them with two contradictory error messages:
conan install /Users/near/Code/personal/blight -if=/Users/near/Code/personal/blight/cmake-build-debug -pr=LLVM11Debug --build=missing
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=clang
compiler.libcxx=libstdc++
compiler.version=11
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
fmt/7.1.3: WARN: Package binary is corrupted, removing: 2284170e72f485ebb586c7bd784f294475c25e5e
conanfile.txt: Installing package
Requirements
fmt/7.1.3 from 'conan-center' - Cache
spdlog/1.8.5 from 'conan-center' - Cache
Packages
fmt/7.1.3:2284170e72f485ebb586c7bd784f294475c25e5e - Build
spdlog/1.8.5:b744aef5cdad24eec65bb267843e16ad74c9ad39 - Build
Installing (downloading, building) binaries...
fmt/7.1.3: WARN: Build folder is dirty, removing it: /Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e
fmt/7.1.3: Copying sources to build folder
fmt/7.1.3: Building your package in /Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e
fmt/7.1.3: Generator cmake created conanbuildinfo.cmake
fmt/7.1.3: Calling build()
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- 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
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: Compiler Clang>=8, checking major version 11
-- Conan: Checking correct version: 12
CMake Error at conanbuildinfo.cmake:402 (message):
Detected a mismatch for the compiler version between your conan profile
settings and CMake:
Compiler version specified in your conan profile: 11
Compiler version detected in CMake: 12.0
Please check your conan profile settings (conan profile show
[default|your_profile_name])
P.S. You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to
disable this check.
Call Stack (most recent call first):
conanbuildinfo.cmake:499 (conan_error_compiler_version)
conanbuildinfo.cmake:589 (check_compiler_version)
conanbuildinfo.cmake:141 (conan_check_compiler)
CMakeLists.txt:5 (conan_basic_setup)
-- Configuring incomplete, errors occurred!
See also "/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e/build_subfolder/CMakeFiles/CMakeOutput.log".
See also "/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e/build_subfolder/CMakeFiles/CMakeError.log".
fmt/7.1.3:
fmt/7.1.3: ERROR: Package '2284170e72f485ebb586c7bd784f294475c25e5e' build failed
fmt/7.1.3: WARN: Build folder /Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e
ERROR: fmt/7.1.3: Error in build() method, line 63
cmake = self._configure_cmake()
while calling '_configure_cmake', line 56
self._cmake.configure(build_folder=self._build_subfolder)
ConanException: Error 1 while executing cd '/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e/build_subfolder' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="11" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/Users/near/.conan/data/fmt/7.1.3/_/_/package/2284170e72f485ebb586c7bd784f294475c25e5e" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DFMT_DOC="False" -DFMT_TEST="False" -DFMT_INSTALL="True" -DFMT_LIB_DIR="lib" -Wno-dev '/Users/near/.conan/data/fmt/7.1.3/_/_/build/2284170e72f485ebb586c7bd784f294475c25e5e'
"/Users/near/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/203.7717.62/CLion.app/Contents/bin/cmake/mac/bin/cmake" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=clang++ -G "CodeBlocks - Unix Makefiles" /Users/near/Code/personal/blight
-- The CXX compiler identification is Clang 11.1.0
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/near/Code/personal/blight/cmake-build-debug
CMake Error at cmake-build-debug/conanbuildinfo.cmake:626 (message):
Detected a mismatch for the compiler version between your conan profile
settings and CMake:
Compiler version specified in your conan profile: 12.0
Compiler version detected in CMake: 11.1
Please check your conan profile settings (conan profile show
[default|your_profile_name])
P.S. You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to
disable this check.
Call Stack (most recent call first):
cmake-build-debug/conanbuildinfo.cmake:728 (conan_error_compiler_version)
cmake-build-debug/conanbuildinfo.cmake:813 (check_compiler_version)
cmake-build-debug/conanbuildinfo.cmake:365 (conan_check_compiler)
CMakeLists.txt:13 (conan_basic_setup)
-- Configuring incomplete, errors occurred!
See also "/Users/near/Code/personal/blight/cmake-build-debug/CMakeFiles/CMakeOutput.log".
This is the output seen in the CMake output window of CLion. The first invocation has CMake think Apple-clang is my compiler while conan is configured to use the llvm version and on the second step (most likely invoked by conan_basic_setup in my CMakeLists.txt) the correct CMake compiler is chosen but Conan ends up without a profile hence a version mismatch.
In the CLion settings I have already overwritten the c++ compiler with the llvm v11.1 compiler:
What's the correct solution to properly configure both to use the llvm v11.1 compiler? I personally do not want to enable the CONAN_DISABLE_CHECK_COMPILER CMake variable as it is unclear which compiler will be used to compile dependencies in the end.
Previously posted questions only suggest intentionally using the higher version which is not what I want:
CMake Error: mismatch for the compiler version between your conan profile
Both packages I see in your log file, spdlog and fmt, are available as header only configuration.
So if these are your only dependencies, you can simply set the option to use them header only, and this will eliminate the problem since there is nothing to build for these packages.
One way doing so is adding the settings into the profile you use, into the option section, like that
[options]
fmt:header_only=True
spdlog:header_only=True
I was able to find a solution albeit by disabling the Conan integration first. With a clean build directory I went in there and had to invoke Conan manually as follows:
CC=clang CXX=clang++ conan install .. -pr=LLVM11Debug --build=missing
Afterwards it was possible run build with CMake and clang 11 configured in the UI of CLion. The issue was that the Conan integration plugin does not provide a direct way to set the compiler using the environment variables and it does not get the compiler from the Toolchain options in CLion.

Make Error : Unknown CMake command "set_dist_list" when building mongo c driver 1.17.3

I am trying to build a mongocxx c driver with the latest release. I am doing this with minGW makefiles and am using cmake-gui.
My configuration for cmake is:
Source input:
C:/****/mongo-c-driver-1.17.3/build
Build destination:
C:/mongo-c-driver
The output is the following:
CMake Warning (dev) in CMakeLists.txt:
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
The C compiler identification is GNU 4.8.0
The CXX compiler identification is GNU 4.8.0
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: C:/Qt5.2.1/Tools/mingw48_32/bin/gcc.exe - 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: C:/Qt5.2.1/Tools/mingw48_32/bin/g++.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at cmake/make_dist/CMakeLists.txt:7 (set_dist_list):
Unknown CMake command "set_dist_list".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.19)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
See also "C:/mongo-c-driver/CMakeFiles/CMakeOutput.log".

CLion not using the correct compiler?

I get this output when I run cmake in the CLion environment. When I run outside of CLion I get no warnings and everything works fine.
The really strange part about this is I specify clang and clang++ for the compiler, I do this in the CC and CXX environment variables as well as in the toolchain settings in CLion, but it is saying the g++ and gcc are having errors. However, no where in any of my config for CLion have I mentioned gcc or g++.
Where are these coming from and how can I fix it? It would be really nice to actually build this project from my IDE.
These issues started after the CLion 2017.3 update.
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/make -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G "CodeBlocks - Unix Makefiles" /home/rkratt/src
-- The C compiler identification is Clang 3.9.0
-- The CXX compiler identification is Clang 3.9.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- 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/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Building src in Debug mode.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rkratt/src/cmake-build-debug
Problems were encountered while collecting compiler information:
g++: error: unrecognized command line option '-fopenmp=libomp'
gcc: error: unrecognized command line option '-fopenmp=libomp'
[Finished]
Ryan, it seems that CMake associated g++/gcc with specific targets in you project. I suspect that building will also fail. Could you check that?
If you are not able to resolve the problem, please file a ticket and we'll try to help.

CMake cannot find Boost on OS X with brew

I'm trying to use CMake to compile another library and it requires Boost.
I have installed both CMake and Boost using brew on OS X 10.10 Yosemite, but CMake refuses to find it. Boost is located in /usr/local/Cellar/boost/1.55.0_2
I've tried the following:
Setting -DBoost_DIR and -DBOOST_ROOT with the above path
Setting -DBoost_INCLUDE_DIR and -DBOOST_INCLUDEDIR with the above path + /include
Setting any and all of these options in the CMakeLists.txt file
Compiling Boost myself, and pointing the above vars to my own build
Trying out similar solutions to the same problem here, here, and here. The only answer that I found that mentioned brew on OS X was this one, and the same solution did not work for me.
Why is CMake blatantly ignoring my instructions? :(
Edit: CMake output from -DBoost_DEBUG=ON
I found a separate homebrew package of boost-python. With it installed, CMake does find Boost:
brew install boost-python
gives me
> mkdir build ; ( cd build ; cmake .. )
-- The C compiler identification is AppleClang 6.0.0.6000056
-- The CXX compiler identification is AppleClang 6.0.0.6000056
-- 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
-- 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
-- Found PythonInterp: /usr/local/bin/python (found version "2.7.9")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.5")
-- Boost version: 1.56.0
-- Found the following Boost libraries:
-- python
-- Configuring done
-- Generating done
(I have problems linking, but that's another story)
I was also having trouble compiling something with C++/Python/Boost/CMake (Specifically, I was trying to build https://github.com/mapillary/OpenSfM).
I was getting an error like this
Linking CXX shared library .../OpenSfM/opensfm/csfm.so
Undefined symbols for architecture x86_64:
"boost::python::instance_holder::deallocate(_object*, void*)", referenced from:
Undefined symbols for architecture x86_64:
"boost::python::instance_holder::deallocate(_object*, void*)", referenced from:
...
Inspired by the above comment, I tried to find this mythical "boost-python", but it didn't exist. Instead, I wound up using homebrew to reinstall normal boost with python.
brew install boost --with-python
That worked. CMake could now find boost and whatever python boost things it needed, and the compilation succeeded.
In my case upgrading both cmake and boost to their newest version solved the problem
brew upgrade boost cmake

Resources