[LLVMdev] A patch for refine the cmake system and also configure

罗勇刚(Yonggang Luo)
2009-08-27T14:20:15Z

>
> What do you want to improve exactly? Do you experience
> problems?
>
not only iterator.h but also DataTypes.h

I also put back iterator.h because at the trunk of llvm, iterator.h.in
and iterator.h.cmake still there:(
My improvement is now we didn't to generate DataTyes.h,
we just need to generate config.h,
And everything is configured at config.h, but not in seperate files.:)

Also DataTypes.h
and iterator.hn

at the config.h.cmake
I did the these changes. So at iterator.h, we can import the necessary
defines from config.h.

/**************************************
 ** Created by Kevin from config.h.in **
 ***************************************/
+#ifdef LLVM_IMPORT_ITERATOR_CONFIG

+/* Define to 1 if you have the `bidirectional_iterator' struct*/
+#cmakedefine HAVE_BI_ITERATOR ${HAVE_BI_ITERATOR}
+
+/* Define to 1 if you have the standard `iterator' struct */
+#cmakedefine HAVE_STD_ITERATOR ${HAVE_STD_ITERATOR}
+
+/* Define to 1 if you have the `forward_iterator' struct*/
+#cmakedefine HAVE_FWD_ITERATOR ${HAVE_FWD_ITERATOR}
+
+#elif defined(LLVM_IMPORT_DATATYPES_CONFIG)
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
+
+/* Define to 1 if the system has the type `u_int64_t'. */
+#cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}
+
+#else
+
 /* Define if dlopen(0) will open the symbols of the program */
 #undef CAN_DLOPEN_SELF




Just using
+#define LLVM_IMPORT_ITERATOR_CONFIG
+#include "llvm/Config/config.h"
+#undef LLVM_IMPORT_ITERATOR_CONFIG
in iterator.h, we can import the macro define
 +/* Define to 1 if you have the `bidirectional_iterator' struct*/
+#cmakedefine HAVE_BI_ITERATOR ${HAVE_BI_ITERATOR}
+
+/* Define to 1 if you have the standard `iterator' struct */
+#cmakedefine HAVE_STD_ITERATOR ${HAVE_STD_ITERATOR}
+
+/* Define to 1 if you have the `forward_iterator' struct*/
+#cmakedefine HAVE_FWD_ITERATOR ${HAVE_FWD_ITERATOR}


also
just using
+#define LLVM_IMPORT_DATATYPES_CONFIG
+#include "llvm/Config/config.h"
+#undef LLVM_IMPORT_DATATYPES_CONFIG

we can import

+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
+
+/* Define to 1 if the system has the type `u_int64_t'. */
+#cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}


And because I add
Index: cmake/modules/CheckSymbols.cmake
so that we can using check_type_exists in cmake to identify
HAVE_U_INT64_T
and
HAVE_UINT64_T
and also
+#cmakedefine HAVE_BI_ITERATOR ${HAVE_BI_ITERATOR}
+
+/* Define to 1 if you have the standard `iterator' struct */
+#cmakedefine HAVE_STD_ITERATOR ${HAVE_STD_ITERATOR}
+
+/* Define to 1 if you have the `forward_iterator' struct*/
+#cmakedefine HAVE_FWD_ITERATOR ${HAVE_FWD_ITERATOR}


That's why I submit the patch.
This can simplify the config progress.
And because we using the macro define

LLVM_IMPORT_DATATYPES_CONFIG
LLVM_IMPORT_ITERATOR_CONFIG

we can seperate llvm/Config/config.h to three(3) different part.
and at default, we are using the last part. that's the else part.

And also if there is any other place need config in Config.h,
we can also do it like these.
we can  focus on only one file config.h, that's all, and we doesn't
need to care about iterator.h.cmake or DataTypes.h.cmake.