Skip to content

Commit d6ad890

Browse files
Modernized some cmake files
1 parent 501053e commit d6ad890

File tree

5 files changed

+24
-43
lines changed

5 files changed

+24
-43
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# =========================== LICENSE =================================
1818

19-
cmake_minimum_required(VERSION 3.13)
19+
cmake_minimum_required(VERSION 3.14...4.0)
2020

2121
# Project call
2222
include("${CMAKE_CURRENT_LIST_DIR}/udpcap/version.cmake")
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
include(FetchContent)
22
FetchContent_Declare(GTest
33
GIT_REPOSITORY https://github.com/google/googletest.git
4-
GIT_TAG origin/v1.14.x # This is not a Tag, but the release branch
5-
CONFIGURE_COMMAND ""
6-
BUILD_COMMAND ""
4+
GIT_TAG origin/v1.16.x # This is not a Tag, but the release branch
5+
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
76
)
8-
FetchContent_GetProperties(GTest)
9-
if(NOT gtest_POPULATED)
10-
message(STATUS "Fetching GTest...")
11-
FetchContent_Populate(GTest)
12-
endif()
7+
8+
message(STATUS "Fetching GTest...")
9+
FetchContent_MakeAvailable(GTest)
10+
1311
set(GTest_ROOT_DIR "${gtest_SOURCE_DIR}")
1412

1513
# Googletest automatically forces MT instead of MD if we do not set this option.
@@ -19,15 +17,5 @@ if(MSVC)
1917
set(INSTALL_GTEST OFF CACHE BOOL "My option" FORCE)
2018
endif()
2119

22-
add_subdirectory("${GTest_ROOT_DIR}" EXCLUDE_FROM_ALL)
23-
24-
if(NOT TARGET GTest::gtest)
25-
add_library(GTest::gtest ALIAS gtest)
26-
endif()
27-
28-
if(NOT TARGET GTest::gtest_main)
29-
add_library(GTest::gtest_main ALIAS gtest_main)
30-
endif()
31-
3220
# Prepend googletest-module/FindGTest.cmake to Module Path
3321
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules/")
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
include(FetchContent)
22
FetchContent_Declare(asio
3-
GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
4-
GIT_TAG asio-1-24-0
5-
CONFIGURE_COMMAND ""
6-
BUILD_COMMAND ""
7-
)
8-
FetchContent_GetProperties(asio)
9-
if(NOT asio_POPULATED)
10-
message(STATUS "Fetching asio...")
11-
FetchContent_Populate(asio)
12-
endif()
3+
GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
4+
GIT_TAG asio-1-24-0
5+
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
6+
)
7+
8+
message(STATUS "Fetching asio...")
9+
FetchContent_MakeAvailable(asio)
10+
1311
set(asio_ROOT_DIR "${asio_SOURCE_DIR}")
1412
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules/)

thirdparty/npcap/npcap_make_available.cmake

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ include(FetchContent)
77
FetchContent_Declare(npcap_sdk
88
URL "${NPCAP_SDK_ARCHIVE_URL}"
99
URL_HASH "${NPCAP_SDK_ARCHIVE_HASH}"
10-
CONFIGURE_COMMAND ""
11-
BUILD_COMMAND ""
10+
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
1211
)
13-
FetchContent_GetProperties(npcap_sdk)
14-
if(NOT npcap-sdk_POPULATED)
15-
message(STATUS "Fetching npcap_sdk...")
16-
FetchContent_Populate(npcap_sdk)
17-
endif()
12+
13+
message(STATUS "Fetching npcap_sdk...")
14+
FetchContent_MakeAvailable(npcap_sdk)
15+
1816
set(npcap_ROOT_DIR "${npcap_sdk_SOURCE_DIR}")
1917
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules/)

thirdparty/pcapplusplus/pcapplusplus_make_available.cmake

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ include(FetchContent)
77
FetchContent_Declare(pcapplusplus
88
URL "${PCAPPLUSPLUS_ARCHIVE_URL}"
99
URL_HASH "${PCAPPLUSPLUS_ARCHIVE_HASH}"
10-
CONFIGURE_COMMAND ""
11-
BUILD_COMMAND ""
1210
)
13-
FetchContent_GetProperties(pcapplusplus)
14-
if(NOT pcapplusplus_POPULATED)
15-
message(STATUS "Fetching Pcap++...")
16-
FetchContent_Populate(pcapplusplus)
17-
endif()
11+
12+
message(STATUS "Fetching Pcap++...")
13+
FetchContent_MakeAvailable(pcapplusplus)
14+
1815
set(pcapplusplus_ROOT_DIR "${pcapplusplus_SOURCE_DIR}")
1916
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules/)

0 commit comments

Comments
 (0)