diff --git a/CMakeLists.txt b/CMakeLists.txt index a383d22..26c7a78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,14 +17,12 @@ if(CTH_ENABLE_TESTS) enable_testing() endif() -# exported +# exported, a parent project turns components off with set(CTH_BUILD_ OFF) add_subdirectory(cth) -add_subdirectory(cth_os) -add_subdirectory(cth_coro) -add_subdirectory(cth_net) -if(WIN32) - add_subdirectory(cth_win) -endif() +cth_add_subdirectory(cth_os CTH_BUILD_OS) +cth_add_subdirectory(cth_coro CTH_BUILD_CORO) +cth_add_subdirectory(cth_net CTH_BUILD_NET) +cth_add_subdirectory(cth_win CTH_BUILD_WIN WIN32) cth_create_package() diff --git a/README.md b/README.md index e2cca89..48510ac 100644 --- a/README.md +++ b/README.md @@ -139,11 +139,23 @@ find_package(cth CONFIG REQUIRED COMPONENTS coro) target_link_libraries(app PRIVATE cth::coro) ``` +or add the source as a subdirectory, options turn components off: + +```cmake +set(CTH_BUILD_NET OFF) +add_subdirectory(lib/cth) +target_link_libraries(app PRIVATE cth::os) +``` + api not stable yet, no versioned releases ## components -- `cth`, `os`, `coro` +- `cth`, `os`, `coro`, `net` - windows only: `win`, `win_capture` +## options +- `CTH_BUILD_OS`, `CTH_BUILD_CORO`, `CTH_BUILD_NET`: default ON +- `CTH_BUILD_WIN`: default ON on windows + # license [MIT](LICENSE) diff --git a/cth/CMakeLists.txt b/cth/CMakeLists.txt index cfa0e43..adb41cc 100644 --- a/cth/CMakeLists.txt +++ b/cth/CMakeLists.txt @@ -11,6 +11,10 @@ cth_pkg_target_include_directories( target_compile_options(cth INTERFACE $<$:/Zc:preprocessor>) +# cth/hash/hash_aggregates.hpp includes boost/pfr.hpp +cth_pkg_target_find_package(cth boost_pfr CONFIG REQUIRED) +target_link_libraries(cth INTERFACE Boost::pfr) + target_link_libraries(cth INTERFACE $<$,$>>:stdc++exp>) # tests diff --git a/cth_coro/CMakeLists.txt b/cth_coro/CMakeLists.txt index f001617..df04af0 100644 --- a/cth_coro/CMakeLists.txt +++ b/cth_coro/CMakeLists.txt @@ -1,3 +1,5 @@ +cth_assert_target(cth::os REASON "cth_coro requires cth_os (CTH_BUILD_OS)") + cth_glob_cpp(CTH_CORO_SRC "src") cth_glob_cpp(CTH_CORO_INCL "incl") diff --git a/cth_net/CMakeLists.txt b/cth_net/CMakeLists.txt index e94daa8..b8f4bc3 100644 --- a/cth_net/CMakeLists.txt +++ b/cth_net/CMakeLists.txt @@ -1,3 +1,5 @@ +cth_assert_target(cth::os REASON "cth_net requires cth_os (CTH_BUILD_OS)") + cth_glob_cpp(CTH_NET_SRC "src") cth_glob_cpp(CTH_NET_INCL "incl") diff --git a/cth_win/CMakeLists.txt b/cth_win/CMakeLists.txt index b5692d0..28f14d5 100644 --- a/cth_win/CMakeLists.txt +++ b/cth_win/CMakeLists.txt @@ -1,3 +1,7 @@ +cth_assert_true(WIN32 REASON "cth_win targets windows") +cth_assert_target(cth::os REASON "cth_win requires cth_os (CTH_BUILD_OS)") +cth_assert_target(cth::coro REASON "cth_win requires cth_coro (CTH_BUILD_CORO)") + cth_glob_cpp(CTH_WIN_SRC "src") cth_glob_cpp(CTH_WIN_INCL "incl") diff --git a/lib/cth_cmake b/lib/cth_cmake index 12f2a5c..09a6c5d 160000 --- a/lib/cth_cmake +++ b/lib/cth_cmake @@ -1 +1 @@ -Subproject commit 12f2a5c6d1a7c999ff3f71c7035c8fe104b93e30 +Subproject commit 09a6c5d02421cba58fcf33bc3e4fd3d4fb646002