CMakeLists.txt 1.8 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1
aux_source_directory(src OS_SRC)
S
monitor  
Shengliang Guan 已提交
2
add_library(os STATIC ${OS_SRC})
H
refact  
Hongze Cheng 已提交
3 4
target_include_directories(
    os
wafwerar's avatar
wafwerar 已提交
5 6 7 8
    PUBLIC "${TD_SOURCE_DIR}/include/os"
    PUBLIC "${TD_SOURCE_DIR}/include"
    PUBLIC "${TD_SOURCE_DIR}/include/util"
    PUBLIC "${TD_SOURCE_DIR}/contrib/pthread"
wafwerar's avatar
wafwerar 已提交
9 10
    PUBLIC "${TD_SOURCE_DIR}/contrib/iconv"
    PUBLIC "${TD_SOURCE_DIR}/contrib/msvcregex"
S
Shengliang Guan 已提交
11
)
wafwerar's avatar
wafwerar 已提交
12
# iconv
wafwerar's avatar
wafwerar 已提交
13 14 15 16 17
if(TD_WINDOWS)
    find_path(IconvApiIncludes iconv.h "${TD_SOURCE_DIR}/contrib/iconv")
else()
    find_path(IconvApiIncludes iconv.h PATHS)
endif(TD_WINDOWS)
wafwerar's avatar
wafwerar 已提交
18 19 20
if(NOT IconvApiIncludes)
    add_definitions(-DDISALLOW_NCHAR_WITHOUT_ICONV) 
endif ()
wafwerar's avatar
wafwerar 已提交
21 22 23
if(USE_TD_MEMORY)
    add_definitions(-DUSE_TD_MEMORY) 
endif ()
wafwerar's avatar
wafwerar 已提交
24
if(BUILD_ADDR2LINE)
wafwerar's avatar
wafwerar 已提交
25 26 27 28 29 30 31 32 33
    if(NOT TD_WINDOWS)
        target_include_directories(
            os
            PUBLIC "${TD_SOURCE_DIR}/contrib/libdwarf/src/lib/libdwarf"
        )
        target_link_libraries(
            os PUBLIC addr2line dl z
        )
    endif()
wafwerar's avatar
wafwerar 已提交
34 35
    add_definitions(-DUSE_ADDR2LINE)
endif ()
wafwerar's avatar
wafwerar 已提交
36 37 38
if(CHECK_STR2INT_ERROR)
    add_definitions(-DTD_CHECK_STR_TO_INT_ERROR)
endif()
S
Shengliang Guan 已提交
39
target_link_libraries(
40 41 42
    os
    PUBLIC pthread
    PUBLIC zlibstatic
43
)
wafwerar's avatar
wafwerar 已提交
44
if(TD_WINDOWS)
wafwerar's avatar
wafwerar 已提交
45
    target_link_libraries(
46
        os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump dbghelp
wafwerar's avatar
wafwerar 已提交
47 48
    )
elseif(TD_DARWIN_64)
49 50 51 52
    find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
    target_link_libraries(os  PUBLIC ${CORE_FOUNDATION_FRAMEWORK})
    find_library(SYSTEM_CONFIGURATION_FRAMEWORK SystemConfiguration)
    target_link_libraries(os  PUBLIC  ${SYSTEM_CONFIGURATION_FRAMEWORK})
wafwerar's avatar
wafwerar 已提交
53 54
    target_link_libraries(
        os PUBLIC dl m iconv
wafwerar's avatar
wafwerar 已提交
55 56 57
    )
else()
    target_link_libraries(
wafwerar's avatar
wafwerar 已提交
58
        os PUBLIC dl m rt
wafwerar's avatar
wafwerar 已提交
59
    )
wafwerar's avatar
wafwerar 已提交
60
endif()
wafwerar's avatar
wafwerar 已提交
61 62 63

IF (JEMALLOC_ENABLED)
    target_link_libraries(os PUBLIC -ljemalloc)
64 65 66 67
ENDIF ()

if(${BUILD_TEST})
    add_subdirectory(test)
68
endif(${BUILD_TEST})