Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

CMake Config uses absolute paths.

Abierto
#987 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
54/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cmake
Área
build-system

Línea de trabajo

Comienza con CMakeLists.txt e inspecciona cómo las variables de GNUInstallDirs alimentan los archivos generados cjson.cmake, cjson_utils.cmake y cjson-<BUILD_TYPE>.cmake. Compara las importaciones generadas antes y después del cambio de configuración; se considera terminado cuando se puede encontrar un paquete cJSON instalado desde otro prefijo de instalación sin rutas codificadas.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Out of the box it is not possible to import cjson using find_package cmake command If you have not build the library yourself. This is due to the CMakeLists.txt file using CMAKE_INSTALL_FULL_* variables from GNUInstallDirs module which according to the documentation should not be used on install() commands.

In any case the fix is simple, just replace CMAKE_INSTALL_FULL_* variables with their relative counterparts (i.e., CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR, etc.)

If you want a little bit more detail. What happens is that if you use the FULL variables in install commands. The cmake config files will use the FULL path as the installation prefix instead of calculating the path at runtime base on the file location. You can see this in the cjson.cmake file (more or less line 48) and in cjson_utils.cmake where when using the FULL variant the code looks like this:

# The installation prefix configured by this project.
set(_IMPORT_PREFIX "/<my-person-install>/cjson/cjson-1.7.19/")


While when using the relative paths it looks like this:

# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
  set(_IMPORT_PREFIX "")
endif()

You can also see it on the cjson-<BUILD_TYPE>.cmake Where the IMPORTED_LOCATION_<BUILD_TYPE> will be the FULL path and if using the relative path variables it will just use the calculated _IMPORT_PREFIX instead.

If you want I can make a pull request with this simple fix. 😅

PS. This does not affect CJSON_INCLUDE_DIRS and CJSON_INCLUDE_DIR variables. Those still have the full path.

Lenguaje dominante
C
Estrellas
13k
Forks
3.5k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DaveGamble/cJSON

Todos los issues de DaveGamble/cJSON

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.