Skip to content

Commit fd1b05b

Browse files
committed
Fixed Some Linking Issue
1 parent 93e19a4 commit fd1b05b

3 files changed

Lines changed: 52 additions & 42 deletions

File tree

CMakeLists.txt

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -45,57 +45,61 @@ else()
4545
endif()
4646
endif()
4747

48-
# Find and link jsoncpp
48+
# Find and link jsoncpp (optional for cross-compilation)
4949
set(JSONCPP_FOUND FALSE)
5050

51-
# Try modern find_package first (works with vcpkg and modern installs)
52-
find_package(jsoncpp CONFIG QUIET)
53-
if(jsoncpp_FOUND)
54-
target_link_libraries(netmgr JsonCpp::JsonCpp)
55-
set(JSONCPP_FOUND TRUE)
56-
message(STATUS "Found jsoncpp via CONFIG find_package")
57-
else()
58-
find_package(PkgConfig QUIET)
59-
if(PkgConfig_FOUND)
60-
pkg_check_modules(JSONCPP jsoncpp)
61-
if(JSONCPP_FOUND)
62-
target_include_directories(netmgr PRIVATE ${JSONCPP_INCLUDE_DIRS})
63-
target_link_directories(netmgr PRIVATE ${JSONCPP_LIBRARY_DIRS})
64-
target_link_libraries(netmgr ${JSONCPP_LIBRARIES})
65-
target_compile_options(netmgr PRIVATE ${JSONCPP_CFLAGS_OTHER})
66-
message(STATUS "Found jsoncpp via pkg-config")
51+
# Skip jsoncpp if explicitly disabled (for cross-compilation)
52+
if(NOT CMAKE_DISABLE_FIND_PACKAGE_jsoncpp)
53+
# Try modern find_package first (works with vcpkg and modern installs)
54+
find_package(jsoncpp CONFIG QUIET)
55+
if(jsoncpp_FOUND)
56+
target_link_libraries(netmgr JsonCpp::JsonCpp)
57+
set(JSONCPP_FOUND TRUE)
58+
message(STATUS "Found jsoncpp via CONFIG find_package")
59+
else()
60+
find_package(PkgConfig QUIET)
61+
if(PkgConfig_FOUND AND NOT CMAKE_DISABLE_FIND_PACKAGE_PkgConfig)
62+
pkg_check_modules(JSONCPP jsoncpp)
63+
if(JSONCPP_FOUND)
64+
target_include_directories(netmgr PRIVATE ${JSONCPP_INCLUDE_DIRS})
65+
target_link_directories(netmgr PRIVATE ${JSONCPP_LIBRARY_DIRS})
66+
target_link_libraries(netmgr ${JSONCPP_LIBRARIES})
67+
target_compile_options(netmgr PRIVATE ${JSONCPP_CFLAGS_OTHER})
68+
message(STATUS "Found jsoncpp via pkg-config")
69+
endif()
6770
endif()
68-
endif()
69-
70-
# Manual search fallback
71-
if(NOT JSONCPP_FOUND)
72-
find_path(JSONCPP_INCLUDE_DIR json/json.h
73-
PATHS
74-
${CMAKE_PREFIX_PATH}/include
75-
/usr/local/include
76-
/opt/homebrew/include
77-
PATH_SUFFIXES jsoncpp
78-
)
79-
80-
find_library(JSONCPP_LIBRARY
81-
NAMES jsoncpp
82-
PATHS
83-
${CMAKE_PREFIX_PATH}/lib
84-
/usr/local/lib
85-
/opt/homebrew/lib
86-
)
8771

88-
if(JSONCPP_INCLUDE_DIR AND JSONCPP_LIBRARY)
89-
target_include_directories(netmgr PRIVATE ${JSONCPP_INCLUDE_DIR})
90-
target_link_libraries(netmgr ${JSONCPP_LIBRARY})
91-
set(JSONCPP_FOUND TRUE)
92-
message(STATUS "Found jsoncpp manually at ${JSONCPP_LIBRARY}")
72+
# Manual search fallback (skip for cross-compilation)
73+
if(NOT JSONCPP_FOUND AND NOT CMAKE_CROSSCOMPILING)
74+
find_path(JSONCPP_INCLUDE_DIR json/json.h
75+
PATHS
76+
${CMAKE_PREFIX_PATH}/include
77+
/usr/local/include
78+
/opt/homebrew/include
79+
PATH_SUFFIXES jsoncpp
80+
)
81+
82+
find_library(JSONCPP_LIBRARY
83+
NAMES jsoncpp
84+
PATHS
85+
${CMAKE_PREFIX_PATH}/lib
86+
/usr/local/lib
87+
/opt/homebrew/lib
88+
)
89+
90+
if(JSONCPP_INCLUDE_DIR AND JSONCPP_LIBRARY)
91+
target_include_directories(netmgr PRIVATE ${JSONCPP_INCLUDE_DIR})
92+
target_link_libraries(netmgr ${JSONCPP_LIBRARY})
93+
set(JSONCPP_FOUND TRUE)
94+
message(STATUS "Found jsoncpp manually at ${JSONCPP_LIBRARY}")
95+
endif()
9396
endif()
9497
endif()
9598
endif()
9699

97100
if(NOT JSONCPP_FOUND)
98-
message(WARNING "jsoncpp not found - some features may be disabled")
101+
message(STATUS "jsoncpp not found - JSON features will be disabled")
102+
add_definitions(-DDISABLE_JSON_FEATURES)
99103
endif()
100104

101105
# Install target

src/modules/dns.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int DNS::show_dns(const GlobalOptions& options) {
2020
std::cout << std::endl;
2121

2222
#ifdef __linux__
23+
(void)options; // Suppress unused parameter warning
2324
std::ifstream resolv_conf("/etc/resolv.conf");
2425
if (resolv_conf.is_open()) {
2526
std::string line;

src/modules/interface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ int Interface::handle_command(const GlobalOptions& options) {
2020
}
2121

2222
int Interface::show_interfaces(const GlobalOptions& options) {
23+
(void)options; // Suppress unused parameter warning for now
24+
2325
Common::log_info("All network interfaces:");
2426
std::cout << std::endl;
2527

@@ -39,12 +41,15 @@ int Interface::show_interfaces(const GlobalOptions& options) {
3941
std::string output = Common::execute_command_output("ip", {"link", "show"});
4042
// Parse and display interface information
4143
// Implementation would parse the ip command output
44+
std::cout << output << std::endl;
4245
#elif defined(__APPLE__)
4346
std::string output = Common::execute_command_output("ifconfig", {});
4447
// Parse and display interface information
48+
std::cout << output << std::endl;
4549
#elif defined(_WIN32)
4650
std::string output = Common::execute_command_output("netsh", {"interface", "show", "interface"});
4751
// Parse and display interface information
52+
std::cout << output << std::endl;
4853
#endif
4954

5055
return 0;

0 commit comments

Comments
 (0)