liberty/CMakeLists.txt

55 lines
1.6 KiB
CMake
Raw Normal View History

2015-02-28 19:53:23 +01:00
project (liberty C)
cmake_minimum_required (VERSION 2.8.12)
2015-02-28 19:53:23 +01:00
# Moar warnings
2017-07-24 03:46:06 +02:00
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
2015-02-28 19:53:23 +01:00
# -Wunused-function is pretty annoying here, as everything is static
set (wdisabled "-Wno-unused-function")
2017-06-22 18:14:49 +02:00
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra ${wdisabled}")
endif ()
2015-02-28 19:53:23 +01:00
# Dependencies
2016-01-04 00:47:12 +01:00
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include (AddThreads)
2015-02-28 19:53:23 +01:00
find_package (PkgConfig REQUIRED)
pkg_check_modules (libssl REQUIRED libssl libcrypto)
2016-01-04 00:47:12 +01:00
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# Our POSIX version macros make these undefined
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
endif ()
2016-01-01 19:15:18 +01:00
2016-01-04 00:47:12 +01:00
set (common_libraries ${libssl_LIBRARIES})
2015-02-28 19:53:23 +01:00
include_directories (${libssl_INCLUDE_DIRS})
link_directories (${libssl_LIBRARY_DIRS})
2016-01-04 00:47:12 +01:00
# -lrt is only for glibc < 2.17
# -liconv may or may not be a part of libc
foreach (extra iconv rt)
find_library (extra_lib_${extra} ${extra})
if (extra_lib_${extra})
list (APPEND common_libraries ${extra})
endif ()
endforeach ()
2016-01-04 00:47:12 +01:00
2015-02-28 19:53:23 +01:00
# Build some unit tests
2017-06-14 23:28:30 +02:00
include_directories (${PROJECT_SOURCE_DIR})
2015-02-28 19:53:23 +01:00
enable_testing ()
set (tests liberty proto)
pkg_check_modules (libpulse libpulse)
if (libpulse_FOUND)
list (APPEND tests pulse)
list (APPEND common_libraries ${libpulse_LIBRARIES})
include_directories (${libpulse_INCLUDE_DIRS})
link_directories (${libpulse_LIBRARY_DIRS})
endif ()
foreach (name ${tests})
2015-02-28 19:53:23 +01:00
add_executable (test-${name} tests/${name}.c ${common_sources})
2016-01-01 19:15:18 +01:00
add_threads (test-${name})
2015-02-28 19:53:23 +01:00
target_link_libraries (test-${name} ${common_libraries})
2015-12-09 00:57:00 +01:00
add_test (NAME test-${name} COMMAND test-${name})
endforeach ()