allow optional static linking

- add cmake option `CMAKE_LINK_STATIC`
- add missing `CMAKE_C_FLAGS`
This commit is contained in:
psychocrypt 2017-04-20 21:21:10 +02:00
parent ef114a1cd3
commit bffbc9d374
1 changed files with 13 additions and 2 deletions

View File

@ -36,6 +36,9 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}") set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")
# option to add static libgcc and libstdc++
option(CMAKE_LINK_STATIC "link as much as possible libraries static" OFF)
############################################################################### ###############################################################################
# Find OpenCL # Find OpenCL
############################################################################### ###############################################################################
@ -83,6 +86,15 @@ include_directories(.)
# activate sse2 and aes-ni # activate sse2 and aes-ni
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -maes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -maes")
# activate static libgcc and libstdc++ linking
if(CMAKE_LINK_STATIC)
set(BUILD_SHARED_LIBRARIES OFF)
set(DL_LIB ${CMAKE_DL_LIBS})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(LIBS "-static-libgcc -static-libstdc++ ${LIBS}")
endif()
file(GLOB SRCFILES_CPP "*.cpp" "crypto/*.cpp") file(GLOB SRCFILES_CPP "*.cpp" "crypto/*.cpp")
file(GLOB SRCFILES_C "crypto/*.c" "amd_gpu/*.c") file(GLOB SRCFILES_C "crypto/*.c" "amd_gpu/*.c")
@ -98,7 +110,7 @@ add_executable(xmr-stak-amd
) )
set(EXECUTABLE_OUTPUT_PATH "bin") set(EXECUTABLE_OUTPUT_PATH "bin")
target_link_libraries(xmr-stak-amd xmr-stak-c ${LIBS}) target_link_libraries(xmr-stak-amd ${LIBS} xmr-stak-c)
################################################################################ ################################################################################
# Install # Install
@ -121,4 +133,3 @@ install(CODE " \
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)\n \ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)\n \
endif()" endif()"
) )