@@ -84,6 +84,8 @@ set(configure_warnings)
84
84
# It is intended to be a usage requirement for all other targets.
85
85
add_library (core INTERFACE )
86
86
87
+ include (TryAppendLinkerFlag )
88
+
87
89
if (WIN32 )
88
90
#[=[
89
91
This build system supports two ways to build binaries for Windows.
@@ -126,14 +128,29 @@ if(WIN32)
126
128
_MT
127
129
)
128
130
# We require Windows 7 (NT 6.1) or later.
129
- add_link_options (-Wl,--major-subsystem-version,6 -Wl,--minor-subsystem-version,1 )
131
+ try_append_linker_flag (core "-Wl,--major-subsystem-version,6" )
132
+ try_append_linker_flag (core "-Wl,--minor-subsystem-version,1" )
130
133
endif ()
131
134
endif ()
132
135
136
+ # Use 64-bit off_t on 32-bit Linux.
137
+ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SIZEOF_VOID_P EQUAL 4 )
138
+ # Ensure 64-bit offsets are used for filesystem accesses for 32-bit compilation.
139
+ target_compile_definitions (core INTERFACE
140
+ _FILE_OFFSET_BITS=64
141
+ )
142
+ endif ()
143
+
133
144
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
134
145
target_compile_definitions (core INTERFACE
135
146
MAC_OSX
136
147
)
148
+ # These flags are specific to ld64, and may cause issues with other linkers.
149
+ # For example: GNU ld will interpret -dead_strip as -de and then try and use
150
+ # "ad_strip" as the symbol for the entry point.
151
+ try_append_linker_flag (core "-Wl,-dead_strip" )
152
+ try_append_linker_flag (core "-Wl,-dead_strip_dylibs" )
153
+ try_append_linker_flag (core "-Wl,-headerpad_max_install_names" )
137
154
endif ()
138
155
139
156
if (CMAKE_CROSSCOMPILING AND DEPENDS_ALLOW_HOST_PACKAGES )
@@ -230,6 +247,8 @@ else()
230
247
set (common_link_options )
231
248
endif ()
232
249
message ("Common link options ................... ${common_link_options} " )
250
+ message ("Linker flags for executables .......... ${CMAKE_EXE_LINKER_FLAGS} " )
251
+ message ("Linker flags for shared libraries ..... ${CMAKE_SHARED_LINKER_FLAGS} " )
233
252
if (DEFINED CMAKE_BUILD_TYPE )
234
253
message ("Build type:" )
235
254
message (" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE} " )
0 commit comments