Loading cmake/Findjson-c.cmake +11 −10 Changes for cmake/Findjson-c.cmake: 11 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -30,13 +30,12 @@ find_package_handle_standard_args(JsonC ) # ----------------------------------------------------------------------------- # 3. Define Imported Shared Target # 3. Define Imported Shared Target (Internal Name) # ----------------------------------------------------------------------------- if(JSONC_FOUND) # 1. Define the target as SHARED IMPORTED # We use a single target since json-c is generally one library. # 1. Define the primary target with the name 'JsonC::JsonC' add_library(JsonC::JsonC SHARED IMPORTED) # 2. Set the public interface (headers) Loading @@ -52,22 +51,17 @@ if(JSONC_FOUND) ) # CRITICAL FOR DLL PATH RESOLUTION: Determine the DLL path. # We assume a common structure: DLLs are in 'bin' and .lib are in 'lib'. get_filename_component(_LIB_DIR "${JSONC_LIBRARY}" DIRECTORY) get_filename_component(_PARENT_DIR "${_LIB_DIR}" DIRECTORY) # Determine the DLL name (strip prefix/suffix, often just 'json-c') # Determine the DLL name get_filename_component(_LIB_NAME_WE "${JSONC_LIBRARY}" NAME_WE) string(REGEX REPLACE "^lib" "" _DLL_NAME_BASE "${_LIB_NAME_WE}") # 💡 Heuristic: Assuming DLL is in <parent>/bin/ # Set IMPORTED_LOCATION for both Debug and Release configurations # Set IMPORTED_LOCATION for configurations set_target_properties(JsonC::JsonC PROPERTIES # Assuming VCPKG/standard installs put the DLL in bin/ IMPORTED_LOCATION_RELEASE "${_PARENT_DIR}/bin/${_DLL_NAME_BASE}.dll" # Assuming a common debug suffix 'd' (e.g., json-cd.dll) IMPORTED_LOCATION_DEBUG "${_PARENT_DIR}/bin/${_DLL_NAME_BASE}d.dll" # Add RelWithDebInfo as well, which might have the same DLL name as Release IMPORTED_LOCATION_RELWITHDEBINFO "${_PARENT_DIR}/bin/${_DLL_NAME_BASE}.dll" ) Loading @@ -78,6 +72,13 @@ if(JSONC_FOUND) ) endif() # ----------------------------------------------------------------------------- # 4. Define Alias for Consumer (Fixes the json-c::json-c-NOTFOUND error) # ----------------------------------------------------------------------------- # The consumer (src/authdb.exe) is looking for json-c::json-c (lowercase). # Create an ALIAS target pointing to the primary target JsonC::JsonC. add_library(json-c::json-c ALIAS JsonC::JsonC) endif() # Hide internal variables from the CMake GUI Loading Loading
cmake/Findjson-c.cmake +11 −10 Changes for cmake/Findjson-c.cmake: 11 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -30,13 +30,12 @@ find_package_handle_standard_args(JsonC ) # ----------------------------------------------------------------------------- # 3. Define Imported Shared Target # 3. Define Imported Shared Target (Internal Name) # ----------------------------------------------------------------------------- if(JSONC_FOUND) # 1. Define the target as SHARED IMPORTED # We use a single target since json-c is generally one library. # 1. Define the primary target with the name 'JsonC::JsonC' add_library(JsonC::JsonC SHARED IMPORTED) # 2. Set the public interface (headers) Loading @@ -52,22 +51,17 @@ if(JSONC_FOUND) ) # CRITICAL FOR DLL PATH RESOLUTION: Determine the DLL path. # We assume a common structure: DLLs are in 'bin' and .lib are in 'lib'. get_filename_component(_LIB_DIR "${JSONC_LIBRARY}" DIRECTORY) get_filename_component(_PARENT_DIR "${_LIB_DIR}" DIRECTORY) # Determine the DLL name (strip prefix/suffix, often just 'json-c') # Determine the DLL name get_filename_component(_LIB_NAME_WE "${JSONC_LIBRARY}" NAME_WE) string(REGEX REPLACE "^lib" "" _DLL_NAME_BASE "${_LIB_NAME_WE}") # 💡 Heuristic: Assuming DLL is in <parent>/bin/ # Set IMPORTED_LOCATION for both Debug and Release configurations # Set IMPORTED_LOCATION for configurations set_target_properties(JsonC::JsonC PROPERTIES # Assuming VCPKG/standard installs put the DLL in bin/ IMPORTED_LOCATION_RELEASE "${_PARENT_DIR}/bin/${_DLL_NAME_BASE}.dll" # Assuming a common debug suffix 'd' (e.g., json-cd.dll) IMPORTED_LOCATION_DEBUG "${_PARENT_DIR}/bin/${_DLL_NAME_BASE}d.dll" # Add RelWithDebInfo as well, which might have the same DLL name as Release IMPORTED_LOCATION_RELWITHDEBINFO "${_PARENT_DIR}/bin/${_DLL_NAME_BASE}.dll" ) Loading @@ -78,6 +72,13 @@ if(JSONC_FOUND) ) endif() # ----------------------------------------------------------------------------- # 4. Define Alias for Consumer (Fixes the json-c::json-c-NOTFOUND error) # ----------------------------------------------------------------------------- # The consumer (src/authdb.exe) is looking for json-c::json-c (lowercase). # Create an ALIAS target pointing to the primary target JsonC::JsonC. add_library(json-c::json-c ALIAS JsonC::JsonC) endif() # Hide internal variables from the CMake GUI Loading