asio icon indicating copy to clipboard operation
asio copied to clipboard

Add CMake Project

Open podsvirov opened this issue 8 years ago • 40 comments

Now implemented:

  • standalote installation as asio package;
  • optional building and installation cpp11 and cpp14 examples.

Usage standalone asio from CMake projects:

find_package(asio REQUIRED)
target_link_libraries(<target_name> asio::standalone)

Prebuid asio_cpp11_xxx and asio_cpp14_xxx examples available for testing from DaD's House by MinGW-w64 based installers:

dad-0.3.1-windows-mingw32-testing.exe

and

dad-0.3.1-windows-mingw64-testing.exe

podsvirov avatar Aug 03 '16 15:08 podsvirov

Hello @chriskohlhoff,

you have the time and can see my changes?

Your library is stable, but my goal is the propaganda and popularization of the use of standalone library among the community CMake users.

podsvirov avatar Aug 05 '16 03:08 podsvirov

Ping.

podsvirov avatar Sep 11 '16 15:09 podsvirov

thank you! I like this

frozen4 avatar Dec 02 '16 09:12 frozen4

Great! I'm not alone :-)

podsvirov avatar Dec 02 '16 10:12 podsvirov

Updated for latest master.

@frozen4 can you check it? What OS and compiler you use?

podsvirov avatar Dec 24 '16 21:12 podsvirov

Hello @kdeforche! What about use this (when merged) in wt4?

podsvirov avatar Jan 13 '17 16:01 podsvirov

Ping.

podsvirov avatar Jan 25 '17 17:01 podsvirov

Hey! In wt4 we added recently an option to use non-boost asio instead of boost asio. However, as I understand it, we only need header files, and thus not really a particular build system.

Or what are you hinting at?

emweb avatar Jan 25 '17 22:01 emweb

Hello @emweb!

As wrote there:

To use Asio in this way, define ASIO_STANDALONE on your compiler command line or as part of the project options.

I looked up your CMake project scripts and found no suitable instructions.

In my proposal, I create exported IMPORTED interface library asio::standalone - when you link to the target in your project, it automatically adjusts the path to the headers and define the ASIO_STANDALONE preprocessor variable.

You can check ASIO_STANDALONE definition in your C++ code to select boost or standalone Asio version and your do not need define additional custom settings variable like WT_ASIO_IS_BOOST_ASIO or WT_ASIO_IS_STANDALONE_ASIO.

(And I try link wt4 to Asio from master and it not compatible now)

@chriskohlhoff, please support our discussion.

podsvirov avatar Jan 26 '17 03:01 podsvirov

If you want to build Wt 4 (the wt4 branch, master is still Wt 3) with the standalone version of asio, you have to set -DWT_ASIO_IMPLEMENTATION to "standalone" and set -DASIO_PREFIX correctly. I think that should be sufficient?

emweb avatar Jan 26 '17 16:01 emweb

For example see config.hpp.

I think that ASIO_STANDALONE it is very important variable.

podsvirov avatar Jan 26 '17 17:01 podsvirov

@chriskohlhoff, ping.

podsvirov avatar Feb 06 '17 19:02 podsvirov

@chriskohlhoff, ping.

podsvirov avatar Mar 05 '17 08:03 podsvirov

@chriskohlhoff, ping.

podsvirov avatar Jul 18 '17 01:07 podsvirov

Why did you not include the unit tests and the cpp03 examples?

ClausKlein avatar Jul 18 '17 20:07 ClausKlein

Hello @ClausKlein, at the moment, only the standalone version of the library is supported (without Boost dependencies). As far as I know, cpp03 examples can not be built with an standalone version of the library. The Boost library support is possible in the future, but I had to start somewhere. With something that has not happened yet (easy using standalone asio from CMake projects). By the way, today I learned the news that the Boost library is moving to the CMake build system: https://lists.boost.org/Archives/boost/2017/07/237248.php

podsvirov avatar Jul 18 '17 21:07 podsvirov

Hi Konstantin,

based on your patch I have extended the CMakeLists.txt files to have more options and use ctest too:

