sj4/CMakeLists.txt

68 lines
2 KiB
Text
Raw Normal View History

2026-06-19 01:31:17 +09:00
cmake_minimum_required(VERSION 3.11)
2026-06-20 02:12:04 +09:00
project(sj4)
2026-06-19 01:31:17 +09:00
2026-06-20 02:23:55 +09:00
option(SJ4_GLOBAL "Use global variables or not" OFF)
2026-06-21 17:52:12 +09:00
option(SJ4_EMBED "Embed main dictionary or not" OFF)
option(SJ4_EMBED_PLUS "Embed pubdic+ as main dictionary or not" OFF)
2026-06-22 00:00:34 +09:00
option(SJ4_NO_UNICODE "Remove Unicode code completely" OFF)
2026-06-22 07:48:17 +09:00
option(SJ4_BUILD_ONLY_LIB "Always build only library" OFF)
option(SJ4_BUILD_TOOLS "Always build tools" OFF)
2026-06-20 02:23:55 +09:00
2026-06-25 13:18:44 +09:00
macro(sj4_library name)
file(GLOB_RECURSE ${name}_SRCS lib/${name}/**.c)
add_library(${name} STATIC ${${name}_SRCS})
target_include_directories(${name} PUBLIC include/${name})
if(NOT "${name}" STREQUAL "sj4common")
target_link_libraries(${name} PUBLIC sj4common)
endif()
endmacro()
sj4_library(sj4common)
2026-06-25 09:25:46 +09:00
2026-06-25 13:18:44 +09:00
sj4_library(sj4charset)
2026-06-25 09:25:46 +09:00
if(NOT SJ4_NO_UNICODE)
target_compile_definitions(sj4charset PRIVATE UCS)
endif()
2026-06-20 21:32:18 +09:00
2026-06-25 13:18:44 +09:00
sj4_library(sj4core)
2026-06-21 16:55:56 +09:00
if(SJ4_GLOBAL)
target_compile_definitions(sj4core PUBLIC SJ4_GLOBAL)
endif()
2026-06-21 17:52:12 +09:00
if(SJ4_EMBED_PLUS)
target_compile_definitions(sj4core PUBLIC EMBED_PLUS)
elseif(SJ4_EMBED)
target_compile_definitions(sj4core PUBLIC EMBED)
endif()
2026-06-19 01:47:46 +09:00
2026-06-25 13:18:44 +09:00
sj4_library(sj4rkcv)
2026-06-19 19:07:01 +09:00
2026-06-21 20:32:04 +09:00
if(NOT SJ4_GLOBAL)
2026-06-25 13:18:44 +09:00
sj4_library(sj4lib)
target_link_libraries(sj4lib PUBLIC sj4core sj4charset)
2026-06-22 00:00:34 +09:00
if(NOT SJ4_NO_UNICODE)
target_compile_definitions(sj4lib PRIVATE UCS)
endif()
2026-06-21 20:32:04 +09:00
endif()
2026-06-25 20:18:21 +09:00
if(NOT SJ4_GLOBAL)
sj4_library(sj4ime)
target_link_libraries(sj4ime PUBLIC sj4lib)
endif()
2026-06-22 07:48:17 +09:00
if(SJ4_BUILD_TOOLS OR (NOT CMAKE_BINARY_DIR MATCHES CMAKE_CURRENT_SOURCE_DIR AND NOT SJ4_BUILD_ONLY_LIB))
2026-06-22 07:34:58 +09:00
file(GLOB_RECURSE SJ4MKDIC_SRCS src/sj4mkdic/**.c)
add_executable(sj4mkdic ${SJ4MKDIC_SRCS})
2026-06-25 13:18:44 +09:00
target_include_directories(sj4mkdic PRIVATE include/sj4core)
2026-06-22 07:34:58 +09:00
target_compile_definitions(sj4mkdic PRIVATE ENGLISH)
2026-06-25 09:25:46 +09:00
target_link_libraries(sj4mkdic PRIVATE sj4common sj4charset)
2026-06-22 07:34:58 +09:00
if(NOT SJ4_NO_UNICODE)
target_compile_definitions(sj4mkdic PRIVATE UTF8)
endif()
2026-06-19 06:25:17 +09:00
2026-06-22 07:34:58 +09:00
if(NOT SJ4_GLOBAL)
file(GLOB_RECURSE SJ4TEST_SRCS src/sj4test/**.c)
add_executable(sj4test ${SJ4TEST_SRCS})
target_link_libraries(sj4test PRIVATE sj4lib)
endif()
2026-06-20 02:23:55 +09:00
endif()