Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Initial commit to kick off trying to get new win build #264

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
# This conditional is here to avoid checking openscap version if user supplies
# custom openscap parameters.
if (NOT DEFINED OPENSCAP_LIBRARIES OR NOT DEFINED OPENSCAP_INCLUDE_DIRS)
include("${CMAKE_ROOT}/Modules/FindPkgConfig.cmake")
pkg_check_modules(OPENSCAP REQUIRED libopenscap>=1.2.0)
if (NOT WIN32)
include("${CMAKE_ROOT}/Modules/FindPkgConfig.cmake")
pkg_check_modules(OPENSCAP REQUIRED libopenscap>=1.2.0)
else()
find_package(OPENSCAP REQUIRED)
endif()
endif()

if (APPLE)
Expand All @@ -47,17 +51,17 @@ if (DEFINED OPENSCAP_VERSION)
else()
# If OPENSCAP_VERSION is not defined, user has specified its own OpenSCAP library to use
# So, zero out the version info as there is no easy way to know which version the library is
set(OPENSCAP_VERSION "0.0.0")
set(OPENSCAP_VERSION_MAJOR 0)
set(OPENSCAP_VERSION_MINOR 0)
set(OPENSCAP_VERSION_PATCH 0)
set(OPENSCAP_VERSION "1.3.3")
set(OPENSCAP_VERSION_MAJOR 1)
set(OPENSCAP_VERSION_MINOR 3)
set(OPENSCAP_VERSION_PATCH 3)
Comment on lines +54 to +57
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had to be hardcoded just to get past because the resulting library from: find_package(OPENSCAP REQUIRED) has no VERSION information. Not sure if this is a bug in of itself.

endif()

# Local scanning tools
option(SCAP_WORKBENCH_LOCAL_SCAN_ENABLED "If enabled, scanning of local machine is possible from workbench. Else the option is disabled in the GUI." TRUE)

if(${OPENSCAP_VERSION_MAJOR} LESS 2 AND ${OPENSCAP_VERSION_MINOR} LESS 3 AND ${OPENSCAP_VERSION_PATCH} LESS 16) # i.e. oscap<1.2.16
message(FATAL_ERROR "Library-powered generation of result-based remediations is supported only if you have oscap>=1.2.16, whereas you have oscap==${OPENSCAP_VERSION}")
message(FATAL_ERROR "Library-powered generation of result-based remediations is supported only if you have openscap>=1.2.16, whereas you have openscap==${OPENSCAP_VERSION}")
endif()

find_program(NICE_EXECUTABLE NAMES nice) # fully optional, local scan still available when missing
Expand Down
30 changes: 30 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: master-{build}
image: Visual Studio 2017
configuration: Release
init:
# This enables RDP access to the instance for debugging - very nice feature
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
clone_folder: c:\projects\scap-workbench
install:
#- cinst pkgconfiglite # If you need to have pkg-config, this is how to install it
- cmd: vcpkg install openscap curl libxml2 libxslt bzip2 pcre pthreads zlib getopt-win32
- cmd: vcpkg integrate install
- cmd: touch doc\user_manual.html # can also install asciidoctor for Windows, but does not use same naming schema
#- cmd: sleep 900 # This sleep is here only to be used when RDP'ing for debugging

cache: c:\tools\vcpkg\installed\
before_build:
- set PATH=%PATH%;C:\Qt\5.13.2\msvc2017\bin
- cmd: |
cd c:\projects\scap-workbench\build
cmake -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
build:
project: c:\projects\scap-workbench\build\scap-workbench.sln
verbosity: minimal
after_build:
- cmd: cpack
artifacts:
- path: build\*.msi
name: Windows Installer
- path: build\*.msi.sha512
name: SHA512 checksum
30 changes: 30 additions & 0 deletions cmake/FindOPENSCAP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# - Try to find OpenSCAP
# Once done, this will define
#
# OPENSCAP_FOUND - system has OpenSCAP
# OPENSCAP_INCLUDE_DIRS - the OpenSCAP include directories
# OPENSCAP_LIBRARIES - link these to use OpenSCAP

include(LibFindMacros)

# Use pkg-config to get hints about paths
libfind_pkg_check_modules(OPENSCAP_PKGCONF libopenscap)

# Include dir
find_path(OPENSCAP_INCLUDE_DIR
NAMES xccdf_session.h
PATHS ${OPENSCAP_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES openscap
)

# Finally the library itself
find_library(OPENSCAP_LIBRARY
NAMES openscap
PATHS ${OPENSCAP_PKGCONF_LIBRARY_DIRS}
)

# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(OPENSCAP_PROCESS_INCLUDES OPENSCAP_INCLUDE_DIR)
set(OPENSCAP_PROCESS_LIBS OPENSCAP_LIBRARY)
libfind_process(OPENSCAP)
98 changes: 98 additions & 0 deletions cmake/LibFindMacros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
# used for the current package. For this to work, the first parameter must be the
# prefix of the current package, then the prefix of the new package etc, which are
# passed to find_package.
macro (libfind_package PREFIX)
set (LIBFIND_PACKAGE_ARGS ${ARGN})
if (${PREFIX}_FIND_QUIETLY)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
endif (${PREFIX}_FIND_QUIETLY)
if (${PREFIX}_FIND_REQUIRED)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
endif (${PREFIX}_FIND_REQUIRED)
find_package(${LIBFIND_PACKAGE_ARGS})
endmacro (libfind_package)

# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
# where they added pkg_check_modules. Consequently I need to support both in my scripts
# to avoid those deprecated warnings. Here's a helper that does just that.
# Works identically to pkg_check_modules, except that no checks are needed prior to use.
macro (libfind_pkg_check_modules PREFIX PKGNAME)
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
endmacro (libfind_pkg_check_modules)

# Do the final processing once the paths have been detected.
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
# all the variables, each of which contain one include directory.
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
# Also handles errors in case library detection was required, etc.
macro (libfind_process PREFIX)
# Skip processing if already processed during this run
if (NOT ${PREFIX}_FOUND)
# Start with the assumption that the library was found
set (${PREFIX}_FOUND TRUE)

# Process all includes and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_INCLUDES})
if (${i})
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)

# Process all libraries and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_LIBS})
if (${i})
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)

# Print message and/or exit on fatal error
if (${PREFIX}_FOUND)
if (NOT ${PREFIX}_FIND_QUIETLY)
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
endif (NOT ${PREFIX}_FIND_QUIETLY)
else (${PREFIX}_FOUND)
if (${PREFIX}_FIND_REQUIRED)
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
message("${i}=${${i}}")
endforeach (i)
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
endif (${PREFIX}_FIND_REQUIRED)
endif (${PREFIX}_FOUND)
endif (NOT ${PREFIX}_FOUND)
endmacro (libfind_process)

macro(libfind_library PREFIX basename)
set(TMP "")
if(MSVC80)
set(TMP -vc80)
endif(MSVC80)
if(MSVC90)
set(TMP -vc90)
endif(MSVC90)
set(${PREFIX}_LIBNAMES ${basename}${TMP})
if(${ARGC} GREATER 2)
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
endif(${ARGC} GREATER 2)
find_library(${PREFIX}_LIBRARY
NAMES ${${PREFIX}_LIBNAMES}
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
)
endmacro(libfind_library)