Claus-MBP:ninjabuild clausklein$ ninja [314/314] Linking CXX executable bin/asio_cpp14_executors_actor Claus-MBP:ninjabuild clausklein$ ctest Test project /Users/clausklein/Workspace/cpp/asio/ninjabuild Start 1: asio_unit_buffer 1/48 Test #1: asio_unit_buffer ......................... Passed 0.02 sec Start 2: asio_unit_buffered_read_stream 2/48 Test #2: asio_unit_buffered_read_stream ........... Passed 0.03 sec Start 3: asio_unit_buffered_stream 3/48 Test #3: asio_unit_buffered_stream ................ Passed 0.01 sec Start 4: asio_unit_buffered_write_stream 4/48 Test #4: asio_unit_buffered_write_stream .......... Passed 0.01 sec Start 5: asio_unit_buffers_iterator 5/48 Test #5: asio_unit_buffers_iterator ............... Passed 0.12 sec Start 6: asio_unit_coroutine 6/48 Test #6: asio_unit_coroutine ...................... Passed 0.02 sec Start 7: asio_unit_error 7/48 Test #7: asio_unit_error .......................... Passed 0.03 sec Start 8: asio_unit_generic_datagram_protocol 8/48 Test #8: asio_unit_generic_datagram_protocol ...... Passed 0.01 sec Start 9: asio_unit_generic_raw_protocol 9/48 Test #9: asio_unit_generic_raw_protocol ........... Passed 0.01 sec Start 10: asio_unit_generic_seq_packet_protocol 10/48 Test #10: asio_unit_generic_seq_packet_protocol .... Passed 0.01 sec Start 11: asio_unit_generic_stream_protocol 11/48 Test #11: asio_unit_generic_stream_protocol ........ Passed 0.01 sec Start 12: asio_unit_io_context 12/48 Test #12: asio_unit_io_context ..................... Passed 8.02 sec Start 13: asio_unit_ip_address 13/48 Test #13: asio_unit_ip_address ..................... Passed 0.01 sec Start 14: asio_unit_ip_address_v4 14/48 Test #14: asio_unit_ip_address_v4 .................. Passed 0.01 sec Start 15: asio_unit_ip_address_v6 15/48 Test #15: asio_unit_ip_address_v6 .................. Passed 0.04 sec Start 16: asio_unit_ip_host_name 16/48 Test #16: asio_unit_ip_host_name ................... Passed 0.01 sec Start 17: asio_unit_ip_icmp 17/48 Test #17: asio_unit_ip_icmp ........................ Passed 0.01 sec Start 18: asio_unit_ip_multicast 18/48 Test #18: asio_unit_ip_multicast ................... Passed 0.04 sec Start 19: asio_unit_ip_network_v4 19/48 Test #19: asio_unit_ip_network_v4 .................. Passed 0.02 sec Start 20: asio_unit_ip_network_v6 20/48 Test #20: asio_unit_ip_network_v6 .................. Passed 0.01 sec Start 21: asio_unit_ip_tcp 21/48 Test #21: asio_unit_ip_tcp ......................... Passed 0.04 sec Start 22: asio_unit_ip_udp 22/48 Test #22: asio_unit_ip_udp ......................... Passed 0.10 sec Start 23: asio_unit_ip_unicast 23/48 Test #23: asio_unit_ip_unicast ..................... Passed 0.01 sec Start 24: asio_unit_ip_v6_only 24/48 Test #24: asio_unit_ip_v6_only ..................... Passed 0.01 sec Start 25: asio_unit_is_read_buffered 25/48 Test #25: asio_unit_is_read_buffered ............... Passed 0.01 sec Start 26: asio_unit_is_write_buffered 26/48 Test #26: asio_unit_is_write_buffered .............. Passed 0.01 sec Start 27: asio_unit_local_connect_pair 27/48 Test #27: asio_unit_local_connect_pair ............. Passed 0.01 sec Start 28: asio_unit_local_datagram_protocol 28/48 Test #28: asio_unit_local_datagram_protocol ........ Passed 0.01 sec Start 29: asio_unit_local_stream_protocol 29/48 Test #29: asio_unit_local_stream_protocol .......... Passed 0.01 sec Start 30: asio_unit_posix_stream_descriptor 30/48 Test #30: asio_unit_posix_stream_descriptor ........ Passed 0.02 sec Start 31: asio_unit_read 31/48 Test #31: asio_unit_read ........................... Passed 0.03 sec Start 32: asio_unit_read_at 32/48 Test #32: asio_unit_read_at ........................ Passed 0.05 sec Start 33: asio_unit_read_until 33/48 Test #33: asio_unit_read_until ..................... Passed 0.02 sec Start 34: asio_unit_serial_port 34/48 Test #34: asio_unit_serial_port .................... Passed 0.01 sec Start 35: asio_unit_serial_port_base 35/48 Test #35: asio_unit_serial_port_base ............... Passed 0.01 sec Start 36: asio_unit_signal_set 36/48 Test #36: asio_unit_signal_set ..................... Passed 0.01 sec Start 37: asio_unit_socket_base 37/48 Test #37: asio_unit_socket_base .................... Passed 0.01 sec Start 38: asio_unit_strand 38/48 Test #38: asio_unit_strand ......................... Passed 8.03 sec Start 39: asio_unit_streambuf 39/48 Test #39: asio_unit_streambuf ...................... Passed 0.01 sec Start 40: asio_unit_system_timer 40/48 Test #40: asio_unit_system_timer ................... Passed 33.75 sec Start 41: asio_unit_use_future 41/48 Test #41: asio_unit_use_future ..................... Passed 0.02 sec Start 42: asio_unit_windows_object_handle 42/48 Test #42: asio_unit_windows_object_handle .......... Passed 0.03 sec Start 43: asio_unit_windows_overlapped_ptr 43/48 Test #43: asio_unit_windows_overlapped_ptr ......... Passed 0.02 sec Start 44: asio_unit_windows_random_access_handle 44/48 Test #44: asio_unit_windows_random_access_handle ... Passed 0.01 sec Start 45: asio_unit_windows_stream_handle 45/48 Test #45: asio_unit_windows_stream_handle .......... Passed 0.01 sec Start 46: asio_unit_write 46/48 Test #46: asio_unit_write .......................... Passed 0.04 sec Start 47: asio_unit_write_at 47/48 Test #47: asio_unit_write_at ....................... Passed 0.04 sec Start 48: asio_unit_ssl_stream 48/48 Test #48: asio_unit_ssl_stream ..................... Passed 0.04 sec

