Skip to content

Commit

Permalink
Hacky? option to build static executables
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Feb 28, 2016
1 parent e376c33 commit d7d1220
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
cmake_minimum_required(VERSION 2.6)
# This CMake file was created by Lane Schwartz <[email protected]>


# Define a single cmake project
project(kenlm)

option(FORCE_STATIC "Build static executables" OFF)
if (FORCE_STATIC)
#presumably overkill, is there a better way?
#http://cmake.3232098.n2.nabble.com/Howto-compile-static-executable-td5580269.html
set(Boost_USE_STATIC_LIBS ON)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set_property(GLOBAL PROPERTY LINK_SEARCH_START_STATIC ON)
set_property(GLOBAL PROPERTY LINK_SEARCH_END_STATIC ON)
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
#Annoyingly the exectuables say "File not found" unless these are set
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
endif ()

# Compile all executables into bin/
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

Expand Down Expand Up @@ -32,8 +50,6 @@ find_package(Boost 1.36.0 REQUIRED COMPONENTS
)




# Define where include files live
include_directories(
${PROJECT_SOURCE_DIR}
Expand Down

0 comments on commit d7d1220

Please sign in to comment.