distromatic/src/CMakeLists.txt

110 lines
2.5 KiB
CMake

find_package(ZLIB REQUIRED)
find_package(PkgConfig)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
pkg_check_modules(RPM REQUIRED rpm)
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
pkg_check_modules(LIBUNWIND REQUIRED libunwind)
pkg_check_modules(LIBREPO REQUIRED librepo)
pkg_check_modules(LIBDW REQUIRED libdw)
pkg_check_modules(LIBXML2 REQUIRED libxml-2.0)
pkg_check_modules(LIBZCK REQUIRED zck)
find_library(LIBIBERTY NAMES iberty)
include_directories(include)
string(REPLACE "." ";" VERSION_LIST ${RPM_VERSION})
list(GET VERSION_LIST 0 RPM_VERSION_MAJOR)
list(GET VERSION_LIST 1 RPM_VERSION_MINOR)
list(GET VERSION_LIST 2 RPM_VERSION_MICRO)
add_compile_definitions(
PACKAGE="distromatic"
PACKAGE_NAME="Distromatic"
PACKAGE_VERSION="${VERSION}"
DEFAULT_CONFIGFILE="/etc/distromatic.conf"
off64_t=__off64_t
RPM_VERSION_MAJOR=${RPM_VERSION_MAJOR}
RPM_VERSION_MINOR=${RPM_VERSION_MINOR}
RPM_VERSION_MICRO=${RPM_VERSION_MICRO}
LOCALEDIR="${LOCALEDIR}"
)
add_executable(distromatic
buildtools.c
changelog.c
distromatic.c
functions.c
reports.c
headerlist.c
requirelist.c
rpmfunctions.c
backend-sqlite3.c
)
target_link_libraries(distromatic
Threads::Threads
${RPM_LIBRARIES}
${ZLIB_LIBRARIES}
${SQLITE3_LIBRARIES}
${LIBREPO_LIBRARIES}
${LIBXML2_LIBRARIES}
${LIBUNWIND_LIBRARIES}
${LIBDW_LIBRARIES}
${LIBIBERTY}
)
target_include_directories(distromatic PUBLIC
${RPM_INCLUDE_DIRS}
${LIBREPO_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
${LIBUNWIND_INCLUDE_DIRS}
)
#
# NOTE: -fno-toplevel-reorder required to prevent Sqlite3 weird problems
#
target_compile_options(distromatic PUBLIC -O2 -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
# -fno-toplevel-reorder
add_executable(distroquery
distroquery_functions.cpp
DistroqueryAPI.cpp
distroquery.cpp
functions.c
headerlist.c
requirelist.c
rpmfunctions.c
changelog.c
)
target_link_libraries(distroquery
Threads::Threads
${RPM_LIBRARIES}
${ZLIB_LIBRARIES}
${SQLITE3_LIBRARIES}
${LIBREPO_LIBRARIES}
${LIBXML2_LIBRARIES}
${LIBUNWIND_LIBRARIES}
${LIBDW_LIBRARIES}
${LIBIBERTY}
)
target_include_directories(distroquery PUBLIC
${RPM_INCLUDE_DIRS}
${LIBREPO_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
${LIBUNWIND_INCLUDE_DIRS}
)
target_compile_options(distroquery PUBLIC -O2 -g -Wall $<$<COMPILE_LANGUAGE:CXX>:-std=c++14> -pedantic ${RPM_CFLAGS_OTHER})
install(
TARGETS distromatic
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
install(
TARGETS distroquery
DESTINATION /var/www/cgi-bin/
)