summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake
blob: f5f78579a6eab434d0648bddcb56edb3ba2241c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

enable_language(C)

set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED TRUE)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
  AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:--start-group"
                                        "LINKER:--end-group")
elseif(CMAKE_C_COMPILER_ID STREQUAL "SunPro"
       AND CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:-z,rescan-start"
                                          "LINKER:-z,rescan-end")
else()
  # feature not yet supported for the other environments
  set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED FALSE)
endif()

add_library(func1 STATIC func1.c func3.c)
add_library(func2 STATIC func2.c)

add_executable(main main.c)
target_link_libraries(main PRIVATE "$<LINK_GROUP:cross_refs,func1,func2>")