Last active
June 3, 2022 22:24
-
-
Save mguludag/f10d18582c56c449382bc8b05513fe35 to your computer and use it in GitHub Desktop.
Download https://github.com/chriskohlhoff/asio library with CMake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(NOT CMAKE_VERSION VERSION_LESS 3.10) | |
| include_guard() | |
| endif() | |
| if(NOT COMMAND FetchContent_Populate) | |
| if(CMAKE_VERSION VERSION_LESS 3.11) | |
| message(STATUS "Fetching FetchContent.cmake") | |
| file(DOWNLOAD | |
| "https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent.cmake" | |
| "${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake" | |
| ) | |
| file(DOWNLOAD | |
| "https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent/CMakeLists.cmake.in" | |
| "${CMAKE_BINARY_DIR}/Modules/FetchContent/CMakeLists.cmake.in" | |
| ) | |
| include(${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake) | |
| else() | |
| include(FetchContent) | |
| endif() | |
| endif() | |
| function(fetch_asio) | |
| cmake_parse_arguments(_ OPTIONAL "TAG" "" ${ARGN}) | |
| if(__UNPARSED_ARGUMENTS) | |
| list(GET __UNPARSED_ARGUMENTS 0 __TAG) | |
| list(REMOVE_AT __UNPARSED_ARGUMENTS 0) | |
| endif() | |
| if(__UNPARSED_ARGUMENTS) | |
| message(AUTHOR_WARNING "asio_fetch: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") | |
| endif() | |
| if(NOT __TAG) | |
| set(__TAG master) | |
| endif() | |
| if(CMAKE_VERSION VERSION_LESS 3.6) | |
| FetchContent_Declare(asio QUIET GIT_REPOSITORY "https://github.com/chriskohlhoff/asio" GIT_TAG ${__TAG}) | |
| else() | |
| FetchContent_Declare(asio QUIET GIT_REPOSITORY "https://github.com/chriskohlhoff/asio" GIT_TAG ${__TAG} GIT_SHALLOW 1) | |
| endif() | |
| add_compile_definitions(BOOST_DATETIME_NO_LIB BOOST_REGEX_NO_LIB BOOST_SYSTEM_NO_LIB) | |
| FetchContent_GetProperties(asio) | |
| if(NOT asio_POPULATED) | |
| FetchContent_Populate(asio) | |
| include_directories("${asio_SOURCE_DIR}/asio/include") | |
| endif() | |
| endfunction(fetch_asio) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: