Skip to content

Commit 43eb249

Browse files
committed
Merge branch 'fix_651_bis' into 'master'
CMake: fix build with LLVM/Clang 17+ Closes #651 See merge request libtiff/libtiff!671
2 parents be8466a + 0dbcfc5 commit 43eb249

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

cmake/LinkerChecks.cmake

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ VERS_2 {
3939
} VERS_1;
4040
")
4141
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
42-
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
42+
if (CMAKE_VERSION GREATER_EQUAL 3.29 AND CMAKE_C_COMPILER_LINKER_ID STREQUAL "LLD" AND CMAKE_C_COMPILER_LINKER_VERSION GREATER_EQUAL 17)
43+
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--undefined-version "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
44+
else()
45+
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
46+
endif()
47+
4348
check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
4449
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
4550
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")

libtiff/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,13 @@ if(NOT CYGWIN)
201201
set_target_properties(tiff PROPERTIES VERSION ${SO_VERSION})
202202
endif()
203203
if(HAVE_LD_VERSION_SCRIPT)
204-
set_target_properties(tiff PROPERTIES LINK_FLAGS
205-
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtiff.map")
204+
if (CMAKE_VERSION GREATER_EQUAL 3.29 AND CMAKE_C_COMPILER_LINKER_ID STREQUAL "LLD" AND CMAKE_C_COMPILER_LINKER_VERSION GREATER_EQUAL 17)
205+
set_target_properties(tiff PROPERTIES LINK_FLAGS
206+
"-Wl,--undefined-version -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtiff.map")
207+
else()
208+
set_target_properties(tiff PROPERTIES LINK_FLAGS
209+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtiff.map")
210+
endif()
206211
endif()
207212

208213
if(tiff-install)

0 commit comments

Comments
 (0)