Skip to content

Commit

Permalink
Latest CMP and deps. Use alias targets. Define ALIAS target fishnets:…
Browse files Browse the repository at this point in the history
…:fishnets
  • Loading branch information
iboB committed Sep 24, 2022
1 parent fb2df99 commit 241dab9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include(./get_cpm.cmake)

#######################################
# cmake lib
CPMAddPackage(gh:iboB/[email protected].3)
CPMAddPackage(gh:iboB/[email protected].4)

set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
Expand All @@ -35,8 +35,8 @@ endif()

#######################################
# packages
CPMAddPackage(gh:iboB/[email protected].0)
CPMAddPackage(gh:iboB/itlib@1.5.0)
CPMAddPackage(gh:iboB/[email protected].1)
CPMAddPackage(gh:iboB/itlib@1.6.3)

find_package(Threads REQUIRED)
if(FISHNETS_SSL)
Expand All @@ -50,8 +50,7 @@ if(ICM_DEV_MODE)
# only add boost in dev mode
# otherwise rely on the external project providing it
CPMAddPackage(gh:iboB/[email protected])
add_library(boost-beast INTERFACE)
target_link_libraries(boost-beast INTERFACE Boost::boost)
add_library(Boost::beast ALIAS Boost::boost)

# only add scratch project in dev mode
add_subdirectory(scratch)
Expand Down
7 changes: 4 additions & 3 deletions code/fishnets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
icm_add_lib(fishnets FISHNETS
FishnetsImpl.cpp
)
add_library(fishnets::fishnets ALIAS fishnets)

icm_bigobj(FishnetsImpl.cpp)

target_link_libraries(fishnets
PRIVATE
boost-beast
Boost::beast
${CMAKE_THREAD_LIBS_INIT}
PUBLIC
splat
itlib
splat::splat
itlib::itlib
)

if(FISHNETS_SSL)
Expand Down
4 changes: 2 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ macro(fishnets_example example)
target_link_libraries(${example} fishnets)
endmacro()

CPMAddPackage(gh:iboB/xec@1.3.1)
CPMAddPackage(gh:iboB/xec@1.4.1)

fishnets_example(echo-server e-EchoServer.cpp)
fishnets_example(oneshot-client e-OneshotClient.cpp)
fishnets_example(terminal-client e-TerminalClient.cpp)
target_link_libraries(terminal-client xec)
target_link_libraries(terminal-client xec::xec)
6 changes: 3 additions & 3 deletions get_cpm.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
set(CPM_DOWNLOAD_VERSION 0.35.1)
set(CPM_DOWNLOAD_VERSION 0.35.6)

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
Expand Down
3 changes: 1 addition & 2 deletions scratch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ add_executable(scratch scratch.cpp)
target_link_libraries(scratch fishnets)

add_executable(scratch-raw scratch-raw.cpp)
target_link_libraries(scratch-raw boost-beast)

target_link_libraries(scratch-raw Boost::beast)
16 changes: 8 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
#
include(icm_testing)

CPMAddPackage(gh:iboB/doctest-[email protected])
CPMAddPackage(gh:iboB/xec@1.3.1)
CPMAddPackage(gh:iboB/doctest-[email protected])
CPMAddPackage(gh:iboB/xec@1.4.1)

add_library(TestSSLSettings STATIC TestSSLSettings.cpp)
target_link_libraries(TestSSLSettings PUBLIC fishnets)
add_library(TestNullSSLSettings STATIC TestNullSSLSettings.cpp)
target_link_libraries(TestNullSSLSettings PUBLIC fishnets)
add_library(fishnets-TestSSLSettings STATIC TestSSLSettings.cpp)
target_link_libraries(fishnets-TestSSLSettings PUBLIC fishnets)
add_library(fishnets-TestNullSSLSettings STATIC TestNullSSLSettings.cpp)
target_link_libraries(fishnets-TestNullSSLSettings PUBLIC fishnets)

macro(fishnets_dual_test test)
icm_add_doctest_lib_test(${test}-ws fishnets ${ARGN} LIBRARIES xec TestNullSSLSettings)
add_doctest_lib_test(${test}-ws fishnets ${ARGN} LIBRARIES xec::xec fishnets-TestNullSSLSettings)
if(FISHNETS_SSL)
icm_add_doctest_lib_test(${test}-ssl fishnets ${ARGN} LIBRARIES xec TestSSLSettings)
add_doctest_lib_test(${test}-ssl fishnets ${ARGN} LIBRARIES xec::xec fishnets-TestSSLSettings)
endif()
endmacro()

Expand Down
6 changes: 3 additions & 3 deletions test/t-ServerMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class TestClientSession final : public fishnets::WebSocketSession

TEST_CASE("server client threads")
{
xec::ThreadExecutionContext executionContext;
auto executionContext = std::make_shared<xec::ThreadExecutionContext>();
Server server;
server.setExecutionContext(executionContext);

Expand All @@ -328,9 +328,9 @@ TEST_CASE("server client threads")
}

server.setFinishTasksOnExit(true);
while (executionContext.running())
while (executionContext->running())
{
executionContext.wait();
executionContext->wait();
server.update();
}
server.finalize();
Expand Down

0 comments on commit 241dab9

Please sign in to comment.