File: FindOpenSCAP.cmake

package info (click to toggle)
scap-security-guide 0.1.39-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 31,836 kB
  • sloc: xml: 129,736; python: 7,462; sh: 3,796; makefile: 27
file content (48 lines) | stat: -rw-r--r-- 1,343 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
set(OPENSCAP_POSSIBLE_ROOT_DIRS
    "${OPENSCAP_ROOT_DIR}"
    "$ENV{OPENSCAP_ROOT_DIR}"
    "$ENV{ProgramFiles}"
    "/usr"
    "/usr/bin"
    "/usr/sbin"
    "/usr/local"
    "/usr/share/"
    "/usr/local/share"
    "/opt"
    "/opt/local"
)

foreach(NAME ${OPENSCAP_POSSIBLE_ROOT_DIRS})
	FIND_FILE(OPENSCAP_XCCDF_XSL_1_2 NAMES xccdf_1.1_to_1.2.xsl
        PATHS "${NAME}"
        PATH_SUFFIXES "share/openscap/xsl/"
    )
endforeach()

foreach(NAME ${OPENSCAP_POSSIBLE_ROOT_DIRS})
    FIND_PROGRAM(OPENSCAP_OSCAP_EXECUTABLE NAMES oscap
        PATHS "${NAME}"
        PATH_SUFFIXES "bin/"
    )
endforeach()

if (NOT EXISTS "${OPENSCAP_XCCDF_XSL_1_2}")
    MESSAGE(SEND_ERROR
            "ERROR: The OPENSCAP XSL XCCDF file was not found. Please specify the OPENSCAP ROOT DIR with the OPENSCAP_ROOT_DIR environment variable.")
endif()

if (NOT EXISTS "${OPENSCAP_OSCAP_EXECUTABLE}")
    MESSAGE(SEND_ERROR
            "ERROR: The OPENSCAP executable was not found. Please specify the OPENSCAP ROOT DIR with the OPENSCAP_ROOT_DIR environment variable.")
endif()

execute_process(
    COMMAND "${OPENSCAP_OSCAP_EXECUTABLE}" --v
    OUTPUT_VARIABLE OSCAP_V_OUTPUT
)

if("${OSCAP_V_OUTPUT}" MATCHES "^OpenSCAP command line tool \\(oscap\\) ([0-9\\.]+)")
    set(OSCAP_VERSION "${CMAKE_MATCH_1}")
else()
    set(OSCAP_VERSION "unknown")
endif()