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

Cmake issue #4

Closed
mkcisse opened this issue Apr 14, 2020 · 8 comments
Closed

Cmake issue #4

mkcisse opened this issue Apr 14, 2020 · 8 comments

Comments

@mkcisse
Copy link

mkcisse commented Apr 14, 2020

Hi, I tried to compile openat with the following commands:
mkdir build
cd build
cmake ..
The Makefile does noot appear in the directory.
How to compile ths library ?

@galeone
Copy link
Owner

galeone commented Apr 15, 2020

Hi @mkcisse

The commands are correct. Have you also installed all the required dependencies and cloned the submodules too?

Which OS are you using?

I'm testing it right now locally and the following command sequence builds the library correctly.

Using archlinux I had to install first some system dependency:

sudo pacman -S spdlog gumbo-parser nlohmann-json
yay -S libcurlpp
#using yay because is available in the AUR, however you can install from the repo itself, going into
# libs/curlpp/ and giving mkdir build; cd build; cmake ..; make; sudo make install

Then clone the repo and install other dependencies I can't find on the repositories (that are shipped with openat).

git clone --recurse-submodules [email protected]:galeone/openat.git
cd openat/libs/gumbo/query/

Here's I just noticed there is a problem what make, and we have to fix it manually.
Open the file cmake/FindGumbo.cmake and comment the lines

#find_library(Gumbo_static_LIBRARY
#  NAMES libgumbo.a libgumbo_static.a gumbo.a gumbo_static.a libgumbo.lib libgumbo_static.lib gumbo.lib gumbo_static.lib
#  PATHS ${Gumbo_PKGCONF_LIBRARY_DIRS}
#)

and also change this line in this way:

# (just comment out Gumbo_static_LIBRARY)
set(Gumbo_PROCESS_LIBS Gumbo_LIBRARY)# Gumbo_static_LIBRARY)

After that

cd build
cmake ..
make
sudo make install
# now we have gumbo query installed in the system

Now we are ready to build openat, so go back go the openat repo, and

mkdir build
cd build
make ..
make

@mkcisse
Copy link
Author

mkcisse commented Apr 15, 2020

Which OS are you using?
Ubuntu 18..04 LTS bionic

This is the error message:
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message)

@galeone
Copy link
Owner

galeone commented Apr 15, 2020

Yes, is the error you get while building gumbo query - manually apply the fix as I described (commenting the lines) and it should work

@mkcisse
Copy link
Author

mkcisse commented Apr 15, 2020

It works !
However, i have the same issue with :
CMake Error at src/CMakeLists.txt:16 (find_package): By not providing "Findnlohmann_json.cmake" in CMAKE_MODULE_PATH this
I already ran : apt-get install -y nlohmann-json-dev

@galeone
Copy link
Owner

galeone commented Apr 15, 2020

uhm.. it should work - the integration with cmake of the JSON library is made exactly as suggested from the documentation https://github.com/nlohmann/json#cmake

However, looking at some comments into that repo, I can see that is a pretty common issue: nlohmann/json#1977 (comment)

Maybe on Ubuntu the nlohmann-json-dev package is installed in some non standard location?

I don't know I'm sorry, and I also don't have an ubuntu machine to use to test

@mkcisse
Copy link
Author

mkcisse commented Apr 15, 2020

I downloaded and compiled nlohmann_json from git repo: https://github.com/nlohmann/json
But another issue:
CMake Error at src/CMakeLists.txt:21 (add_library): Target "openat" links to target "Threads::Threads" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

@mkcisse
Copy link
Author

mkcisse commented Apr 18, 2020

I got it. The issue comes from the default nlohmann_json on Ubuntu. No problem when I compiled nlohmann_json. This is the last result of cmake .. command:

-- 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
-- Configuring done
CMake Error at src/CMakeLists.txt:21 (add_library):
Target "openat" links to target "Threads::Threads" 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 tests/CMakeLists.txt:10 (add_executable):
Target "openat_tests" links to target "Threads::Threads" 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
-- Build files have been written to: /home/mkcisse/openat/build

@galeone
Copy link
Owner

galeone commented Apr 19, 2020

Happy you solved with the JSON stuff!

For this last problem, yes this is a bug in my cmake. I forgot to add the line find_package(Threads).

I fixed it in the last commit on master branch. Update the repo to the latest version (git pull origin master) and try again 👍

@galeone galeone closed this as completed Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants