Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3c24c32

Browse files
Alexander Soldatovweshaggard
authored andcommitted
[Unix] Passing extra CMake args (#26792)
Added support for compiler and linker additional arguments in CMake. By using CLR_ADDITIONAL_LINKER_FLAGS and CLR_ADDITIONAL_COMPILER_OPTIONS it's possible to pass toolchain options without changing build scripts.
1 parent e2cd5a8 commit 3c24c32

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Native/Unix/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
148148
set(CLR_CMAKE_PLATFORM_UNIX 1)
149149
endif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
150150

151+
# CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
152+
# CLR_ADDITIONAL_COMPILER_OPTIONS - used for passing additional arguments to compiler
153+
#
154+
# For example:
155+
# ./build-native.sh cmakeargs -DCLR_ADDITIONAL_COMPILER_OPTIONS=<...> cmakeargs -DCLR_ADDITIONAL_LINKER_FLAGS=<...>
156+
#
157+
if(CLR_CMAKE_PLATFORM_UNIX)
158+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}")
159+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}" )
160+
add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS})
161+
endif(CLR_CMAKE_PLATFORM_UNIX)
162+
151163
if (NOT WIN32)
152164
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
153165
# Ensure that dsymutil and strip are present

0 commit comments

Comments
 (0)