Setting SDK on cross-compilation to OSX in CMake - macos

I'm cross compiling from Linux to OSX using CMake. To do this I use a toolchain file, so the call is like this:
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchains/c.apple.universal.cmake .
The toolchain file looks like this:
SET(CMAKE_SYSTEM_NAME Darwin)
SET(CMAKE_SYSTEM_PROCESSOR universal)
# set compilers...
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/c.apple.common.cmake")
And the other one:
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../Modules/CMakeMacroSetCCache.cmake")
# specify the cross compiler
SET_CCACHE(CMAKE_C_COMPILER i686-apple-darwin10-gcc)
SET_CCACHE(CMAKE_CXX_COMPILER i686-apple-darwin10-g++)
SET(CMAKE_RANLIB i686-apple-darwin10-ranlib CACHE STRING "" FORCE)
SET(CMAKE_LIPO i686-apple-darwin10-lipo CACHE STRING "" FORCE)
SET(OSX104_SDK "/usr/lib/apple/SDKs/MacOSX10.4.sdk")
SET(OSX105_SDK "/usr/lib/apple/SDKs/MacOSX10.5.sdk")
# set SDK
SET(CMAKE_OSX_DEPLOYMENT_TARGET )
IF(EXISTS ${OSX104_SDK})
SET(CMAKE_OSX_SYSROOT ${OSX104_SDK})
ELSEIF(EXISTS ${OSX105_SDK})
SET(CMAKE_OSX_SYSROOT ${OSX105_SDK})
ELSE()
MESSAGE(FATAL_ERROR "No OSX SDK found!")
ENDIF()
MESSAGE(STATUS "Using OSX SDK at ${CMAKE_OSX_SYSROOT}")
SET(CMAKE_PREFIX_PATH ${CMAKE_OSX_SYSROOT})
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
SET(BOOST_ROOT ${CMAKE_PREFIX_PATH})
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
This works so far, but somehow CMake resets CMAKE_OSX_SYSROOT at some point. The output I get is:
-- Set CMAKE_C_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-gcc
-- Set CMAKE_CXX_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-g++
-- Using OSX SDK at /usr/lib/apple/SDKs/MacOSX10.5.sdk
-- Set CMAKE_C_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-gcc
-- Set CMAKE_CXX_COMPILER to /usr/lib/ccache-lipo/i686-apple-darwin10-g++
-- Using OSX SDK at /usr/lib/apple/SDKs/MacOSX10.5.sdk
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- 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 - yes
-- Check for working C compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-gcc
-- Check for working C compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-g++
-- Check for working CXX compiler: /usr/lib/ccache-lipo/i686-apple-darwin10-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Used Toolchain definition file '/srv/jenkins/.../cmake/toolchains/c.apple.universal.cmake'
-- Configuring for cross-compiling to Darwin on universal
-- Using platform config cmake/darwin.cmake
-- Checking /Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.B.dylib for possible architectures
The last 3 lines are from the CMakeList.txt. The correct toolchain file was used (it's just a message), SYSTEM_NAME and SYSTEM_PROCESSOR are set correctly but the OSX SDK is wrong. The corresponding CMake code comes from a macro that will set CMAKE_OSX_ARCHITECTURES if it wasn't set before (which is the case here). The line is:
MESSAGE(STATUS "Checking ${CMAKE_OSX_SYSROOT}/usr/lib/libSystem.B.dylib for possible architectures")
Am I using CMake wrongly here? Why is CMake resetting the OSX_SYSROOT? According to http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_OSX_SYSROOT.html it should also affect FIND* commands but I needed to set CMAKE_FIND_ROOT_PATH for it to work.
Strange enough, it worked yesterday. Cleaning the whole build-directory (which I'm sure I did yesterday too) and rerunning CMake resets CMAKE_OSX_SYSROOT now.
If this makes a difference: PROJECT is called before the inclusion end execution of the macro, that shows the wrong sysroot.

The solution I found is to set the variable into the cache. This way it "survives" during CMake processing:
SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT} CACHE PATH "..." FORCE)

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

How to set adf_path and build a project for LYRA-T board?

