File: CMakeLists.txt

package info (click to toggle)
cppformat 3.0.1%2Bds-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 844 kB
  • sloc: cpp: 8,205; python: 77; sh: 12; makefile: 8; ansic: 4
file content (60 lines) | stat: -rw-r--r-- 2,105 bytes parent folder | download
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
# Define the fmt library, its includes and the needed defines.
# format.cc is added to FMT_HEADERS for the header-only configuration.
set(FMT_HEADERS format.h ostream.h time.h)
set(FMT_SOURCES format.cc ostream.cc)
if (HAVE_OPEN)
  set(FMT_HEADERS ${FMT_HEADERS} posix.h)
  set(FMT_SOURCES ${FMT_SOURCES} posix.cc)
endif ()

add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} ../ChangeLog.rst)

option(FMT_CPPFORMAT "Build cppformat library for backward compatibility." OFF)
if (FMT_CPPFORMAT)
  message(WARNING "The cppformat library is deprecated, use fmt instead.")
  add_library(cppformat ${FMT_SOURCES} ${FMT_HEADERS})
endif ()

# Starting with cmake 3.1 the CXX_STANDARD property can be used instead.
target_compile_options(fmt PUBLIC ${CPP11_FLAG})
if (FMT_PEDANTIC)
  target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS})
endif ()

target_include_directories(fmt PUBLIC
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
  $<INSTALL_INTERFACE:include>)

set_target_properties(fmt PROPERTIES
  VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})

if (BUILD_SHARED_LIBS)
  if (UNIX AND NOT APPLE)
    # Fix rpmlint warning:
    # unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
    target_link_libraries(fmt -Wl,--as-needed)
  endif ()
  target_compile_definitions(fmt PRIVATE FMT_EXPORT INTERFACE FMT_SHARED)
endif ()

#------------------------------------------------------------------------------
# additionally define a header only library when cmake is new enough
if (CMAKE_VERSION VERSION_GREATER 3.1.0 OR CMAKE_VERSION VERSION_EQUAL 3.1.0)
  add_library(fmt-header-only INTERFACE)

  target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)

  target_include_directories(fmt-header-only INTERFACE
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
    $<INSTALL_INTERFACE:include>)
endif ()

# Install targets.
if (FMT_INSTALL)
  # Install the library and headers.
  install(TARGETS fmt DESTINATION lib)
  install(FILES ${FMT_HEADERS} DESTINATION include/fmt)
  if (FMT_CPPFORMAT)
    install(TARGETS cppformat DESTINATION lib)
  endif ()
endif ()