comparison CMakeLists.txt @ 1522:6766485fb584

Better error handling for CMake LLVM config file detection.
author Christian Kamm <kamm incasoftware de>
date Fri, 03 Jul 2009 18:49:42 +0200
parents 1a93c3da09ef
children 259b031f3d22
comparison
equal deleted inserted replaced
1521:982eb70e83b2 1522:6766485fb584
142 ) 142 )
143 143
144 # build a define that contains all LLVM targets required and is usable for 144 # build a define that contains all LLVM targets required and is usable for
145 # preprocessor code generation. start with the native target. 145 # preprocessor code generation. start with the native target.
146 find_path(LLVM_CONFIG_FILE_PATH config.h PATHS ${LLVM_INCLUDEDIR}/llvm/Config ${LLVM_INCLUDEDIR}/Config NO_DEFAULT_PATH) 146 find_path(LLVM_CONFIG_FILE_PATH config.h PATHS ${LLVM_INCLUDEDIR}/llvm/Config ${LLVM_INCLUDEDIR}/Config NO_DEFAULT_PATH)
147 message(${LLVM_CONFIG_FILE_PATH}/config.h) 147 if(LLVM_CONFIG_FILE_PATH STREQUAL "LLVM_CONFIG_FILE_PATH-NOTFOUND")
148 file(STRINGS ${LLVM_CONFIG_FILE_PATH}/config.h LLVM_NATIVE_ARCH REGEX "^#define LLVM_NATIVE_ARCH") 148 message("Couldn't find your llvm Config.h file in ${LLVM_INCLUDEDIR}, no native target will be initialized.")
149 string(REGEX REPLACE "^#define LLVM_NATIVE_ARCH (.*)Target$" "\\1" LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}) 149 else(LLVM_CONFIG_FILE_PATH STREQUAL "LLVM_CONFIG_FILE_PATH-NOTFOUND")
150 set(LLVM_MODULES_DEFINE "LLVM_TARGET(${LLVM_NATIVE_ARCH})") 150 file(STRINGS ${LLVM_CONFIG_FILE_PATH}/config.h LLVM_NATIVE_ARCH REGEX "^#define LLVM_NATIVE_ARCH")
151 if(LLVM_NATIVE_ARCH)
152 string(REGEX REPLACE "^#define LLVM_NATIVE_ARCH (.*)Target$" "\\1" LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH})
153 message("Found native target ${LLVM_NATIVE_ARCH}")
154 set(LLVM_MODULES_DEFINE "LLVM_TARGET(${LLVM_NATIVE_ARCH})")
155 else(LLVM_NATIVE_ARCH)
156 message("Couldn't find the LLVM_NATIVE_ARCH define in ${LLVM_CONFIG_FILE_PATH}/config.h. Probably you have an older LLVM and can ignore this warning.")
157 endif(LLVM_NATIVE_ARCH)
158 endif(LLVM_CONFIG_FILE_PATH STREQUAL "LLVM_CONFIG_FILE_PATH-NOTFOUND")
151 # chain the extra target list to the define 159 # chain the extra target list to the define
152 foreach(EXTRA_TARGET ${EXTRA_LLVM_MODULES}) 160 foreach(EXTRA_TARGET ${EXTRA_LLVM_MODULES})
153 set(LLVM_MODULES_DEFINE "${LLVM_MODULES_DEFINE} LLVM_TARGET(${EXTRA_TARGET})") 161 set(LLVM_MODULES_DEFINE "${LLVM_MODULES_DEFINE} LLVM_TARGET(${EXTRA_TARGET})")
154 endforeach(EXTRA_TARGET) 162 endforeach(EXTRA_TARGET)
155 set_source_files_properties( 163 set_source_files_properties(