From 49cd5a2694ee70fcaac95fec8d4ad592047f9c07 Mon Sep 17 00:00:00 2001 From: Choe Hwanjin Date: Tue, 12 Oct 2021 16:15:14 +0900 Subject: cmake: Add BUILD_SHARED_LIBS option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 사용자가 Shared와 Static 빌드를 선택할 수 있게 BUILD_SHARED_LIBS 옵션을 추가한다. ENABLE_EXTERNAL_KEYBOARDS 옵션이 ON 일때에만 expat을 찾아도 되므로 조건 처리한다. 추가로 find_package()를 사용한다. 패키지를 찾을 때에는 include()보다 나을 것 같다. --- CMakeLists.txt | 7 ++++++- data/keyboards/CMakeLists.txt | 2 +- hangul/CMakeLists.txt | 13 +++++-------- po/CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b31d0e4..2307e55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,13 @@ set(LIBHANGUL_SOVERSION_MAJOR 1) set(LIBHANGUL_SOVERSION_MINOR 0) set(LIBHANGUL_SOVERSION_PATCH 1) +option(BUILD_SHARED_LIBS + "Enable/Disable shared library build." + ON +) + option(ENABLE_EXTERNAL_KEYBOARDS - "enable external keyboard xml file loading feature" + "Enable/Disable external keyboard xml file loading feature." ON ) diff --git a/data/keyboards/CMakeLists.txt b/data/keyboards/CMakeLists.txt index 6c94c18..fea4951 100644 --- a/data/keyboards/CMakeLists.txt +++ b/data/keyboards/CMakeLists.txt @@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.0) #include(GNUInstallDirs) -include(FindGettext) +find_package(Gettext) set(keyboard_file_list hangul-keyboard-2.xml diff --git a/hangul/CMakeLists.txt b/hangul/CMakeLists.txt index aa6e27e..93f7fb4 100644 --- a/hangul/CMakeLists.txt +++ b/hangul/CMakeLists.txt @@ -17,14 +17,11 @@ cmake_minimum_required(VERSION 3.0) -include(FindPkgConfig) -include(FindEXPAT) include(GNUInstallDirs) -option(ENABLE_EXTERNAL_KEYBOARDS - "enable external keyboard xml file loading feature" - ON -) +if(ENABLE_EXTERNAL_KEYBOARDS) + find_package(EXPAT) +endif() set(hangul_PUBLIC_HEADERS hangul.h @@ -37,7 +34,7 @@ set(hangul_PRIVATE_HEADERS hanjacompatible.h ) -add_library(hangul SHARED +add_library(hangul ${hangul_PUBLIC_HEADERS} ${hangul_PRIVATE_HEADERS} hangulctype.c @@ -53,7 +50,7 @@ target_compile_definitions(hangul PRIVATE -DTOP_SRCDIR=\"${CMAKE_SOURCE_DIR}\" ) -if (ENABLE_EXTERNAL_KEYBOARDS) +if(ENABLE_EXTERNAL_KEYBOARDS) target_compile_definitions(hangul PRIVATE -DENABLE_EXTERNAL_KEYBOARDS=1 ) diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 82e26d4..ffa968b 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.0) -include(FindGettext) +find_package(Gettext) include(GNUInstallDirs) file(READ LINGUAS LINGUAS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 433baf9..52415bf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.0) -include(FindPkgConfig) +find_package(PkgConfig) add_executable(test-hangul hangul.c -- cgit v1.2.1