@@ -45,57 +45,61 @@ else()
4545 endif ()
4646endif ()
4747
48- # Find and link jsoncpp
48+ # Find and link jsoncpp (optional for cross-compilation)
4949set (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 ()
9598endif ()
9699
97100if (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 )
99103endif ()
100104
101105# Install target
0 commit comments