summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorVo Trung Chi <chi.votrung@vn.bosch.com>2019-07-03 09:41:38 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2019-07-03 11:41:38 +0900
commitb757183f51920e8445ed0ea0bbdb490d99781ec6 (patch)
treeab984058504593f58a842f79b945dd6c6f12751f /src/lib
parentc232148a950c536b99bf91033a78ada6ee6f1771 (diff)
downloadDLT-daemon-b757183f51920e8445ed0ea0bbdb490d99781ec6.tar.gz
cmake-improvements (#135)
1. Allow building as a subproject of another cmake project (CMAKE_* vs PROJECT_* variables) 2. Do not generate header files within source – bad practice, use build directory for that(e.g. change location where dlt_version.h is being generated) 3. Use add_compile_options() instead of *_C/CXX_FLAGS variables for proper compile environment definition, also bad practice, also see p.2 4. Add WITH_DLT_PKGCONFIG – add generate pkgconfig .pc files as switchable option, should probably be part of headers install routine. Signed-off-by: Radoslaw Kaczorowski <external.radoslaw.kaczorowski@bosch-softtec.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/CMakeLists.txt32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 537e2ca..db3a38e 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -15,11 +15,19 @@
# @licence end@
#######
-set(dlt_LIB_SRCS dlt_user dlt_client dlt_filetransfer dlt_env_ll ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_protocol.c)
+set(dlt_LIB_SRCS
+ dlt_user.c
+ dlt_client.c
+ dlt_filetransfer.c
+ dlt_env_ll.c
+ ${PROJECT_SOURCE_DIR}/src/shared/dlt_common.c
+ ${PROJECT_SOURCE_DIR}/src/shared/dlt_protocol.c
+ ${PROJECT_SOURCE_DIR}/src/shared/dlt_user_shared.c
+ )
if(WITH_DLT_SHM_ENABLE)
- set(dlt_LIB_SRCS ${dlt_LIB_SRCS} ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c)
-endif(WITH_DLT_SHM_ENABLE)
+ set(dlt_LIB_SRCS ${dlt_LIB_SRCS} ${PROJECT_SOURCE_DIR}/src/shared/dlt_shm.c)
+endif()
add_library(dlt ${dlt_LIB_SRCS})
@@ -31,14 +39,18 @@ else()
set(SOCKET_LIBRARY socket)
endif()
-target_link_libraries(dlt ${RT_LIBRARY} ${SOCKET_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
+if(HAVE_FUNC_PTHREAD_SETNAME_NP)
+ add_definitions(-DDLT_USE_PTHREAD_SETNAME_NP)
+ message(STATUS "Using pthread_setname_np API to set thread name")
+else()
+ message(STATUS "pthread_setname_np API not available on this platform")
+endif()
+target_link_libraries(dlt ${RT_LIBRARY} ${SOCKET_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
set_target_properties(dlt PROPERTIES VERSION ${DLT_VERSION} SOVERSION ${DLT_MAJOR_VERSION})
install(TARGETS dlt
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
- COMPONENT base)
-
-
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
+ COMPONENT base)