Skip to content

Commit

Permalink
Support installation (#5)
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Apr 3, 2024
1 parent bb39d35 commit 7f59fc6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ jobs:
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
run: >
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config ${{ matrix.build_type }}
- name: Install
run: >
cmake --install ${{ steps.strings.outputs.build-output-dir }}
--prefix ${{ steps.strings.outputs.build-output-dir }}/dist
--config ${{ matrix.build_type }}
--component benoni
--verbose
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ elseif(UNIX)
add_subdirectory(src/linux)
endif()

set_target_properties(benoni PROPERTIES PUBLIC_HEADER include/benoni/http.h)

include(GNUInstallDirs)

install(TARGETS benoni
EXPORT benoni
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT benoni
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT benoni)
install(EXPORT benoni
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake"
COMPONENT benoni)

if(BENONI_EXAMPLES)
add_subdirectory(examples)
endif()
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ configure: .always
build: .always
$(CLANG_FORMAT) --style=file -i include/benoni/http.h src/apple/http.mm src/win32/http.cc src/linux/http.cc examples/http_example.cc test/unit/postman-echo-get.cc test/packaging/project/project.cc
$(CMAKE) --build build
$(CMAKE) --install build --prefix build/dist --config Debug --component benoni --verbose

example: .always
$(EXAMPLE)
Expand Down
4 changes: 3 additions & 1 deletion src/apple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ add_library(benoni STATIC http.mm)

target_compile_options(benoni PUBLIC "-fobjc-arc")

target_include_directories(benoni PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(benoni PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

target_link_libraries(benoni PUBLIC "-framework Foundation")
4 changes: 3 additions & 1 deletion src/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_library(benoni STATIC http.cc)

target_include_directories(benoni PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(benoni PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

target_link_libraries(benoni PUBLIC libsoup)
4 changes: 3 additions & 1 deletion src/win32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_library(benoni STATIC http.cc)

target_include_directories(benoni PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(benoni PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

target_link_libraries(benoni PUBLIC "Winhttp.lib")

0 comments on commit 7f59fc6

Please sign in to comment.