<commit_before>cmake_minimum_required(VERSION 2.6)

project("openscap")
set(OPENSCAP_VERSION_MAJOR "1")
set(OPENSCAP_VERSION_MINOR "3")
set(OPENSCAP_VERSION_PATCH "0")
set(OPENSCAP_VERSION "${OPENSCAP_VERSION_MAJOR}.${OPENSCAP_VERSION_MINOR}.${OPENSCAP_VERSION_PATCH}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
    set(NDEBUG 1)
endif()

# ---------- DEPENDENCIES

include(GNUInstallDirs)
include(FindPkgConfig)
include(CheckLibraryExists)

# ACL
#pkg_check_modules(ACL REQUIRED acl)
CHECK_LIBRARY_EXISTS(acl acl_init "" HAVE_ACL_INIT)
CHECK_LIBRARY_EXISTS(acl acl_extended_file "" HAVE_ACL_EXTENDED_FILE)

# APTPKG
pkg_check_modules(APTPKG libapt-pkg)
if(APTPKG_FOUND)
    CHECK_LIBRARY_EXISTS(${APTPKG_LIBRARIES} pkgVersion ${APTPKG_LIBRARY_DIRS} HAVE_PKGVERSION)
endif()

# BLKID
pkg_check_modules(BLKID REQUIRED blkid)
if(BLKID_FOUND)
    CHECK_LIBRARY_EXISTS(blkid blkid_get_cache "" HAVE_BLKID_GET_CACHE)
    CHECK_LIBRARY_EXISTS(blkid blkid_get_tag_value "" HAVE_BLKID_GET_TAG_VALUE)
endif()

# CAP
pkg_check_modules(CAP REQUIRED libcap)
CHECK_LIBRARY_EXISTS(cap cap_init "" HAVE_CAP_INIT)
CHECK_LIBRARY_EXISTS(cap cap_get_pid "" HAVE_CAP_GET_PID)
CHECK_LIBRARY_EXISTS(cap capgetp "" HAVE_CAPGETP)

# CURL
pkg_check_modules(CURL REQUIRED libcurl>=7.12.0)

# DBUS
pkg_check_modules(DBUS REQUIRED dbus-1)
if(DBUS_FOUND)
    CHECK_LIBRARY_EXISTS(${DBUS_LIBRARIES} dbus_bus_get "" HAVE_DBUS_BUS_GET)
endif()

# EXSLT
pkg_check_modules(EXSLT REQUIRED libexslt>=0.8)

# GCONF2
pkg_check_modules(GCONF2 REQUIRED gconf-2.0)
if(GCONF2_FOUND)
    CHECK_LIBRARY_EXISTS(gconf-2 gconf_engine_get_default "" HAVE_GCONF_ENGINE_GET_DEFAULT)
endif()

# LDAP
find_package(Ldap REQUIRED)
CHECK_LIBRARY_EXISTS(ldap ldap_init "" HAVE_LDAP_INIT)
CHECK_LIBRARY_EXISTS(lber ber_init "" HAVE_BER_INIT)

# OpenDbx
pkg_check_modules(OPENDBX REQUIRED opendbx)
CHECK_LIBRARY_EXISTS(opendbx odbx_init "" HAVE_ODBX_INIT)

# PCRE
pkg_check_modules(PCRE REQUIRED libpcre)
if(PCRE_FOUND)
    CHECK_LIBRARY_EXISTS(pcre pcre_exec "" HAVE_PCRE_EXEC)
endif()

# POPT
pkg_check_modules(POPT REQUIRED popt)

# PROCPS
pkg_check_modules(PROCPS libprocps)
if(PROCPS_FOUND)
    CHECK_LIBRARY_EXISTS(procps dev_to_tty "" HAVE_DEV_TO_TTY)
endif()

# RPM
pkg_check_modules(RPM rpm>=4.4)
pkg_check_modules(RPM46 rpm>=4.6)
pkg_check_modules(RPM47 rpm>=4.7)
if(RPM_FOUND)
    CHECK_LIBRARY_EXISTS(rpm rpmtsCreate "" HAVE_RPMTSCREATE)
    CHECK_LIBRARY_EXISTS(rpm rpmReadConfigFiles "" HAVE_RPMREADCONFIGFILES)
    CHECK_LIBRARY_EXISTS(rpm headerFormat "" HAVE_HEADERFORMAT)
    CHECK_LIBRARY_EXISTS(rpm headerSprintf "" HAVE_HEADERSPRINTF)
    CHECK_LIBRARY_EXISTS(rpmio rpmFreeCrypto "" HAVE_RPMFREECRYPTO)
    CHECK_LIBRARY_EXISTS(rpm rpmFreeFilesystems "" HAVE_RPMFREEFILESYSTEMS)

    set(HAVE_RPMVERCMP 1)
endif()
if (RPM46_FOUND)
    set(HAVE_RPM46 1)
endif()
if (RPM47_FOUND)
    set(HAVE_RPM47 1)
endif()

# SELINUX
pkg_check_modules(SELINUX REQUIRED libselinux)

# XML2
pkg_check_modules(XML2 REQUIRED libxml-2.0>=2.0)
if (XML2_FOUND)
    CHECK_LIBRARY_EXISTS(xml2 xmlTextReaderRead "" HAVE_XMLTEXTREADERREAD)
endif()

# XSTL
pkg_check_modules(XSLT REQUIRED libxslt>=1.1)
if (XSLT_FOUND)
    CHECK_LIBRARY_EXISTS(xslt xsltDocumentFunction "" HAVE_XSLTDOCUMENTFUNCTION)
endif()

# BZip2
find_package(BZip2)

# PThread
find_package(Threads)
set(CMAKE_THREAD_PREFER_PTHREAD)

# WITH_CRYPTO
set(WITH_CRYPTO "gcrypt" CACHE STRING "gcrypt|nss3")
if(NOT (${WITH_CRYPTO} EQUAL "nss3"))
    # gcrypt
    find_package(GCrypt REQUIRED)
    include(CheckCSourceCompiles)<commit_msg>Prefer -pthread compiler and linker flag<commit_after>cmake_minimum_required(VERSION 2.6)

project("openscap")
set(OPENSCAP_VERSION_MAJOR "1")
set(OPENSCAP_VERSION_MINOR "3")
set(OPENSCAP_VERSION_PATCH "0")
set(OPENSCAP_VERSION "${OPENSCAP_VERSION_MAJOR}.${OPENSCAP_VERSION_MINOR}.${OPENSCAP_VERSION_PATCH}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
    set(NDEBUG 1)
endif()

# ---------- DEPENDENCIES

include(GNUInstallDirs)
include(FindPkgConfig)
include(CheckLibraryExists)

# ACL
#pkg_check_modules(ACL REQUIRED acl)
CHECK_LIBRARY_EXISTS(acl acl_init "" HAVE_ACL_INIT)
CHECK_LIBRARY_EXISTS(acl acl_extended_file "" HAVE_ACL_EXTENDED_FILE)

# APTPKG
pkg_check_modules(APTPKG libapt-pkg)
if(APTPKG_FOUND)
    CHECK_LIBRARY_EXISTS(${APTPKG_LIBRARIES} pkgVersion ${APTPKG_LIBRARY_DIRS} HAVE_PKGVERSION)
endif()

# BLKID
pkg_check_modules(BLKID REQUIRED blkid)
if(BLKID_FOUND)
    CHECK_LIBRARY_EXISTS(blkid blkid_get_cache "" HAVE_BLKID_GET_CACHE)
    CHECK_LIBRARY_EXISTS(blkid blkid_get_tag_value "" HAVE_BLKID_GET_TAG_VALUE)
endif()

# CAP
pkg_check_modules(CAP REQUIRED libcap)
CHECK_LIBRARY_EXISTS(cap cap_init "" HAVE_CAP_INIT)
CHECK_LIBRARY_EXISTS(cap cap_get_pid "" HAVE_CAP_GET_PID)
CHECK_LIBRARY_EXISTS(cap capgetp "" HAVE_CAPGETP)

# CURL
pkg_check_modules(CURL REQUIRED libcurl>=7.12.0)

# DBUS
pkg_check_modules(DBUS REQUIRED dbus-1)
if(DBUS_FOUND)
    CHECK_LIBRARY_EXISTS(${DBUS_LIBRARIES} dbus_bus_get "" HAVE_DBUS_BUS_GET)
endif()

# EXSLT
pkg_check_modules(EXSLT REQUIRED libexslt>=0.8)

# GCONF2
pkg_check_modules(GCONF2 REQUIRED gconf-2.0)
if(GCONF2_FOUND)
    CHECK_LIBRARY_EXISTS(gconf-2 gconf_engine_get_default "" HAVE_GCONF_ENGINE_GET_DEFAULT)
endif()

# LDAP
find_package(Ldap REQUIRED)
CHECK_LIBRARY_EXISTS(ldap ldap_init "" HAVE_LDAP_INIT)
CHECK_LIBRARY_EXISTS(lber ber_init "" HAVE_BER_INIT)

# OpenDbx
pkg_check_modules(OPENDBX REQUIRED opendbx)
CHECK_LIBRARY_EXISTS(opendbx odbx_init "" HAVE_ODBX_INIT)

# PCRE
pkg_check_modules(PCRE REQUIRED libpcre)
if(PCRE_FOUND)
    CHECK_LIBRARY_EXISTS(pcre pcre_exec "" HAVE_PCRE_EXEC)
endif()

# POPT
pkg_check_modules(POPT REQUIRED popt)

# PROCPS
pkg_check_modules(PROCPS libprocps)
if(PROCPS_FOUND)
    CHECK_LIBRARY_EXISTS(procps dev_to_tty "" HAVE_DEV_TO_TTY)
endif()

# RPM
pkg_check_modules(RPM rpm>=4.4)
pkg_check_modules(RPM46 rpm>=4.6)
pkg_check_modules(RPM47 rpm>=4.7)
if(RPM_FOUND)
    CHECK_LIBRARY_EXISTS(rpm rpmtsCreate "" HAVE_RPMTSCREATE)
    CHECK_LIBRARY_EXISTS(rpm rpmReadConfigFiles "" HAVE_RPMREADCONFIGFILES)
    CHECK_LIBRARY_EXISTS(rpm headerFormat "" HAVE_HEADERFORMAT)
    CHECK_LIBRARY_EXISTS(rpm headerSprintf "" HAVE_HEADERSPRINTF)
    CHECK_LIBRARY_EXISTS(rpmio rpmFreeCrypto "" HAVE_RPMFREECRYPTO)
    CHECK_LIBRARY_EXISTS(rpm rpmFreeFilesystems "" HAVE_RPMFREEFILESYSTEMS)

    set(HAVE_RPMVERCMP 1)
endif()
if (RPM46_FOUND)
    set(HAVE_RPM46 1)
endif()
if (RPM47_FOUND)
    set(HAVE_RPM47 1)
endif()

# SELINUX
pkg_check_modules(SELINUX REQUIRED libselinux)

# XML2
pkg_check_modules(XML2 REQUIRED libxml-2.0>=2.0)
if (XML2_FOUND)
    CHECK_LIBRARY_EXISTS(xml2 xmlTextReaderRead "" HAVE_XMLTEXTREADERREAD)
endif()

# XSTL
pkg_check_modules(XSLT REQUIRED libxslt>=1.1)
if (XSLT_FOUND)
    CHECK_LIBRARY_EXISTS(xslt xsltDocumentFunction "" HAVE_XSLTDOCUMENTFUNCTION)
endif()

# BZip2
find_package(BZip2)

# PThread
find_package(Threads)
set(CMAKE_THREAD_PREFER_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG)

# WITH_CRYPTO
set(WITH_CRYPTO "gcrypt" CACHE STRING "gcrypt|nss3")
if(NOT (${WITH_CRYPTO} EQUAL "nss3"))
    # gcrypt
    find_package(GCrypt REQUIRED)
    include(CheckCSourceCompiles)
{'fraction_non_alphanumeric': 0.0926729986431479, 'fraction_numerical': 0.014654002713704206, 'mean_word_length': 8.033088235294118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4174638', 'n_tokens_mistral': 3324, 'n_tokens_neox': 3045, 'n_words': 439}