2019-09-18 20:19:13 +00:00
|
|
|
if(NOT STATIC_LINK_RUNTIME)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# not supported on Solaris - system libraries are not available as archives
|
|
|
|
# LTO is supported only for native builds
|
|
|
|
if(SOLARIS)
|
|
|
|
link_libraries( -static-libstdc++ -static-libgcc )
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
2019-10-12 19:01:24 +00:00
|
|
|
add_compile_options(-static -flto)
|
2019-09-18 20:19:13 +00:00
|
|
|
else()
|
|
|
|
add_compile_options(-static)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
if(APPLE)
|
|
|
|
link_libraries( -flto)
|
|
|
|
else()
|
|
|
|
link_libraries( -static -static-libstdc++ -pthread -flto )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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")
|
2019-10-12 03:44:50 +00:00
|
|
|
link_libraries( -flto -static-libstdc++ -static-libgcc -static ${CMAKE_CXX_FLAGS} ${CRYPTO_FLAGS} )
|
2019-09-18 20:19:13 +00:00
|
|
|
else()
|
2019-10-17 01:39:59 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static" )
|
2019-09-18 20:19:13 +00:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
|
|
|
endif()
|