CMakeLists.txt 2.43 KB
Newer Older
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
1 2 3 4 5 6
# Main library aec
add_library(aec
  encode.c
  encode_accessors.c
  decode.c)
add_library(libaec::aec ALIAS aec)
7

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
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
target_include_directories(aec
  PUBLIC
  "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>"
  "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>"
  "$<INSTALL_INTERFACE:include>")

set_target_properties(aec
  PROPERTIES
  VERSION 0.0.10
  SOVERSION 0
  PUBLIC_HEADER ../include/libaec.h)

# Wrapper for compatibility with szip
add_library(sz sz_compat.c)
add_library(libaec::sz ALIAS sz)

set_target_properties(sz
  PROPERTIES
  VERSION 2.0.1
  SOVERSION 2
  OUTPUT_NAME $<IF:$<BOOL:${WIN32}>,szip,sz>
  PUBLIC_HEADER ../include/szlib.h)
target_link_libraries(sz PUBLIC aec)

# Simple client for testing and benchmarking.
# Can also be used stand-alone
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
34
add_executable(aec_client aec.c)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
35 36
set_target_properties(aec_client PROPERTIES OUTPUT_NAME aec)
target_link_libraries(aec_client PUBLIC aec)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
37

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
38
include(GNUInstallDirs)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
39
if(UNIX)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
40 41 42 43 44 45 46 47 48
  # Handle visibility of symbols. Compatible with gnulib's gl_VISIBILITY
  include(CheckCCompilerFlag)
  check_c_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
  set_target_properties(aec sz
    PROPERTIES
    COMPILE_DEFINITIONS
    "HAVE_VISIBILITY=$<BOOL:${COMPILER_HAS_HIDDEN_VISIBILITY}>;BUILDING_LIBAEC")

  # The shell scripts for benchmarking are supported on unix only
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
49
  add_executable(utime EXCLUDE_FROM_ALL utime.c)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
50
  target_include_directories(utime PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/..")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
51
  add_custom_target(bench
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
52 53 54
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/benc.sh
    ${CMAKE_CURRENT_SOURCE_DIR}/../data/typical.rz
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bdec.sh
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
55
    DEPENDS aec_client utime)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
56

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  # Install manpage
  install(
    FILES aec.1
    DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man1
    COMPONENT doc)
endif()

install(TARGETS aec sz aec_client
  EXPORT LibaecTargets)

install(EXPORT LibaecTargets
  FILE LibaecTargets.cmake
  NAMESPACE libaec::
  DESTINATION lib/cmake)

include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/../Config.cmake.in
  "${CMAKE_CURRENT_BINARY_DIR}/LibaecConfig.cmake"
  INSTALL_DESTINATION lib/cmake)

# generate the version file for the config file
write_basic_package_version_file(
  "${CMAKE_CURRENT_BINARY_DIR}/LibaecConfigVersion.cmake"
  COMPATIBILITY AnyNewerVersion)

install(FILES
  "${CMAKE_CURRENT_BINARY_DIR}/LibaecConfig.cmake"
  "${CMAKE_CURRENT_BINARY_DIR}/LibaecConfigVersion.cmake"
  DESTINATION lib/cmake)