[CMake] reading a variable causes a segfault

Pablo Yanez Trujillo shaoran at sakuranohana.org
Fri Nov 21 10:20:11 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

I'm using (on a Gentoo/Linux) box cmake version 2.4-patch 6 and I think I've found a bug in cmake.

I am writting a MACRO that creates targets (with ADD_LIBRARY) depending on values of the first paremeter and predefined
variables. The idea is to have something similar of Makefile.am

SET(cu_blmotor_DEPS cu_dsp_402)
SET(cu_blmotor_SRC_REGEX "cu_bl.*.c")

CREATE_DRV_TARGET(cu_blmotor)
CREATE_DRV_TARGET(cu_dsp_402)

The CREATE_DRV_TARGET macro is the one I'm writting. Using those variables I'm able to tell the macro which
modules depend on which modules, what are their source files, etc. The macro has currently this:

MACRO(CREATE_DRV_TARGET MODULE_NAME)
    SET(DRV_TARGET_SOURCE "")
    SET(MOD_SRC_REGEX ${${MODULE_NAME}_SRC_REGEX})
    SET(MOD_SRC ${${MODULE_NAME}_SRC})
    MESSAGE("Creating target for ${MODULE_NAME}")


    MESSAGE("MOD_SRC_REGEX is ${MOD_SRC_REGEX}")

    IF(NOT MOD_SRC_REGEX MATCHES "^$")
        MESSAGE("In if MOD_SRC_REGEX is ${MOD_SRC_REGEX}")
        SET(MOD_SRC "")
        FILE(GLOB DRV_TARGET_SOURCE "${MOD_SRC_REGEX}")
    ENDIF(NOT MOD_SRC_REGEX MATCHES "^$")
...
ENDMACRO(CREATE_DRV_TARGET)

If I execute cmake I get:
cmake ..
Creating target for cu_blmotor
MOD_SRC_REGEX is ot*.c
In if MOD_SRC_REGEX is ot*.c
Creating target for cu_dsp_402
MOD_SRC_REGEX is
In if MOD_SRC_REGEX is
Segmentation fault


The segfault comes when cu_dsp_402_SRC_REGEX is either undefined or is set to "". I'm not sure whether this is a real
bug of cmake (at least cmake should not die with segfault) or I'm not implementing my idea correctly. Should it be
better if I first check whether the ${MODULE_NAME}_SRC_REGEX variables are definied or not instead of relying that
undefined variables are empty?

Does cmake have a bugtrucker where you can submit bugs?

Thanks,
Pablo


- --
Pablo Yanez Trujillo
http://klingsor.informatik.uni-freiburg.de
My public key: http://klingsor.informatik.uni-freiburg.de/gpg/supertux.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkm0asACgkQDzf8xo+0xRXVUwCeJJuQPfVpHoiV2dK3nFTvhM/3
Rk4AnAuXq/6W7ZkNhFQn7FwxqdymbLzr
=9tSU
-----END PGP SIGNATURE-----


More information about the CMake mailing list