Refactor CMake
This commit is contained in:
parent
eb45d08191
commit
7993ba946c
1 changed files with 16 additions and 21 deletions
|
|
@ -9,23 +9,23 @@ option(SJ4_NO_UNICODE "Remove Unicode code completely" OFF)
|
|||
option(SJ4_BUILD_ONLY_LIB "Always build only library" OFF)
|
||||
option(SJ4_BUILD_TOOLS "Always build tools" OFF)
|
||||
|
||||
file(GLOB_RECURSE SJ4COMMON_SRCS lib/sj4common/**.c)
|
||||
add_library(sj4common STATIC ${SJ4COMMON_SRCS})
|
||||
target_include_directories(sj4common PUBLIC include/sj4common)
|
||||
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()
|
||||
|
||||
file(GLOB_RECURSE SJ4CHARSET_SRCS lib/sj4charset/**.c)
|
||||
add_library(sj4charset STATIC ${SJ4CHARSET_SRCS})
|
||||
target_include_directories(sj4charset PUBLIC include/sj4common include/sj4charset)
|
||||
target_link_libraries(sj4charset PUBLIC sj4common)
|
||||
sj4_library(sj4common)
|
||||
|
||||
sj4_library(sj4charset)
|
||||
if(NOT SJ4_NO_UNICODE)
|
||||
target_compile_definitions(sj4charset PRIVATE UCS)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE SJ4CORE_SRCS lib/sj4core/**.c)
|
||||
add_library(sj4core STATIC ${SJ4CORE_SRCS})
|
||||
target_include_directories(sj4core PUBLIC include/sj4common include/sj4core)
|
||||
target_include_directories(sj4core PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(sj4core PUBLIC sj4common)
|
||||
sj4_library(sj4core)
|
||||
if(SJ4_GLOBAL)
|
||||
target_compile_definitions(sj4core PUBLIC SJ4_GLOBAL)
|
||||
endif()
|
||||
|
|
@ -35,16 +35,11 @@ elseif(SJ4_EMBED)
|
|||
target_compile_definitions(sj4core PUBLIC EMBED)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE SJ4RKCV_SRCS lib/sj4rkcv/**.c)
|
||||
add_library(sj4rkcv STATIC ${SJ4RKCV_SRCS})
|
||||
target_include_directories(sj4rkcv PUBLIC include/sj4common include/sj4rkcv)
|
||||
target_link_libraries(sj4rkcv PUBLIC sj4common)
|
||||
sj4_library(sj4rkcv)
|
||||
|
||||
if(NOT SJ4_GLOBAL)
|
||||
file(GLOB_RECURSE SJ4LIB_SRCS lib/sj4lib/**.c)
|
||||
add_library(sj4lib STATIC ${SJ4LIB_SRCS})
|
||||
target_include_directories(sj4lib PUBLIC include/sj4common include/sj4core include/sj4lib)
|
||||
target_link_libraries(sj4lib PUBLIC sj4charset sj4core)
|
||||
sj4_library(sj4lib)
|
||||
target_link_libraries(sj4lib PUBLIC sj4core sj4charset)
|
||||
if(NOT SJ4_NO_UNICODE)
|
||||
target_compile_definitions(sj4lib PRIVATE UCS)
|
||||
endif()
|
||||
|
|
@ -53,7 +48,7 @@ endif()
|
|||
if(SJ4_BUILD_TOOLS OR (NOT CMAKE_BINARY_DIR MATCHES CMAKE_CURRENT_SOURCE_DIR AND NOT SJ4_BUILD_ONLY_LIB))
|
||||
file(GLOB_RECURSE SJ4MKDIC_SRCS src/sj4mkdic/**.c)
|
||||
add_executable(sj4mkdic ${SJ4MKDIC_SRCS})
|
||||
target_include_directories(sj4mkdic PRIVATE include/sj4common include/sj4core)
|
||||
target_include_directories(sj4mkdic PRIVATE include/sj4core)
|
||||
target_compile_definitions(sj4mkdic PRIVATE ENGLISH)
|
||||
target_link_libraries(sj4mkdic PRIVATE sj4common sj4charset)
|
||||
if(NOT SJ4_NO_UNICODE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue