Skip to content

Commit

Permalink
[asio] Add cmake target (#6751)
Browse files Browse the repository at this point in the history
* [asio] Add cmake target

* [asio] Export both asio and asio::asio

* [asio] Also export include dir variable
  • Loading branch information
Helco authored and Rastaban committed Jun 4, 2019
1 parent fadd52d commit e3e495d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
33 changes: 33 additions & 0 deletions ports/asio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.8)
project(asio)

add_library(asio INTERFACE)

# Always use "ASIO_STANDALONE" to avoid boost dependency
file(READ "asio/include/asio/detail/config.hpp" _contents)
string(REPLACE "defined(ASIO_STANDALONE)" "!defined(VCPKG_DISABLE_ASIO_STANDALONE)" _contents "${_contents}")
file(WRITE "asio/include/asio/detail/config.hpp" "${_contents}")

# Export target
install(TARGETS asio
EXPORT asio
INCLUDES DESTINATION include/
)

install(EXPORT asio
DESTINATION "share/asio"
FILE asio-targets.cmake
)

install(DIRECTORY
asio/include/asio
DESTINATION include/
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.ipp"
)

install(FILES
asio/include/asio.hpp
DESTINATION include/
)
2 changes: 1 addition & 1 deletion ports/asio/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source: asio
Version: 1.12.2
Version: 1.12.2-1
Description: Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.
6 changes: 6 additions & 0 deletions ports/asio/asio-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include ("${CMAKE_CURRENT_LIST_DIR}/asio-targets.cmake")
add_library(asio::asio INTERFACE IMPORTED)
target_link_libraries(asio::asio INTERFACE asio)

get_target_property(_ASIO_INCLUDE_DIR asio INTERFACE_INCLUDE_DIRECTORIES)
set(ASIO_INCLUDE_DIR "${_ASIO_INCLUDE_DIR}")
22 changes: 15 additions & 7 deletions ports/asio/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ vcpkg_from_github(
HEAD_REF master
)

# CMake install
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()

vcpkg_fixup_cmake_targets(CONFIG_PATH "share/asio")
file(INSTALL
${CMAKE_CURRENT_LIST_DIR}/asio-config.cmake
DESTINATION ${CURRENT_PACKAGES_DIR}/share/asio/
)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug)

# Handle copyright
file(INSTALL ${SOURCE_PATH}/asio/LICENSE_1_0.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

# Copy the asio header files
file(INSTALL ${SOURCE_PATH}/asio/include DESTINATION ${CURRENT_PACKAGES_DIR} FILES_MATCHING PATTERN "*.hpp" PATTERN "*.ipp")

# Always use "ASIO_STANDALONE" to avoid boost dependency
file(READ "${CURRENT_PACKAGES_DIR}/include/asio/detail/config.hpp" _contents)
string(REPLACE "defined(ASIO_STANDALONE)" "!defined(VCPKG_DISABLE_ASIO_STANDALONE)" _contents "${_contents}")
file(WRITE "${CURRENT_PACKAGES_DIR}/include/asio/detail/config.hpp" "${_contents}")

0 comments on commit e3e495d

Please sign in to comment.