2012-10-21 23:51:49 +08:00
|
|
|
|
2015-09-24 19:30:22 +08:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
|
2012-10-21 23:51:49 +08:00
|
|
|
macro(add_polly_library name)
|
2015-09-24 19:30:22 +08:00
|
|
|
cmake_parse_arguments(ARG "FORCE_STATIC" "" "" ${ARGN})
|
|
|
|
set(srcs ${ARG_UNPARSED_ARGUMENTS})
|
2012-10-21 23:51:49 +08:00
|
|
|
if(MSVC_IDE OR XCODE)
|
|
|
|
file( GLOB_RECURSE headers *.h *.td *.def)
|
|
|
|
set(srcs ${srcs} ${headers})
|
|
|
|
string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
list( GET split_path -1 dir)
|
|
|
|
file( GLOB_RECURSE headers
|
|
|
|
../../include/polly${dir}/*.h)
|
|
|
|
set(srcs ${srcs} ${headers})
|
|
|
|
endif(MSVC_IDE OR XCODE)
|
|
|
|
if (MODULE)
|
|
|
|
set(libkind MODULE)
|
2015-09-24 19:30:22 +08:00
|
|
|
elseif (ARG_FORCE_STATIC)
|
|
|
|
set(libkind STATIC)
|
2012-10-21 23:51:49 +08:00
|
|
|
elseif (SHARED_LIBRARY)
|
|
|
|
set(libkind SHARED)
|
|
|
|
else()
|
|
|
|
set(libkind)
|
|
|
|
endif()
|
|
|
|
add_library( ${name} ${libkind} ${srcs} )
|
2015-07-21 20:40:01 +08:00
|
|
|
set_target_properties(${name} PROPERTIES FOLDER "Polly")
|
|
|
|
|
2012-10-21 23:51:49 +08:00
|
|
|
if( LLVM_COMMON_DEPENDS )
|
|
|
|
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
|
|
|
|
endif( LLVM_COMMON_DEPENDS )
|
|
|
|
if( LLVM_USED_LIBS )
|
|
|
|
foreach(lib ${LLVM_USED_LIBS})
|
|
|
|
target_link_libraries( ${name} ${lib} )
|
|
|
|
endforeach(lib)
|
|
|
|
endif( LLVM_USED_LIBS )
|
|
|
|
|
2014-03-14 04:24:48 +08:00
|
|
|
if(POLLY_LINK_LIBS)
|
|
|
|
foreach(lib ${POLLY_LINK_LIBS})
|
|
|
|
target_link_libraries(${name} ${lib})
|
|
|
|
endforeach(lib)
|
|
|
|
endif(POLLY_LINK_LIBS)
|
2012-10-21 23:51:49 +08:00
|
|
|
|
|
|
|
if( LLVM_LINK_COMPONENTS )
|
|
|
|
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
|
|
|
|
endif( LLVM_LINK_COMPONENTS )
|
|
|
|
install(TARGETS ${name}
|
2014-11-30 20:45:44 +08:00
|
|
|
EXPORT LLVMExports
|
2016-04-09 22:09:08 +08:00
|
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
2012-10-21 23:51:49 +08:00
|
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
2014-11-30 20:45:44 +08:00
|
|
|
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
|
2012-10-21 23:51:49 +08:00
|
|
|
endmacro(add_polly_library)
|
|
|
|
|
|
|
|
macro(add_polly_loadable_module name)
|
|
|
|
set(srcs ${ARGN})
|
2014-03-04 03:30:19 +08:00
|
|
|
# klduge: pass different values for MODULE with multiple targets in same dir
|
|
|
|
# this allows building shared-lib and module in same dir
|
|
|
|
# there must be a cleaner way to achieve this....
|
|
|
|
if (MODULE)
|
|
|
|
else()
|
|
|
|
set(GLOBAL_NOT_MODULE TRUE)
|
|
|
|
endif()
|
|
|
|
set(MODULE TRUE)
|
2012-10-21 23:51:49 +08:00
|
|
|
add_polly_library(${name} ${srcs})
|
2015-07-21 20:40:01 +08:00
|
|
|
set_target_properties(${name} PROPERTIES FOLDER "Polly")
|
2014-03-04 03:30:19 +08:00
|
|
|
if (GLOBAL_NOT_MODULE)
|
|
|
|
unset (MODULE)
|
|
|
|
endif()
|
2012-10-21 23:51:49 +08:00
|
|
|
if (APPLE)
|
|
|
|
# Darwin-specific linker flags for loadable modules.
|
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
|
|
|
|
endif()
|
|
|
|
endmacro(add_polly_loadable_module)
|
2015-06-23 04:31:16 +08:00
|
|
|
|
2015-06-30 03:57:59 +08:00
|
|
|
# Use C99-compatible compile mode for all C source files of a target.
|
2015-06-23 04:31:16 +08:00
|
|
|
function(target_enable_c99 _target)
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER "3.1")
|
|
|
|
set_target_properties("${_target}" PROPERTIES C_STANDARD 99)
|
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
get_target_property(_sources "${_target}" SOURCES)
|
2015-06-30 03:57:59 +08:00
|
|
|
foreach(_file IN LISTS _sources)
|
|
|
|
get_source_file_property(_lang "${_file}" LANGUAGE)
|
|
|
|
if(_lang STREQUAL "C")
|
|
|
|
set_source_files_properties(${_file} COMPILE_FLAGS "-std=gnu99")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2015-06-23 04:31:16 +08:00
|
|
|
endif()
|
|
|
|
endfunction()
|