Skip to content

Commit

Permalink
Add support for static library build
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Dec 22, 2024
1 parent 7650dee commit e321b9d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.12)
project(libime VERSION 1.1.9)
set(LibIME_VERSION ${PROJECT_VERSION})

Expand All @@ -8,6 +8,7 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${C
#########################################
# Options
#########################################
option(BUILD_SHARED_LIBS "Build library as shared libs" On)
option(ENABLE_TEST "Build Test" On)
option(ENABLE_COVERAGE "Build the project with gcov support (Need ENABLE_TEST=On)" Off)
set(GCOV_TOOL "gcov" CACHE STRING "Path to gcov tool used by coverage.")
Expand Down
4 changes: 2 additions & 2 deletions src/libime/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ foreach(f ${__KENLM_SRCS})
endif()
endforeach()

add_library(kenlm STATIC ${KENLM_SRCS})
add_library(kenlm OBJECT ${KENLM_SRCS})
target_include_directories(kenlm PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/kenlm>)
target_compile_definitions(kenlm PUBLIC -DKENLM_MAX_ORDER=3 PRIVATE -DNDEBUG)
target_link_libraries(kenlm PUBLIC Boost::boost PkgConfig::ZSTD)
Expand Down Expand Up @@ -69,7 +69,7 @@ ecm_setup_version(PROJECT
# the cmake if will
set(IMECore_SOVERSION 0)

add_library(IMECore SHARED ${LIBIME_SRCS})
add_library(IMECore ${LIBIME_SRCS})
set_target_properties(IMECore
PROPERTIES VERSION ${IMECore_VERSION}
SOVERSION ${IMECore_SOVERSION}
Expand Down
2 changes: 1 addition & 1 deletion src/libime/pinyin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ecm_setup_version(PROJECT
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LibIMEPinyinConfigVersion.cmake")
set(IMEPinyin_SOVERSION 0)

add_library(IMEPinyin SHARED ${LIBIME_PINYIN_SRCS})
add_library(IMEPinyin ${LIBIME_PINYIN_SRCS})
set_target_properties(IMEPinyin PROPERTIES
VERSION ${IMEPinyin_VERSION}
SOVERSION ${IMEPinyin_SOVERSION}
Expand Down
2 changes: 1 addition & 1 deletion src/libime/table/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ecm_setup_version(PROJECT
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LibIMETableConfigVersion.cmake")
set(IMETable_SOVERSION 0)

add_library(IMETable SHARED ${LIBIME_TABLE_SRCS})
add_library(IMETable ${LIBIME_TABLE_SRCS})
set_target_properties(IMETable
PROPERTIES VERSION ${IMETable_VERSION}
SOVERSION ${IMETable_SOVERSION}
Expand Down
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ target_link_libraries(libime_tabledict LibIME::Table)
install(TARGETS libime_tabledict DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT tools)
add_executable(LibIME::tabledict ALIAS libime_tabledict)

add_library(filesystem_helper filesystem_helper.cpp)
add_library(filesystem_helper STATIC filesystem_helper.cpp)
if (HAS_STD_FILESYSTEM)
target_compile_definitions(filesystem_helper PRIVATE -DHAS_STD_FILESYSTEM)
else()
Expand Down

0 comments on commit e321b9d

Please sign in to comment.