100% tests passed, 0 tests failed out of 48

Total Test time (real) = 50.92 sec Claus-MBP:ninjabuild clausklein$

It works with each option on OSX, cygwin, VC2015, but not on MSYS! I am still working on this.

Regards, Claus

On 18 Jul 2017, at 23:06, Konstantin Podsvirov [email protected] wrote:

Hello @ClausKlein https://github.com/clausklein, at the moment, only the standalone version of the library is supported (without Boost dependencies). As far as I know, cpp03 examples can not be built with an offline version of the library. The Boost library support is possible in the future, but I had to start somewhere. With something that has not happened yet (easy using standalone asio from CMake projects). By the way, today I learned the news that the Boost library is moving to the CMake build system: https://lists.boost.org/Archives/boost/2017/07/237248.php https://lists.boost.org/Archives/boost/2017/07/237248.php — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/pull/128#issuecomment-316197885, or mute the thread https://github.com/notifications/unsubscribe-auth/ABv4WvoJUIOQw_jCMQMlwt2WegTyo8l6ks5sPR5JgaJpZM4JbzGx.

ClausKlein avatar Jul 19 '17 15:07 ClausKlein

@ClausKlein, thank you for your interest and efforts. I created these changes about a year ago, but there is still no reaction from @chriskohlhoff...

podsvirov avatar Jul 19 '17 18:07 podsvirov

Rebased to master and updated list of public files to install.

podsvirov avatar Aug 16 '17 18:08 podsvirov

@chriskohlhoff, any feedback please... :-(

podsvirov avatar Aug 17 '17 19:08 podsvirov

What is the status of this PR? I am currently looking at workarounds but this solution would be highly preferred.

hgaiser avatar Nov 01 '17 10:11 hgaiser

Rebased to master.

podsvirov avatar Nov 01 '17 21:11 podsvirov

Rebased to master.

podsvirov avatar Mar 22 '18 20:03 podsvirov

Hello @chriskohlhoff, what about paying attention to these changes?

podsvirov avatar Mar 31 '18 22:03 podsvirov

Rebased to master.

podsvirov avatar Apr 01 '18 01:04 podsvirov

I have based on your patch conan with cmake build files prepared, see https://github.com/chriskohlhoff/asio/pull/296

ClausKlein avatar Apr 06 '18 15:04 ClausKlein

Rebased to master. Add support for import package from buildtree.

podsvirov avatar Jun 16 '18 07:06 podsvirov

Dear @chriskohlhoff, what you think about CMake and about this PR?

podsvirov avatar Jun 16 '18 08:06 podsvirov

@chriskohlhoff any chance this gets merged soon?

gocarlos avatar Dec 11 '18 14:12 gocarlos

Would love to see this merged. CMake is awesome and would make integrating asio as easy as it gets. :)

marcj avatar Aug 15 '20 22:08 marcj