Skip to content

Commit d2e4c05

Browse files
authored
Add cmake option for linker (#295)
1 parent 26834a3 commit d2e4c05

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.10)
22

3+
include(CheckCXXSourceCompiles)
4+
35
if(POLICY CMP0068)
46
cmake_policy(SET CMP0068 NEW)
57
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
@@ -55,6 +57,21 @@ else ()
5557
include_directories(${POLYGEIST_TABLEGEN_OUTPUT_DIR})
5658
endif()
5759

60+
function(append value)
61+
foreach(variable ${ARGN})
62+
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
63+
endforeach(variable)
64+
endfunction()
65+
66+
if( POLYGEIST_USE_LINKER )
67+
append("-fuse-ld=${POLYGEIST_USE_LINKER}"
68+
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
69+
check_cxx_source_compiles("int main() { return 0; }" CXX_SUPPORTS_CUSTOM_LINKER)
70+
if ( NOT CXX_SUPPORTS_CUSTOM_LINKER )
71+
message(FATAL_ERROR "Host compiler does not support '-fuse-ld=${LLVM_USE_LINKER}'")
72+
endif()
73+
endif()
74+
5875
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
5976
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
6077
list(APPEND CMAKE_MODULE_PATH "${CLANG_CMAKE_DIR}")

0 commit comments

Comments
 (0)