File: CMakeLists.txt

package info (click to toggle)
plplot 5.14.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 30,424 kB
  • sloc: ansic: 79,613; xml: 28,583; cpp: 20,037; ada: 19,456; tcl: 12,081; f90: 11,423; ml: 7,276; java: 6,863; python: 6,792; sh: 3,185; perl: 828; lisp: 75; makefile: 48; sed: 33; fortran: 5
file content (48 lines) | stat: -rw-r--r-- 1,904 bytes parent folder | download | duplicates (4)
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
# Top-level CMakeLists.txt for a simple project to test Linux IPC efficiency.

# MAINTENANCE
# Use same minimum version for all platforms as the non-Linux platform minimum adopted for
# the PLplot project.
cmake_minimum_required(VERSION 3.11.0 FATAL_ERROR)

project(test_linux_ipc C)

add_executable(pshm_write pshm_write.c)
add_executable(pshm_read pshm_read.c)
add_executable(pshm_unlink pshm_unlink.c)

set_target_properties(pshm_write pshm_read pshm_unlink
  PROPERTIES
  INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
  )

# Note that both pshm_write.c and phsm_read.c contain calls to shm_open
# which on most Unix systems requires an explicit link
# with the rt library.  However, Mac OS X is a Unix system that does
# not have the rt library and provides those functions instead as part
# of the ordinary C libraries that do not require explicit linking.
# So only define RT_LIB for the Unix but not Mac case.
if(UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  find_library(RT_LIB rt)
  if(RT_LIB)
    message(STATUS "RT_LIB = ${RT_LIB}")
  else(RT_LIB)
    message(STATUS "WARNING: rt library could not be found so that pshm_write and pshm_read may not link correctly")
    set(RT_LIB)
  endif(RT_LIB)
else(UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  set(RT_LIB)
endif(UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")

# The -pthread compiler option set below is not enough, and I have
# to add this library to the ones that are linked in.
find_library(PTHREAD_LIB pthread)

target_link_libraries(pshm_write ${RT_LIB} ${PTHREAD_LIB})
target_link_libraries(pshm_read ${RT_LIB} ${PTHREAD_LIB})
target_link_libraries(pshm_unlink ${RT_LIB} ${PTHREAD_LIB})

# Web advice says -pthread has to be a compiler option as well.
target_compile_options(pshm_write PRIVATE "-pthread")
target_compile_options(pshm_read PRIVATE "-pthread")
target_compile_options(pshm_unlink PRIVATE "-pthread")