-
Notifications
You must be signed in to change notification settings - Fork 225
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
Added support to build project with CMake #4
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Hi there, any news about this? |
@devsdmf Hi. As I can see, your CMake configuration is incomplete. You don't provide targets for library and tests (no calls for add_library/add_tests). Which is curious, because this project is intended to be used as library at first. |
Hi, would you mind changing the url of the submodule from git@github.com:abseil/abseil-cpp.git into https://github.com/abseil/abseil-cpp.git because then building should work for everyone, while the git@ url requires ssh access afaik edit: also +1 for adding the test and library. thanks! |
Awesome, I'll do the changes tonight, thanks for the feedbacks! (: |
Done, added static and shared libraries and tests |
Also, I changed the dependency management approach to use configure time based resolution instead of git submodules. |
As of commit 5a7d82f, when following the instructions, using "make" after "cmake .. -DENABLE_TESTS=1" there's a linker error: /usr/bin/ld: c-build/libs/abseil-cpp-src/absl/strings/libabsl_absl_strings.a(ascii.cc.o): relocation R_X86_64_PC32 against symbol `_ZN4absl14ascii_internal8kToLowerE' can not be used when making a shared object; recompile with -fPIC Can you reproduce it as well? |
Weird, I didn't got this error. What's your environment? (OS, compiler, etc..) |
Trying on Linux with gcc version 9.1.0, ld version (GNU Binutils) 2.32, clang v 8.0.0, cmake version 3.14.5 |
Ok, I'm working from my macbook, I'll try in my linux computer tonight. |
Maybe it's a matter of adding the -fPIC flag somewhere (I couldn't currently tell where exactly though, or if CMake should do that automatically) |
Adding SET(CMAKE_POSITION_INDEPENDENT_CODE ON) to the main CMakeLists.txt does the trick, everything builds successfully on Ubuntu 18.04 and all 20 tests work too. Didn't test the "install" stage though. By the way, "make test" does not work as expected:
Also current cmake configuration does not support out of source builds:
Steps to reproduce:
|
@sdolgikh thanks for the tip, I've made the changes in the Regarding to the I'm looking now for the problem with the build in a sibling folder, I'll push the changes in a few minutes. |
…ation issue in Linux platforms and added new option for improve the library embedding in CMake based projects
@sdolgikh I've tested the out of sources build and I could not reproduce the error, I don't know if the changes that I've pushed already fixed the problem, can you re-run your testes and let me know the error stills happening? |
@devsdmf I guess you neet to set CMAKE_POSITION_INDEPENDENT_CODE earlier, because it still fails with the same error. I placed it in the "build options" section. Use this container to reproduce the problem: FROM ubuntu:18.04
RUN apt update && apt upgrade -y
RUN apt install -y build-essential cmake git-core
RUN useradd -M -u 1001 -r cmakebuild && chown -R cmakebuild: /usr/src
USER cmakebuild
WORKDIR /usr/src
RUN git clone --depth=1 -b cmake-build https://github.com/devsdmf/robotstxt.git
RUN mkdir /usr/src/robotstxt-build
WORKDIR /usr/src/robotstxt-build
RUN /usr/bin/cmake /usr/src/robotstxt -DROBOTS_BUILD_TESTS=ON
ENV VERBOSE=1
RUN make
RUN make test The problem with out-of-source builds seems to be solved in the latest revision. |
Awesome! Now the issue is fixed! Ty! |
It works for me too, thanks! |
Hi there,
I took some time to do a simple cmake build system implementation from my point of view that would be good for the project.
Also, I took the freedom to make some decisions for the project structure as the current build system (Bazel) provides an easier way to deal with the project dependencies. So, what I did was to add the dependent project (abseil-cpp) as a submodule of the project, if you guys think that would be better to set this dependency directly into the libs folder instead of using a git submodule, I can do the changes. Or if you get any better idea of how to deal with it, pls, let me know so I can make the changes.