Skip to content

Commit

Permalink
Add options for using system versions of libraries (#547)
Browse files Browse the repository at this point in the history
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <[email protected]>
  • Loading branch information
Arfrever Frehtes Taifersar Arahesis authored and lotem committed Jan 10, 2021
1 parent f753bb5 commit 6cdd438
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
26 changes: 21 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ option(BUILD_SHARED_LIBS "Build opencc as shared library" ON)
option(ENABLE_GTEST "Build all tests." OFF)
option(ENABLE_BENCHMARK "Build benchmark tests." OFF)
option(ENABLE_DARTS "Build DartsDict (ocd format)." ON)
option(BUILD_BUNDLED_LIBMARISA "" ON)
option(BUILD_PYTHON "Build python library" OFF)
option(USE_SYSTEM_DARTS "Use system version of Darts" OFF)
option(USE_SYSTEM_GOOGLE_BENCHMARK "Use system version of Google Benchmark" OFF)
option(USE_SYSTEM_GTEST "Use system version of GoogleTest" OFF)
option(USE_SYSTEM_MARISA "Use system version of Marisa" OFF)
option(USE_SYSTEM_PYBIND11 "Use system version of pybind11" OFF)
option(USE_SYSTEM_RAPIDJSON "Use system version of RapidJSON" OFF)
option(USE_SYSTEM_TCLAP "Use system version of TCLAP" OFF)

######## Package information
set (PACKAGE_URL https://github.com/BYVoid/Opencc)
Expand Down Expand Up @@ -173,7 +179,7 @@ endif()

######## Dependencies

if(BUILD_BUNDLED_LIBMARISA)
if(NOT USE_SYSTEM_MARISA)
message(STATUS "Use bundled marisa library.")
add_subdirectory(deps/marisa-0.2.5)
else()
Expand All @@ -195,20 +201,30 @@ add_subdirectory(test)
######## Testing

if (ENABLE_GTEST)
add_subdirectory(deps/gtest-1.11.0)
if(NOT USE_SYSTEM_GTEST)
add_subdirectory(deps/gtest-1.11.0)
endif()
enable_testing()
endif()

if (ENABLE_BENCHMARK)
set(BENCHMARK_ENABLE_TESTING OFF)
add_subdirectory(deps/google-benchmark)
if(NOT USE_SYSTEM_GOOGLE_BENCHMARK)
add_subdirectory(deps/google-benchmark)
endif()
enable_testing()
endif()

######## Python

if (BUILD_PYTHON)
add_subdirectory(deps/pybind11-2.5.0)
if(USE_SYSTEM_PYBIND11)
include(pybind11Config)
include(pybind11Common)
include(pybind11Tools)
else()
add_subdirectory(deps/pybind11-2.5.0)
endif()
pybind11_add_module(opencc_clib src/py_opencc.cpp)
target_link_libraries(opencc_clib PRIVATE libopencc)
endif()
16 changes: 12 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
include (GenerateExportHeader)
include_directories(../deps/marisa-0.2.5/include)
include_directories(../deps/rapidjson-1.1.0)
include_directories(../deps/tclap-1.2.2)
if(NOT USE_SYSTEM_MARISA)
include_directories(../deps/marisa-0.2.5/include)
endif()
if(NOT USE_SYSTEM_RAPIDJSON)
include_directories(../deps/rapidjson-1.1.0)
endif()
if(NOT USE_SYSTEM_TCLAP)
include_directories(../deps/tclap-1.2.2)
endif()

# Library

Expand Down Expand Up @@ -72,7 +78,9 @@ set(UNITTESTS
)

if (ENABLE_DARTS)
include_directories(../deps/darts-clone)
if(NOT USE_SYSTEM_DARTS)
include_directories(../deps/darts-clone)
endif()
set(
LIBOPENCC_HEADERS
${LIBOPENCC_HEADERS}
Expand Down
5 changes: 3 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include_directories(../deps/libdarts/src)
include_directories(../src)

set(CONFIG_TEST
Expand Down Expand Up @@ -27,7 +26,9 @@ if (ENABLE_GTEST)
)
endif()

include_directories(../deps/gtest-1.7.0/include)
if(NOT USE_SYSTEM_GTEST)
include_directories(../deps/gtest-1.7.0/include)
endif()
set(UNITTESTS
CommandLineConvertTest
)
Expand Down

0 comments on commit 6cdd438

Please sign in to comment.