"Warn about uninitialized values.
CMake Warning (dev) at CMakeLists.txt:5 (include):
uninitialized variable 'ADF_PATH'
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:5 (include):
include could not find load file:
/CMakeLists.txt
-- Found Git: C:/Program Files/Git/bin/git.exe (found version "2.25.1.windows.1")
-- Unexpected file in components directory: C:/Users/Embedded/Desktop/esp/esp-idf/components/.gitkeep
-- ccache will be used for faster recompilation
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe -- 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: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe
-- Check for working CXX compiler: C:/Users/Embedded/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32
warning: the default selection SR_RUN_WM6_CORE1 (undefined) of (defined at C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-sr/Kconfig.projbuild:83) is not contained in the choice
warning: the default selection CONFIG_SR_MN1_MODEL_QUANT (undefined) of (defined at C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-sr/Kconfig.projbuild:100) is not contained in the choice
-- App "play_mp3" version: v2.0-beta2-21-g30403e2-dirty
-- Found PythonInterp: C:/Users/Embedded/.espressif/python_env/idf4.2_py2.7_env/Scripts/python.exe (found version "2.7.12")
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-adf/examples/get-started/play_mp3/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp32/ld/esp32.project.ld.in
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs-time.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Current board name is CONFIG_ESP_LYRAT_V4_3_BOARD
-- Components: adf_utils app_trace app_update asio audio_board audio_hal audio_pipeline audio_sal audio_stream bluetooth_service bootloader bootloader_support bt cbor clouds coap console cxx display_service driver dueros_service efuse esp-adf-libs esp-sr esp-tls esp32 esp_actions esp_adc_cal esp_common esp_dispatcher esp_eth esp_event esp_gdbstub esp_http_client esp_http_server esp_https_ota esp_https_server esp_local_ctrl esp_netif esp_peripherals esp_ringbuf esp_rom esp_serial_slave_link esp_timer esp_websocket_client esp_wifi espcoredump esptool_py expat fatfs freemodbus freertos heap idf_test input_key_service jsmn json libsodium log lwip main mbedtls mdns mqtt newlib nghttp nvs_flash openssl partition_table perfmon playlist protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport tcpip_adapter ulp unity vfs wear_levelling wifi_provisioning wifi_service wpa_supplicant xtensa
-- Component paths: C:/Users/Embedded/Desktop/esp/esp-idf/components/adf_utils C:/Users/Embedded/Desktop/esp/esp-idf/components/app_trace C:/Users/Embedded/Desktop/esp/esp-idf/components/app_update C:/Users/Embedded/Desktop/esp/esp-idf/components/asio C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_board C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_hal C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_pipeline C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_sal C:/Users/Embedded/Desktop/esp/esp-idf/components/audio_stream C:/Users/Embedded/Desktop/esp/esp-idf/components/bluetooth_service C:/Users/Embedded/Desktop/esp/esp-idf/components/bootloader C:/Users/Embedded/Desktop/esp/esp-idf/components/bootloader_support C:/Users/Embedded/Desktop/esp/esp-idf/components/bt C:/Users/Embedded/Desktop/esp/esp-idf/components/cbor C:/Users/Embedded/Desktop/esp/esp-idf/components/clouds C:/Users/Embedded/Desktop/esp/esp-idf/components/coap C:/Users/Embedded/Desktop/esp/esp-idf/components/console C:/Users/Embedded/Desktop/esp/esp-idf/components/cxx C:/Users/Embedded/Desktop/esp/esp-idf/components/display_service C:/Users/Embedded/Desktop/esp/esp-idf/components/driver C:/Users/Embedded/Desktop/esp/esp-idf/components/dueros_service C:/Users/Embedded/Desktop/esp/esp-idf/components/efuse C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-adf-libs C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-sr C:/Users/Embedded/Desktop/esp/esp-idf/components/esp-tls C:/Users/Embedded/Desktop/esp/esp-idf/components/esp32 C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_actions C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_adc_cal C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_common C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_dispatcher C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_eth C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_event C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_gdbstub C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_http_client C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_http_server C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_https_ota C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_https_server C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_local_ctrl C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_netif C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_peripherals C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_ringbuf C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_rom C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_serial_slave_link C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_timer C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_websocket_client C:/Users/Embedded/Desktop/esp/esp-idf/components/esp_wifi C:/Users/Embedded/Desktop/esp/esp-idf/components/espcoredump C:/Users/Embedded/Desktop/esp/esp-idf/components/esptool_py C:/Users/Embedded/Desktop/esp/esp-idf/components/expat C:/Users/Embedded/Desktop/esp/esp-idf/components/fatfs C:/Users/Embedded/Desktop/esp/esp-idf/components/freemodbus C:/Users/Embedded/Desktop/esp/esp-idf/components/freertos C:/Users/Embedded/Desktop/esp/esp-idf/components/heap C:/Users/Embedded/Desktop/esp/esp-idf/components/idf_test C:/Users/Embedded/Desktop/esp/esp-idf/components/input_key_service C:/Users/Embedded/Desktop/esp/esp-idf/components/jsmn C:/Users/Embedded/Desktop/esp/esp-idf/components/json C:/Users/Embedded/Desktop/esp/esp-idf/components/libsodium C:/Users/Embedded/Desktop/esp/esp-idf/components/log C:/Users/Embedded/Desktop/esp/esp-idf/components/lwip C:/Users/Embedded/Desktop/esp/esp-adf/examples/get-started/play_mp3/main C:/Users/Embedded/Desktop/esp/esp-idf/components/mbedtls C:/Users/Embedded/Desktop/esp/esp-idf/components/mdns C:/Users/Embedded/Desktop/esp/esp-idf/components/mqtt C:/Users/Embedded/Desktop/esp/esp-idf/components/newlib C:/Users/Embedded/Desktop/esp/esp-idf/components/nghttp C:/Users/Embedded/Desktop/esp/esp-idf/components/nvs_flash C:/Users/Embedded/Desktop/esp/esp-idf/components/openssl C:/Users/Embedded/Desktop/esp/esp-idf/components/partition_table C:/Users/Embedded/Desktop/esp/esp-idf/components/perfmon C:/Users/Embedded/Desktop/esp/esp-idf/components/playlist C:/Users/Embedded/Desktop/esp/esp-idf/components/protobuf-c C:/Users/Embedded/Desktop/esp/esp-idf/components/protocomm C:/Users/Embedded/Desktop/esp/esp-idf/components/pthread C:/Users/Embedded/Desktop/esp/esp-idf/components/sdmmc C:/Users/Embedded/Desktop/esp/esp-idf/components/soc C:/Users/Embedded/Desktop/esp/esp-idf/components/spi_flash C:/Users/Embedded/Desktop/esp/esp-idf/components/spiffs C:/Users/Embedded/Desktop/esp/esp-idf/components/tcp_transport C:/Users/Embedded/Desktop/esp/esp-idf/components/tcpip_adapter C:/Users/Embedded/Desktop/esp/esp-idf/components/ulp C:/Users/Embedded/Desktop/esp/esp-idf/components/unity C:/Users/Embedded/Desktop/esp/esp-idf/components/vfs C:/Users/Embedded/Desktop/esp/esp-idf/components/wear_levelling C:/Users/Embedded/Desktop/esp/esp-idf/components/wifi_provisioning C:/Users/Embedded/Desktop/esp/esp-idf/components/wifi_service C:/Users/Embedded/Desktop/esp/esp-idf/components/wpa_supplicant C:/Users/Embedded/Desktop/esp/esp-idf/components/xtensa
-- Configuring incomplete, errors occurred!
See also "C:/Users/Embedded/Desktop/esp/esp-adf/examples/get-started/play_mp3/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1
"
if using Windows :
in IDF command prompt
set ADF_PATH = "C:\Users\username\Desktop\esp-adf"
to ensure your path
echo %ADF_PATH%
Permanent solution :add the following at the end of export.bat (found in IDF folder)
set ADF_PATH = "C:\Users\username\Desktop\esp-adf"

