I'm trying to find the most convenient way of installing C++ libraries on macOS by using brew. It's my first approach to understand cmake with CLion.
I would like to use C++ library osmium
https://github.com/osmcode/libosmium:
$ brew install libosmium
$ brew list libosmium
/usr/local/Cellar/libosmium/2.15.4/include/osmium/ (198 files)
/usr/local/Cellar/libosmium/2.15.4/include/gdalcpp.hpp
/usr/local/Cellar/libosmium/2.15.4/libexec/include/ (12 files)
$ brew unlink libosmium --dry-run | xargs ls -l
/usr/local/include/gdalcpp.hpp -> ../Cellar/libosmium/2.15.4/include/gdalcpp.hpp
/usr/local/include/osmium -> ../Cellar/libosmium/2.15.4/include/osmium
Based on this post I tried to add paths:
find_library(LZMA_LIBRARY lzma)
message("lzma: ${LZMA_LIBRARY}")
list(APPEND CMAKE_SYSTEM_PREFIX_PATH /usr/local/include)
list(APPEND CMAKE_PREFIX_PATH /usr/local/include)
list(APPEND CMAKE_LIBRARY_PATH /usr/local/include)
find_library(OSMIUM_LIBRARY_LIB libosmium)
find_library(OSMIUM_LIBRARY osmium)
message("osmium: ${OSMIUM_LIBRARY}")
message("osmium_lib: ${OSMIUM_LIBRARY_LIB}")
Output:
lzma: /usr/local/lib/liblzma.dylib
osmium: OSMIUM_LIBRARY-NOTFOUND
osmium_lib: OSMIUM_LIBRARY_LIB-NOTFOUND
Then I played around with this answer:
if(APPLE)
set(CMAKE_FIND_FRAMEWORK ONLY)
message(APPLE)
find_library(OSM
NAMES osmium libosmium
HINTS /usr/local/include
REQUIRED)
message("OSM: ${OSM}")
if(OSM)
include_directories(${OSM}/Headers)
link_libraries(${OSM})
message("OSM found: ${OSM}")
endif()
endif()
Output:
APPLE
OSM: OSM-NOTFOUND
To make everything clear this is the code which I'm trying to execute and this is the error:
main.cpp:5:10: fatal error: 'osmium/io/any_input.hpp' file not found
#include <osmium/io/any_input.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Maybe there is a better way to integrate external libraries C++. I'm open for suggestions.