Skip to content

Commit 2daecf0

Browse files
committed
Fixing static compilation
1 parent 7d0257f commit 2daecf0

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

CMakeLists.txt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ if (SANITIZE)
104104
#add_cxx_flag("-Wsign-conversion")
105105
#add_cxx_flag("-Wconversion")
106106
add_cxx_flag("-Wdeprecated")
107-
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
107+
#set(CMAKE_EXE_LINKER_FLAGS " ${CMAKE_EXE_LINKER_FLAGS} -pie ")
108108
endif()
109109

110110
include(CheckCXXCompilerFlag)
@@ -208,7 +208,7 @@ if (COVERAGE)
208208
endif()
209209

210210
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
211-
set(CMAKE_EXE_LINKER_FLAGS " -Wl,--discard-all -Wl,--build-id=sha1")
211+
set(CMAKE_EXE_LINKER_FLAGS " ${CMAKE_EXE_LINKER_FLAGS} -Wl,--discard-all -Wl,--build-id=sha1")
212212
endif()
213213

214214
# -----------------------------------------------------------------------------
@@ -218,7 +218,8 @@ option(STATICCOMPILE "Compile to static executable (only works on linux)" OFF)
218218
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
219219
if(STATICCOMPILE)
220220
MESSAGE(STATUS "Compiling for static library use")
221-
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -static")
221+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -static ")
222+
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static ")
222223
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
223224
set(NOMYSQL ON)
224225
else()
@@ -284,10 +285,6 @@ MESSAGE(STATUS "PROJECT_VERSION_PATCH: ${PROJECT_VERSION_PATCH}")
284285

285286
option(ONLY_SIMPLE "Only build very simplistic executable -- no Boost needed" OFF)
286287

287-
if (STATICCOMPILE)
288-
set(ONLY_SIMPLE ON)
289-
endif()
290-
291288
if (NOT ONLY_SIMPLE)
292289
set (boost_components "")
293290
set(boost_components ${boost_components} program_options)
@@ -332,10 +329,6 @@ ENDIF ()
332329
# -----------------------------------------------------------------------------
333330
option(NOZLIB "Don't use zlib" OFF)
334331

335-
if (STATICCOMPILE)
336-
set(NOZLIB ON)
337-
endif()
338-
339332
if (NOT NOZLIB)
340333
find_package(ZLIB)
341334
IF (ZLIB_FOUND)

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ if (NOT ONLY_SIMPLE)
219219
set_target_properties(cryptominisat5 PROPERTIES
220220
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
221221
INSTALL_RPATH_USE_LINK_PATH TRUE)
222+
if (STATICCOMPILE)
223+
SET_TARGET_PROPERTIES(cryptominisat5 PROPERTIES LINK_SEARCH_END_STATIC 1)
224+
endif()
222225

223226
if (USE_GAUSS)
224227
set_target_properties(scalmc PROPERTIES
@@ -230,6 +233,9 @@ endif()
230233
set_target_properties(cryptominisat5_simple PROPERTIES
231234
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
232235
INSTALL_RPATH_USE_LINK_PATH TRUE)
236+
if (STATICCOMPILE)
237+
SET_TARGET_PROPERTIES(cryptominisat5_simple PROPERTIES LINK_SEARCH_END_STATIC 1)
238+
endif()
233239

234240
if (NOT ONLY_SIMPLE)
235241
target_link_libraries(cryptominisat5

0 commit comments

Comments
 (0)