CMake uses gcc from devtoolset but links against wrong libgcc and libstd++

I have a project with CMake, devtoolset-6 and standart gcc 4.8.2 installed.
CMake correctly finds correct gcc:
-- The C compiler identification is GNU 6.2.1
-- The CXX compiler identification is GNU 6.2.1
-- Check for working C compiler: /opt/rh/devtoolset-6/root/usr/bin/cc
-- Check for working C compiler: /opt/rh/devtoolset-6/root/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: /opt/rh/devtoolset-6/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-6/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
PATH and LD_LIBRARY_PATH are set
echo $PATH
/opt/rh/devtoolset-6/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
echo $LD_LIBRARY_PATH
/opt/rh/devtoolset-6/root/usr/lib64:/opt/rh/devtoolset-6/root/usr/lib
The project builds correctly but lings against wrong libgcc and libstd++ from /usr/lib64
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f60b47bf000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f60b45a8000)
What is wrong?
This is not a bug, but the feature! :)
RH DevToolset is not just an alternative compiler built on the side. It's libstdc++ is an LD script. The new C++11 (and above) symbols in your binary would be resolved via static library (built specially and shipped w/ DTS). However, old symbols (existed in the OS's shipped libstdc++) going to be resolved dynamically. That is why ldd shows you libstdc++ from the /usr/lib64! Also, it has Old C++ ABI by default... to make your modern C++ code compatible w/ old libstdc++ DSO.
This feature allows you to use modern C++ standards, and produce a binary which can be executed in the original OS (CentOS/RHEL) w/o any additional "redistributable" shared libraries.
JFYI, if you use strip, make sure you use it from DTS and not the "native" one (shipped in binutils from the OS)! Otherwise, really bad things can happen.

