1 # Disable warnings for upstream projects.
3 set(DISABLE_WARNING_FLAGS
4 -wd4018 # 'expression' : signed/unsigned mismatch
5 -wd4090 # 'operation' : different 'modifier' qualifiers
6 -wd4200 # nonstandard extension used: zero-sized array in struct/union
7 -wd4201 # nonstandard extension used: nameless struct/union
8 -wd4334 # 'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
9 -wd4221 # nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable
12 set(DISABLE_WARNING_FLAGS "-w")
16 # External: Integer Set Library
17 if (POLLY_BUNDLED_ISL)
18 set(ISL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/isl")
19 set(ISL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/isl")
21 # Determine version of isl
22 if (EXISTS "${ISL_SOURCE_DIR}/GIT_HEAD_ID")
23 # The source comes from a 'make dist' archive
24 file(READ "${ISL_SOURCE_DIR}/GIT_HEAD_ID" ISL_GIT_HEAD_ID)
25 string(STRIP "${ISL_GIT_HEAD_ID}" ISL_GIT_HEAD_ID)
26 elseif (EXISTS "${ISL_SOURCE_DIR}/gitversion.h")
27 # The source directory is preconfigured
28 file(READ "${ISL_SOURCE_DIR}/gitversion.h" GITVERSION_H)
29 string(REGEX REPLACE ".*\\\"([^\\\"]*)\\\".*" "\\1" ISL_GIT_HEAD_ID "${GITVERSION_H}")
32 # TODO: We could look for a .git and get the revision from HEAD
33 set(ISL_GIT_HEAD_ID "UNKNOWN")
36 message(STATUS "ISL version: ${ISL_GIT_HEAD_ID}")
38 # Enable small integer optimization and imath
39 set(USE_GMP_FOR_MP OFF)
40 set(USE_IMATH_FOR_MP ON)
41 set(USE_SMALL_INT_OPT ON)
43 # Determine compiler characteristics
44 include(CheckCSourceCompiles)
46 # Like check_c_source_compiles, but sets the result to either
47 # 0 (error while compiling) or 1 (compiled successfully)
48 # Required for compatibility with autotool's AC_CHECK_DECLS
49 function (check_c_source_compiles_numeric _prog _var)
50 check_c_source_compiles("${_prog}" "${_var}")
52 set("${_var}" 1 PARENT_SCOPE)
54 set("${_var}" 0 PARENT_SCOPE)
58 # Check for the existance of a type
59 function (check_c_type_exists _type _files _variable)
61 foreach (file_name ${_files})
62 set(_includes "${_includes}#include<${file_name}>\n")
64 check_c_source_compiles("
74 check_c_source_compiles("
75 int func(void) __attribute__((__warn_unused_result__));
76 int main(void) { return 0; }
77 " HAS_ATTRIBUTE_WARN_UNUSED_RESULT)
78 set(GCC_WARN_UNUSED_RESULT)
79 if (HAS_ATTRIBUTE_WARN_UNUSED_RESULT)
80 set(GCC_WARN_UNUSED_RESULT "__attribute__((__warn_unused_result__))")
83 check_c_source_compiles("
84 __attribute__ ((unused)) static void foo(void);
85 int main(void) { return 0; }
89 check_c_source_compiles_numeric("
91 int main(void) { (void)ffs(0); return 0; }
94 check_c_source_compiles_numeric("
95 int main(void) { (void)__builtin_ffs(0); return 0; }
96 " HAVE_DECL___BUILTIN_FFS)
98 check_c_source_compiles_numeric("
100 int main(void) { (void)_BitScanForward(NULL, 0); return 0; }
101 " HAVE_DECL__BITSCANFORWARD)
103 if (NOT HAVE_DECL_FFS AND
104 NOT HAVE_DECL___BUILTIN_FFS AND
105 NOT HAVE_DECL__BITSCANFORWARD)
106 message(FATAL_ERROR "No ffs implementation found")
110 check_c_source_compiles_numeric("
112 int main(void) { (void)strcasecmp(\"\", \"\"); return 0; }
113 " HAVE_DECL_STRCASECMP)
115 check_c_source_compiles_numeric("
117 int main(void) { (void)_stricmp(\"\", \"\"); return 0; }
118 " HAVE_DECL__STRICMP)
120 if (NOT HAVE_DECL_STRCASECMP AND NOT HAVE_DECL__STRICMP)
121 message(FATAL_ERROR "No strcasecmp implementation found")
125 check_c_source_compiles_numeric("
127 int main(void) { (void)strncasecmp(\"\", \"\", 0); return 0; }
128 " HAVE_DECL_STRNCASECMP)
130 check_c_source_compiles_numeric("
132 int main(void) { (void)_strnicmp(\"\", \"\", 0); return 0; }
133 " HAVE_DECL__STRNICMP)
135 if (NOT HAVE_DECL_STRNCASECMP AND NOT HAVE_DECL__STRNICMP)
136 message(FATAL_ERROR "No strncasecmp implementation found")
140 check_c_source_compiles_numeric("
142 int main(void) { snprintf((void*)0, 0, \" \"); return 0; }
143 " HAVE_DECL_SNPRINTF)
145 check_c_source_compiles_numeric("
147 int main(void) { _snprintf((void*)0, 0, \" \"); return 0; }
148 " HAVE_DECL__SNPRINTF)
150 if (NOT HAVE_DECL_SNPRINTF AND NOT HAVE_DECL__SNPRINTF)
151 message(FATAL_ERROR "No snprintf implementation found")
155 check_c_type_exists(uint8_t "" HAVE_UINT8T)
156 check_c_type_exists(uint8_t "stdint.h" HAVE_STDINT_H)
157 check_c_type_exists(uint8_t "inttypes.h" HAVE_INTTYPES_H)
158 check_c_type_exists(uint8_t "sys/types.h" HAVE_SYS_INTTYPES_H)
160 set(INCLUDE_STDINT_H "")
161 elseif (HAVE_STDINT_H)
162 set(INCLUDE_STDINT_H "#include <stdint.h>")
163 elseif (HAVE_INTTYPES_H)
164 set(INCLUDE_STDINT_H "#include <inttypes.h>")
165 elseif (HAVE_SYS_INTTYPES_H)
166 set(INCLUDE_STDINT_H "#include <sys/inttypes.h>")
168 message(FATAL_ERROR "No stdint.h or compatible found")
171 # Write configure result
172 # configure_file(... COPYONLY) avoids that the time stamp changes if the file is identical
173 file(WRITE "${ISL_BINARY_DIR}/gitversion.h.tmp"
174 "#define GIT_HEAD_ID \"${ISL_GIT_HEAD_ID}\"")
175 configure_file("${ISL_BINARY_DIR}/gitversion.h.tmp"
176 "${ISL_BINARY_DIR}/gitversion.h" COPYONLY)
178 file(WRITE "${ISL_BINARY_DIR}/include/isl/stdint.h.tmp"
179 "${INCLUDE_STDINT_H}\n")
180 configure_file("${ISL_BINARY_DIR}/include/isl/stdint.h.tmp"
181 "${ISL_BINARY_DIR}/include/isl/stdint.h" COPYONLY)
183 configure_file("isl_config.h.cmake" "${ISL_BINARY_DIR}/isl_config.h")
184 configure_file("isl_srcdir.c.cmake" "${ISL_BINARY_DIR}/isl_srcdir.c")
186 include_directories(BEFORE
188 ${ISL_SOURCE_DIR}/imath
189 ${ISL_SOURCE_DIR}/include
193 # ISL files to compile
195 isl/basis_reduction_tab.c
198 isl/isl_affine_hull.c
201 isl/isl_ast_build_expr.c
203 isl/isl_ast_codegen.c
211 isl/isl_convex_hull.c
216 isl/isl_factorization.c
223 isl/isl_id_to_ast_expr.c
225 isl/isl_id_to_pw_aff.c
229 isl/isl_int_sioimath.c
231 isl/isl_local_space.c
235 isl/isl_map_simplify.c
236 isl/isl_map_subtract.c
237 isl/isl_map_to_basic_set.c
251 isl/isl_schedule_band.c
252 isl/isl_schedule_constraints.c
253 isl/isl_schedule_node.c
254 isl/isl_schedule_read.c
255 isl/isl_schedule_tree.c
257 isl/isl_scheduler_clustering.c
258 isl/isl_scheduler_scc.c
261 isl/isl_set_to_ast_graft_list.c
269 isl/isl_transitive_closure.c
272 isl/isl_val_sioimath.c
281 isl/imath/gmp_compat.c
286 add_polly_library(PollyISL
291 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
293 ${ISL_SOURCE_DIR}/include/
294 ${ISL_BINARY_DIR}/include/
295 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/polly"
298 PATTERN "CMakeFiles" EXCLUDE
302 add_executable(polly-isl-test
305 set_target_properties(polly-isl-test PROPERTIES FOLDER "Polly")
307 target_link_libraries(polly-isl-test PRIVATE
311 # ISL requires at least C99 to compile. gcc < 5.0 use -std=gnu89 as default.
312 set_property(TARGET PollyISL polly-isl-test PROPERTY C_STANDARD 99)
314 target_compile_options(PollyISL PRIVATE ${DISABLE_WARNING_FLAGS})
315 target_compile_options(polly-isl-test PRIVATE ${DISABLE_WARNING_FLAGS})
316 endif (POLLY_BUNDLED_ISL)