-
Notifications
You must be signed in to change notification settings - Fork 186
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
Include CMakeLists.txt to make it easier to import into other projects? #261
Comments
Not too familiar with CMake unfortunately to give an expert comment on this, but aren't the ones you pointed basically the configurations to build those libraries. All that we wanted to provide with |
Correct.
You don't need that file btw. This is (more or less) how I do it currently: find_package(PkgConfig REQUIRED)
pkg_check_modules(PC_HTTPSERVER REQUIRED IMPORTED_TARGET
libhttpserver>=0.19)
pkg_check_modules(PC_MICROHTTPD REQUIRED IMPORTED_TARGET
libmicrohttpd>=0.9.52)
# and later
target_link_libraries(foo
PRIVATE
PkgConfig::PC_HTTPSERVER
PkgConfig::PC_MICROHTTPD
) If all is in standard paths, you can even avoid pkg-config and just use However if libhttpserver wants to provide a CMake find module, then this should guide you to update to a modern one: |
I don't know if it's wrong or right but I typically have issues with How do you pass the path of |
Which only works if all those deps are projects built with CMake. This is not the case with libhttpserver. You would have to add all those CMakeLists.txt files and this would mean either supporting an additional build system or switching over from autotools. The FindLibHttpServer.cmake is about a very different thing, not building libhttpserver with CMake, but using an already built and installed libhttpserver from other CMake projects.
You have to distinguish between different types of builds:
ExternalProject_Add(libhttpserver
DEPENDS libmicrohttpd
PREFIX sysroot-prefix
GIT_REPOSITORY https://github.com/etr/libhttpserver.git
GIT_TAG master
UPDATE_DISCONNECTED 1
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
--$<IF:$<CONFIG:DEBUG>,enable,disable>-debug --disable-examples
TEST_COMMAND make check
TEST_EXCLUDE_FROM_MAIN 1
STEP_TARGETS update install test
)
ExternalProject_Get_Property(libhttpserver SOURCE_DIR)
ExternalProject_Add_Step(libhttpserver bootstrap
COMMAND ./bootstrap
DEPENDEES update
DEPENDERS configure
BYPRODUCTS <SOURCE_DIR>/configure
WORKING_DIRECTORY <SOURCE_DIR>
) |
Hi LeSpocky I try to setup my application using cMake and ExternalProject to build libhttpserver. I started with your example above, but I'm not able to link correctly to the libmicrohttpd. Is your superbuild project available some where? Or could you share the CMakeLists of it? This would be nice and help me to setup my own project. |
No, and it won't be, at least not that project I use in production.
I will share a generic superbuild project with example code. As a first step I created a small project based on the hello world from libhttpserver examples: https://github.com/LeSpocky/glowing-tribble You can already build that without a superbuild, if recent libhttpserver is installed on your build host (which probably is not the case). I will provide a separate superbuild project as soon as I find time for that. |
@schnudi See https://github.com/LeSpocky/glowing-tribble-build for a working superbuild including some explanation on how it works in its README.md file. Hope that helps. |
This library seems great however not having a cmakelists is a bummer for me. |
maybe we can combine and write Bazel for it? i agree though, i thought bundling cmakelist was pretty standard for most c/c++ projects |
@hesa2020 @brandonros What you essentially suggest is libhttpserver should either switch its build system to something different or add the burden to maintain two or more different build systems at the same time for a project which can be used fine with either autotools or by importing the pkgconfig file it distributes. 😉 |
I agree with @LeSpocky here and wonder if I am missing the point you are both trying to make in the quotes above. How do you manage with libraries that are not compiled with CMake but use other build systems (i.e. autotools, Meson, etc.)? I guess CMake is popular but not the only one. I guess you just don't use them? |
There are a few options. You could use something like conan/vcpkg, or build on a linux distro that provides static versions of packages. In both cases, you just import a prebuilt library via e.g. pkg-config or FindFooBar.cmake. You could also learn to use ExternalProject_Add for cmake. :) meson has an externalproject module that's intended to support generic
Standard? That's an intimidating term. It's certainly common, it's one of the 3 major choices after all. More common for C++ than for C, however. Also, more common on Windows than on Unix. |
I don't think this is enough: https://github.com/etr/libhttpserver/blob/master/cmakemodule/FindLibHttpServer.cmake
Something like this: https://github.com/curl/curl/blob/master/CMakeLists.txt
https://github.com/janbar/openssl-cmake/blob/master/CMakeLists.txt
The text was updated successfully, but these errors were encountered: