summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-04-20 21:21:10 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-04-20 21:21:10 +0200
commit015111fae68c5941362d9287be1dbfc38197a344 (patch)
treea8a3c51e9edd0625ece8b60d646d667cabea0e2f /CMakeLists.txt
parentddfcbd3c4ab9a37c06598a6e4898ed54d2922236 (diff)
downloadxmr-stak-015111fae68c5941362d9287be1dbfc38197a344.zip
xmr-stak-015111fae68c5941362d9287be1dbfc38197a344.tar.gz
allow optional static linking
- add cmake option `CMAKE_LINK_STATIC` - add missing `CMAKE_C_FLAGS` - change documentation
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt14
1 files changed, 13 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5aa8b16..e87d69d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,9 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
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 PThreads
################################################################################
@@ -83,6 +86,15 @@ endif()
# activate sse2 and aes-ni
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_C "crypto/*.c")
@@ -98,7 +110,7 @@ add_executable(xmr-stak-cpu
)
set(EXECUTABLE_OUTPUT_PATH "bin")
-target_link_libraries(xmr-stak-cpu xmr-stak-c ${LIBS})
+target_link_libraries(xmr-stak-cpu ${LIBS} xmr-stak-c)
################################################################################
# Install
OpenPOWER on IntegriCloud