Skip to content

Commit

Permalink
Upgrade to make the project work with nix (#121)
Browse files Browse the repository at this point in the history
* Convert expected vendor dependency to submodle and upgrade

Submodule makes it easier to upgrade to the latest version.

* Add install target to the makefile + pkgconfig

add make install target. Also pc pkgconfig file.
  • Loading branch information
jstranik authored Oct 7, 2022
1 parent acbe301 commit dd67c85
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 2,726 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "vendor/c-ares/c-ares"]
path = vendor/c-ares/c-ares
url = https://github.com/c-ares/c-ares.git
[submodule "vendor/tartanllama/expected"]
path = vendor/tartanllama/expected
url = https://github.com/jstranik/expected.git
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.0)
project(libcoro CXX)
project(libcoro LANGUAGES CXX DESCRIPTION "C++20 coroutine library")

if (NOT "$ENV{version}" STREQUAL "")
set(PROJECT_VERSION "$ENV{version}" CACHE INTERNAL "Copied from environment variable")
endif()

# Set the githooks directory to auto format and update the readme.
message("${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} -> git config --local core.hooksPath .githooks")
Expand Down Expand Up @@ -92,4 +96,13 @@ endif()

if(LIBCORO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
endif()


# generate pc file for pkg-config
set(target1 ${PROJECT_NAME})
configure_file(libcoro.pc.in libcoro.pc @ONLY)

install(TARGETS libcoro)
install(DIRECTORY inc/coro TYPE INCLUDE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcoro.pc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/../lib/pkgconfig)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ This project uses git submodules, to properly checkout this project use:
This project depends on the following git sub-modules:
* [libc-ares](https://github.com/c-ares/c-ares) For async DNS resolver, this is a git submodule.
* [catch2](https://github.com/catchorg/Catch2) For testing, this is embedded in the `test/` directory.
* [expected](https://github.com/TartanLlama/expected) For results on operations that can fail, this is embedded in the `vendor/` directory.
* [expected](https://github.com/TartanLlama/expected) For results on operations that can fail, this is a git submodule in the `vendor/` directory.

#### Building
mkdir Release && cd Release
Expand Down
2 changes: 1 addition & 1 deletion inc/coro/ring_buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <expected/expected.hpp>
#include <tl/expected.hpp>

#include <array>
#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion inc/coro/semaphore.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <expected/expected.hpp>
#include <tl/expected.hpp>

#include <atomic>
#include <coroutine>
Expand Down
9 changes: 9 additions & 0 deletions libcoro.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix="@CMAKE_INSTALL_PREFIX@"
libdir="${prefix}/lib"
includedir="@CMAKE_INSTALL_INCLUDEDIR@"

Name: @PROJECT_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -l@target1@
1 change: 1 addition & 0 deletions vendor/tartanllama/expected
Submodule expected added at d11e06
9 changes: 0 additions & 9 deletions vendor/tartanllama/expected/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit dd67c85

Please sign in to comment.