forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
63 lines (46 loc) · 1.96 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
include (LibAddMacros)
find_package (PkgConfig QUIET)
pkg_check_modules (GOBJECT QUIET gobject-2.0>=2.36)
# Test if binding can be build
if (NOT GOBJECT_FOUND)
exclude_binding (glib "No gobject found using pkg-config, also remove gi bindings because they depend on it")
return ()
endif (NOT GOBJECT_FOUND)
if (ENABLE_ASAN)
exclude_binding (glib "glib is not compatible with ENABLE_ASAN")
return ()
endif (ENABLE_ASAN)
if (NOT BUILD_SHARED)
exclude_binding (glib "it can only be built if `BUILD_SHARED` is enabled")
return ()
endif (NOT BUILD_SHARED)
# Add binding
add_binding (glib)
set (
GELEKTRA_LIBRARY
gelektra-${SO_VERSION}.0
CACHE INTERNAL "GELEKTRA_LIBRARY")
file (GLOB GELEKTRA_HDR_FILES *.h)
file (GLOB GELEKTRA_SRC_FILES *.c)
add_headers (ELEKTRA_HEADERS)
set (SOURCES ${GELEKTRA_SRC_FILES} ${GELEKTRA_HDR_FILES} ${ELEKTRA_HEADERS})
add_library (${GELEKTRA_LIBRARY} SHARED ${SOURCES})
target_include_directories (${GELEKTRA_LIBRARY} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories (${GELEKTRA_LIBRARY} SYSTEM PUBLIC ${GOBJECT_INCLUDE_DIRS})
target_compile_options (${GELEKTRA_LIBRARY} PUBLIC ${GOBJECT_CFLAGS_OTHER} "-Wno-pedantic")
target_link_libraries (${GELEKTRA_LIBRARY} PUBLIC elektra-core elektra-kdb)
target_link_libraries (${GELEKTRA_LIBRARY} PUBLIC ${GOBJECT_LDFLAGS})
install (TARGETS ${GELEKTRA_LIBRARY} LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT glib-elektra)
install (
FILES ${GELEKTRA_HDR_FILES}
DESTINATION include/${TARGET_INCLUDE_FOLDER}
COMPONENT glib-elektra)
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/gelektra-constants.h.in" "${CMAKE_CURRENT_BINARY_DIR}/gelektra-constants.h" @ONLY)
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/gelektra.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${GELEKTRA_LIBRARY}.pc" @ONLY)
install (
FILES "${CMAKE_CURRENT_BINARY_DIR}/${GELEKTRA_LIBRARY}.pc"
DESTINATION lib${LIB_SUFFIX}/${TARGET_PKGCONFIG_FOLDER}
COMPONENT glib-elektra)
if (BUILD_TESTING)
add_subdirectory (tests)
endif (BUILD_TESTING)