CLion not finding Boost headers

Windows build 18362
CLion 2019.1.2
Boost 1.67
Toolchain mingw-64
I'm trying to setup a simple project in Clion using Boost. The problem is when I include a boost header #include <boost/log/trivial.hpp>, CLion cannot find the header file.
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.14)
project(BoostTest)
set(CMAKE_CXX_STANDARD 14)
add_executable(BoostTest main.cpp)
set(BOOST_ROOT "$ENV{HOMEPATH}/.local/share/boost")
set(Boost_ARCHITECTURE "-x64")
find_package(Boost REQUIRED COMPONENTS log)
message(STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}")
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(BoostTest ${Boost_LIBRARIES})
The output of CMake seems to indicate that everything is found correctly:
C:\Users\michael\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\191.6707.69\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\michael\projects\sml\BoostTest
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/mingw/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/mingw/mingw64/bin/gcc.exe -- 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: C:/mingw/mingw64/bin/g++.exe
-- Check for working CXX compiler: C:/mingw/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Boost version: 1.67.0
-- Found the following Boost libraries:
-- log
-- date_time
-- log_setup
-- system
-- filesystem
-- thread
-- regex
-- chrono
-- atomic
-- Boost_INCLUDE_DIR: /Users/michael/.local/share/boost/include/boost-1_67
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/michael/projects/sml/BoostTest/cmake-build-debug
But still CLion cannot find the header file in the include statement. The header files are indeed present at the location specified in Boost_INCLUDE_DIR. I'm new to Windows and CLion , and I probably missing some really basic, but I cannot see it. Any clues?
After getting this to work from the command line, I've come to the conclusion that is a CLion bug. If the include directory does not include the drive designation (i.e., C:/), CLion is not finding the header files.
Here is a CMakeLists.txt that works for CLion:
cmake_minimum_required(VERSION 3.14)
project(boost-test)
set(CMAKE_CXX_STANDARD 14)
add_executable(boost-test main.cpp)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS log)
if (Boost_FOUND)
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
include_directories("C:${Boost_INCLUDE_DIRS}")
target_link_libraries(boost-test ${Boost_LIBRARIES})
endif()
This same file works from the command line without the hacky C: added to the include_directories.
Note that even without the C:, CLion will build and run the code just fine. So the issue seems to be solely with finding the header files based on include_directories().
I just tried doing this from Ubuntu, and no need for any hack to get this working.
find_package(Boost 1.40 COMPONENTS system filesystem program_options log REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
Not sure it may help, but at least it works somewhere.

cmake of "libarchive" fails on OSX Maverick

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.

Resources