Skip to content

Optionally build Crow as a library #968

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

Open
bugdea1er opened this issue Jan 4, 2025 · 1 comment
Open

Optionally build Crow as a library #968

bugdea1er opened this issue Jan 4, 2025 · 1 comment
Labels
feature Code based project improvement

Comments

@bugdea1er
Copy link
Contributor

bugdea1er commented Jan 4, 2025

I think it would be useful for Crow to be able to be compiled as a library (static or shared). This would reduce build times for clients and allow the Crow distribution to be updated separately (in the case of a shared library)

Note that in this case it is still possible to compile everything into crow_all.h

@gittiver gittiver added the feature Code based project improvement label Jan 4, 2025
@SimonCahill
Copy link

Crow can already be used as an INTERFACE library in CMake projects.

Here's an example of how I do it, using CPM:

SET(CROW_BUILD_FUZZER OFF CACHE BOOL "Build the fuzzer for Crow")
SET(CROW_ENABLE_SSL ON CACHE BOOL "Enable Crow's SSL feature for supporting https")
SET(CROW_ENABLE_COMPRESSION ON CACHE BOOL "Enable Crow's Compression feature for supporting compressed http content")
set(CROW_BUILD_EXAMPLES OFF CACHE BOOL "Build the examples in the project")
set(CROW_BUILD_TESTS OFF CACHE BOOL "Build the tests in the project")

# some magic here which fetches the info
CPMAddPackage(
    NAME ${PACKAGE_NAME}
    GIT_REPOSITORY ${PACKAGE_REPO}
    GIT_TAG ${PACKAGE_TAG}
)

list(APPEND ${PROJECT_NAME}_CPM_TARGETS ${PACKAGE_NAME})

# ...

target_link_libraries(${PROJECT_NAME}
    ${${PROJECT_NAME}_CPM_TARGETS}
)

Then you can just:

#include <crow.h>
#include <crow/middlewares/utf-8.h>

Building Crow as a static library doesn't make sense, because it's header-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Code based project improvement
Projects
None yet
Development

No branches or pull requests

3 participants