lokinet/cmake/static_link.cmake

24 lines
565 B
CMake
Raw Normal View History

2019-09-18 20:19:13 +00:00
if(NOT STATIC_LINK)
2019-08-17 11:33:07 +00:00
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
add_compile_options(-static -flto)
else()
add_compile_options(-static)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2019-09-18 20:19:13 +00:00
link_libraries( -flto)
2019-09-24 09:29:11 +00:00
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
set(CMAKE_AR "gcc-ar")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "true")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH "true")
link_libraries( -flto )
2019-08-17 11:33:07 +00:00
endif()