Skip to content

Commit 72d8d9b

Browse files
committed
[cmake] Move ar linking optimization rule into UnixCompileRules.cmake and only run it on Unix-like platforms.
This doesn't make sense on Windows and from what compnerd has said it doesnt even appear in the ninja rules file. This also moves this rule out of the main flow of the top level CMakeLists.txt file so I can reuse it when compiling the stdlib using a sub-cmake invocation.
1 parent 50c0534 commit 72d8d9b

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)