Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew on OSX doesn't install cmake config file #1576

Closed
jambolo opened this issue Apr 21, 2019 · 5 comments
Closed

Homebrew on OSX doesn't install cmake config file #1576

jambolo opened this issue Apr 21, 2019 · 5 comments

Comments

@jambolo
Copy link

jambolo commented Apr 21, 2019

In short, CMake find_package() fails for me, presumably because the Homebrew on OSX installation oh nlohmamm_json does not install the necessary CMake config file. I don't use Homebrew or OSX much, so I'm not 100% sure of what might be wrong, but I currently use several other packages installed with Homebrew successfully. Previously, I used nlohmann_json as a submodule, but switching to find_package() now leads to this problem.

I ran the commands in the readme:

brew tap nlohmann/json
brew install nlohmann_json

Here is output from Homebrew:

$ brew tap nlohmann/json
Updating Homebrew...
==> Auto-updated Homebrew!
...
==> Tapping nlohmann/json
Cloning into '/usr/local/Homebrew/Library/Taps/nlohmann/homebrew-json'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 2 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
Tapped 1 formula (33 files, 32.1KB).
$ brew install nlohmann_json
==> Installing nlohmann_json from nlohmann/json
==> Downloading https://github.com/nlohmann/json/archive/v3.6.1.tar.gz
==> Downloading from https://codeload.github.com/nlohmann/json/tar.gz/v3.6.1
######################################################################## 100.0%
==> Caveats
If built with CMake support, you can use find_package to use the library.

Without it, please set your include path accordingly:
CPPFLAGS: -I/usr/local/opt/nlohmann_json/include
==> Summary
🍺  /usr/local/Cellar/nlohmann_json/3.6.1: 5 files, 935.7KB, built in 36 seconds

Here is the contents of /usr/local/opt/nlohmann_json:

ChangeLog.md		README.md
INSTALL_RECEIPT.json	include

In other installations, there is usually a cmake folder with a CMake configuation script, but there is none here.

INSTALL_RECEIPT.json, if that helps:

{"homebrew_version":"2.1.1","used_options":[],"unused_options":["--with-cmake"],"built_as_bottle":false,"poured_from_bottle":false,"installed_as_dependency":false,"installed_on_request":true,"changed_files":null,"time":1555784893,"source_modified_time":1553112223,"HEAD":"b4f73e61649fcfc5aaa779c311e2514619ce01e7","stdlib":null,"compiler":"clang","aliases":[],"runtime_dependencies":[],"source":{"path":"/usr/local/Homebrew/Library/Taps/nlohmann/homebrew-json/nlohmann_json.rb","tap":"nlohmann/json","spec":"stable","versions":{"stable":"3.6.1","devel":"","head":"HEAD","version_scheme":0}}}

My CMakeLists.txt:

cmake_minimum_required (VERSION 3.10)
project(BackgammonPlayer VERSION 1.0.0 LANGUAGES CXX)

option(BUILD_SHARED_LIBS       "Build libraries as DLLs"                    FALSE)

find_package(nlohmann_json REQUIRED)
find_package(Misc REQUIRED)
...

The CMake configuration error:

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "Findnlohmann_json.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "nlohmann_json", but CMake did not find one.

  Could not find a package configuration file provided by "nlohmann_json"
  with any of the following names:

    nlohmann_jsonConfig.cmake
    nlohmann_json-config.cmake

  Add the installation prefix of "nlohmann_json" to CMAKE_PREFIX_PATH or set
  "nlohmann_json_DIR" to a directory containing one of the above files.  If
  "nlohmann_json" provides a separate development package or SDK, be sure it
  has been installed.
@geekskick
Copy link

I also have this issue, I also tried using the PATHS part of the find_package command as follows:
find_package(nlohmann_json REQUIRED PATHS /usr/local/Cellar/nlohmann_json/3.6.1/ NO_DEFAULT_PATH) with the same output as above.

@stale
Copy link

stale bot commented Jun 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jun 19, 2019
@nlohmann nlohmann removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jun 21, 2019
@nickaein
Copy link
Contributor

This might be totally unrelated (since the package seems to get downloaded) but can you instead use the following command to install (note the dash instead of underscore in the name of package):

brew install nlohmann-json

@jambolo
Copy link
Author

jambolo commented Jun 22, 2019

brew install nlohmann-json

/usr/local/include/nlohmann
/usr/local/lib/cmake/nlohmann_json
/usr/local/opt/nlohmann-json

Using dash instead of underscore fixed it. And I see now that the docs have a dash, so it is my mistake. I'm curious why brew accepts "brew install nlohmann_json"

@jambolo jambolo closed this as completed Jun 22, 2019
@nickaein
Copy link
Contributor

@jambolo: The mistake was in the documentation that was fixed a while ago (#1620). I wasn't aware of your issue so sorry for not informing you.

I'm curious why brew accepts "brew install nlohmann_json"

Yeah, it totally acts as the package is found and even successfully installed. That's very misleading.

BTW, are you John Bolton, the adviser to US president? If so, please don't attack us Iranians :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants