@@ -3,56 +3,33 @@ project(NetworkLibrary)
33
44set (CMAKE_CXX_STANDARD 20)
55
6- set (REPOSITORY repository_dir)
7-
8- if (NOT TARGET asio)
9- include (cmake/FindAsio.cmake)
10- FIND_PACKAGE (asio REQUIRED)
11- endif ()
12-
13-
14- file (GLOB_RECURSE SRCS src/*.cpp)
15- list (REMOVE_ITEM SRCS src/main.cpp)
16-
17- file (GLOB_RECURSE ICLS include /*.hpp)
18- file (GLOB_RECURSE PRIV_ICLS src/include /*.hpp)
6+ if (NOT TARGET PolymorphNetwork)
7+ if (NOT TARGET asio)
8+ include (cmake/FindAsio.cmake)
9+ FIND_PACKAGE (asio REQUIRED)
10+ endif ()
1911
20- add_library (PolymorphNetwork ${SRCS} ${ICLS} ${PRIV_ICLS} )
2112
22- target_include_directories (PolymorphNetwork PUBLIC
23- include
24- )
13+ file (GLOB_RECURSE SRCS src/*.cpp)
14+ list (REMOVE_ITEM SRCS src/main.cpp)
2515
26- target_include_directories (PolymorphNetwork PRIVATE
27- src/include
28- )
16+ file (GLOB_RECURSE ICLS include /*.hpp)
17+ file (GLOB_RECURSE PRIV_ICLS src/include /*.hpp)
2918
30- target_link_libraries (PolymorphNetwork
31- asio
32- )
19+ add_library (PolymorphNetwork ${SRCS} ${ICLS} ${PRIV_ICLS} )
20+ target_include_directories (PolymorphNetwork PUBLIC include )
21+ target_include_directories (PolymorphNetwork PRIVATE src/include )
22+ target_link_libraries (PolymorphNetwork asio)
23+ if (WIN32 )
24+ # MSVC
25+ # /wd4100: unreferenced formal parameter (= unused parameter)
26+ target_compile_options (PolymorphNetwork PRIVATE /W4)
27+ endif ()
28+ endif ()
3329
3430if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} )
35- if (NOT TARGET GTest::gtest_main)
36- include (FetchContent)
37- FetchContent_Declare(
38- googletest
39- GIT_REPOSITORY https://github.com/google/googletest.git
40- GIT_TAG release-1.12.1
41- )
42-
43- set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
44- FetchContent_MakeAvailable(googletest)
45- endif ()
46-
31+ include (tests/cmake/FindGoogleTest.cmake)
4732 enable_testing ()
4833
4934 add_subdirectory (tests)
50-
51-
5235endif ()
53-
54- if (WIN32 )
55- # MSVC
56- # /wd4100: unreferenced formal parameter (= unused parameter)
57- target_compile_options (PolymorphNetwork PRIVATE /W4)
58- endif ()
0 commit comments