Skip to content

Commit 21ca9d4

Browse files
authored
Merge pull request #32111 from gottesmm/pr-846f5396754c136c8adbf30b79b0b1c4b33ff9e5
[cmake] Move ar linking optimization rule into UnixCompileRules.cmake and only run it on Unix-like platforms.
2 parents 21bf781 + 72d8d9b commit 21ca9d4

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

CMakeLists.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ endif()
413413

414414
if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
415415
include(ClangClCompileRules)
416+
elseif(UNIX)
417+
include(UnixCompileRules)
416418
endif()
417419

418420
if(CMAKE_C_COMPILER_ID MATCHES Clang)
@@ -432,19 +434,6 @@ if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
432434
endif()
433435
endif()
434436

435-
#
436-
# Assume a new enough ar to generate the index at construction time. This avoids
437-
# having to invoke ranlib as a secondary command.
438-
#
439-
440-
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
441-
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
442-
set(CMAKE_C_ARCHIVE_FINISH "")
443-
444-
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
445-
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
446-
set(CMAKE_CXX_ARCHIVE_FINISH "")
447-
448437
#
449438
# Include CMake modules
450439
#

cmake/modules/UnixCompileRules.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#
3+
# Assume a new enough ar to generate the index at construction time. This avoids
4+
# having to invoke ranlib as a secondary command.
5+
#
6+
7+
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
8+
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
9+
set(CMAKE_C_ARCHIVE_FINISH "")
10+
11+
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
12+
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
13+
set(CMAKE_CXX_ARCHIVE_FINISH "")

0 commit comments

Comments
 (0)