Skip to content

Commit

Permalink
Ubuntu (#12)
Browse files Browse the repository at this point in the history
Re-targeting BIQT for Ubuntu.

Co-authored-by: aford <aford@mitre.org>
  • Loading branch information
mbartenschlag and aford-mitre authored Aug 22, 2023
1 parent 2dc360b commit 5ec3569
Show file tree
Hide file tree
Showing 219 changed files with 798 additions and 18,467 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
*.o
*.so
*.dll
Expand Down
49 changes: 11 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# #######################################################################
# NOTICE
#
# This software (or technical data) was produced for the U.S. Government
# under contract, and is subject to the Rights in Data-General Clause
# 52.227-14, Alt. IV (DEC 2007).
#
# Copyright 2019 The MITRE Corporation. All Rights Reserved.
# #######################################################################

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.16)
project(biqt)
set(CMAKE_CXX_STANDARD 11)

# OPTIONS #####################################################################

OPTION(BUILD_SHARED_LIBS "Builds shared libraries for certain dependencies. Recommended: ON" ON)
OPTION(BUILD_STATIC_LIBS "Builds static libraries for certain dependencies. Recommended: OFF" OFF)
OPTION(WITH_JAVA "Builds Java bindings. Requires a JDK installation. Default: ON" ON)
OPTION(SKIP_PROFILE "Do not set up environment variables on Linux (turn on if you do not have root access)" OFF)

set(BIQT_VERSION "0.1"
set(BIQT_VERSION "23.04"
CACHE STRING "Build version or tag associated with this BIQT release.")

message("BIQT v${BIQT_VERSION}")
Expand All @@ -33,28 +21,17 @@ else()
endif()

include_directories(cxx/
cxx/jsoncpp/include
${EXTRA_INCLUDES})

set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "biqt")
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 1)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_VERSION 0.1)
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "MITRE Corporation")
set(CPACK_PACKAGE_VENDOR "MITRE Corporation")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_RPM_PACKAGE_PROVIDES "jsoncpp == 1.8.3")
include(CPack)
find_package(jsoncpp REQUIRED)

if(WITH_JAVA)
# Java bindings have been requested.
find_package(Java COMPONENTS Development)

# This tends to fail unless JAVA_HOME is set.
find_package(JNI REQUIRED)
add_definitions(-DBIQT_JAVA_SUPPORT)
add_definitions(-DBIQT_JAVA_SUPPORT)

# Add Java-related includes and C/C++ source files.
include_directories(java/src/c ${JNI_INCLUDE_DIRS})
Expand All @@ -68,10 +45,6 @@ else()
unset(JAVA_LIBRARY_FILES)
endif()

# BUILD JSONCPP DEPENDENCY ####################################################

add_subdirectory(cxx/jsoncpp)

# BUILD THE BIQT LIBRARY FILE #################################################
set(LIBRARY_FILES cxx/BIQT.cpp)
add_library(biqtapi SHARED ${LIBRARY_FILES} ${JAVA_LIBRARY_FILES})
Expand All @@ -89,7 +62,7 @@ if(WITH_JAVA)
FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/java/src/main/resources/)

# Locate the maven executable.
find_program(MAVEN NAMES mvn mvnw)
find_program(MAVEN NAMES mvn mvnw PATHS ${CMAKE_SOURCE_DIR}/java/)

if(NOT MAVEN)
message(FATAL_ERROR "Failed to find the Maven executable named mvn or mvnw. Please add it to the PATH or specify its location in CMAKE_PREFIX_PATH.")
Expand Down Expand Up @@ -135,7 +108,7 @@ if(WIN32)

# Try to set BIQT_HOME and PATH. If this fails, rely on the output messages.
install(CODE "message(\"Remember that you must set or update the BIQT_HOME and PATH system environment variables.\")")
install(CODE "message(\"You may execute `SET \\\"BIQT_HOME=${CMAKE_INSTALL_PREFIX_NATIVE_ESCAPED}\\\"` to define BIQT_HOME temporarily, but it will not be saved for future use.\")")
install(CODE "message(\"You may execute `SET \\\"BIQT_HOME=${CMAKE_INSTALL_PREFIX_NATIVE_ESCAPED}\\\"` to define BIQT_HOME temporarily, but it will not be saved for future use.\")")
install(CODE "message(\"You may execute `SET PATH=%JAVA_HOME%\\\\bin\\\\server;%BIQT_HOME%\\\\bin;%PATH%` to update PATH temporarily, but it will not be saved for future use.\")")
else()
# On Linux, files are installed to different locations.
Expand All @@ -148,8 +121,8 @@ else()
RUNTIME DESTINATION bin
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/biqt.sh "export BIQT_HOME=\"${CMAKE_INSTALL_PREFIX}/share/biqt\";\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/biqt.sh "export PATH=$PATH:\"${CMAKE_INSTALL_PREFIX}/bin\";\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/biqt.sh "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:\"${CMAKE_INSTALL_PREFIX}/lib\":\"${CMAKE_INSTALL_PREFIX}/lib64\";\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/biqt.sh "export PATH=$PATH:\"${CMAKE_INSTALL_PREFIX}/bin\";\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/biqt.sh "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:\"${CMAKE_INSTALL_PREFIX}/lib\":\"${CMAKE_INSTALL_PREFIX}/lib64\";\n")
install(CODE "FILE(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/biqt/providers)")

install(FILES setup_provider.py DESTINATION "./share/biqt/scripts")
Expand Down
45 changes: 9 additions & 36 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker (CentOS 7)
# Docker (Ubuntu 22.04)

## Prerequisites

Expand Down Expand Up @@ -26,19 +26,17 @@ $ docker run --rm -it biqt-github
BIQT v0.1
```

# Linux (CentOS Linux 7.4)
# Linux (Ubuntu Linux 22.04)

## Prerequisites

This guide targets CentOS Linux 7.4.
This guide targets Ubuntu Linux 22.04.

This provider relies on OpenCV and other core development tools including gcc. These dependencies can be installed from
the [Extra Packages for Enterprise Linux (EPEL)](https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F)
repository using the following commands:
This provider relies on OpenCV and other core development tools including gcc. These dependencies can be installed using the following commands:

```bash
sudo yum groupinstall "Development Tools"
sudo yum install -y cmake3 maven
sudo apt update
sudo apt install -y cmake build-essential libjsoncpp-dev openjdk-17-jdk
```

## Building and Installing
Expand All @@ -52,7 +50,7 @@ git clone git@github.com:mitre/biqt
cd biqt
mkdir build
cd build
cmake3 -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
sudo make install
```
Expand All @@ -64,30 +62,9 @@ to start BIQT!

```bash
$> biqt --version
BIQT v0.1
BIQT v23.04
```

# Windows 10

## Prerequisites

This guide targets Microsoft Windows 10.

The following tools are required to build BIQT from source. When installing CMake and Git,
please select the option to add the executables to the system's `PATH` environment variable.
* [CMake 3.9+](https://cmake.org/files/v3.9/cmake-3.9.2-win64-x64.msi)
* [Git 2.16+](https://git-scm.com/)
* [Microsoft Visual Studio Community Edition 2013](https://www.visualstudio.com/vs/older-downloads/) (Registration required.)

The following software is required to build the Java bindings for BIQT.
* [Apache Maven 3.5.2](https://maven.apache.org/download.cgi)
* [Java SE JDK 9](http://www.oracle.com/technetwork/java/javase/downloads/index.html)

After installing Apache Maven and a Java JDK, set the following environment variables according to the example below. Note that
these examples may need to be changed depending on the software versions you install and where you install them.
* Set `JAVA_HOME` to `C:\Program Files\Java\jdk-9.0.4`.
* Update `PATH` to include `C:\apache-maven-3.5.2\bin` and `C:\Program Files\Java\jdk-9.0.4\bin\server`.

## Building and Installing

As an administrator, execute the following commands from the VS2013 x64 Cross Tools Command Prompt. By default, a shortcut to
Expand All @@ -108,10 +85,6 @@ nmake
nmake install
```

By default, BIQT will be installed to `C:\Program Files\biqt`. During installation, you will be reminded to set
the `BIQT_HOME` and `PATH` environment variables as follows:
* Set `BIQT_HOME` to `C:\Program Files\biqt`.
* Update `PATH` to include `C:\Program Files\biqt\bin`.

## Verifying installation.

Expand All @@ -120,5 +93,5 @@ please verify that `JAVA_HOME` and the `PATH` variables are assigned correctly.

```
$> biqt --version
BIQT v0.1
BIQT v23.04
```
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Once implemented, providers can be built and installed into the framework using
framework must already be installed and the BIQT_HOME environment variable must be set.


**CentOS Linux 7.4**
**Ubuntu Linux 22.04**

```bash
cd ~/MyProvider
Expand All @@ -77,16 +77,6 @@ make
make install
```

**Windows 10**

```
cd C:\Users\user\MyProvider
mkdir build
cd build
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..
nmake
nmake install
```

### Related Resources

Expand Down
2 changes: 1 addition & 1 deletion cxx/BIQT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ProviderInfo::ProviderInfo(std::string modulePath, std::string lib)
this->handle = dlopen(this->soPath.c_str(), RTLD_NOW);
if (!this->handle) {
throw std::runtime_error(
"Provider Read error: Unable to load the shared object");
"Provider Read error: Unable to load the shared object: " + std::string(dlerror()));
}
}

Expand Down
47 changes: 0 additions & 47 deletions cxx/jsoncpp/.clang-format

This file was deleted.

11 changes: 0 additions & 11 deletions cxx/jsoncpp/.gitattributes

This file was deleted.

55 changes: 0 additions & 55 deletions cxx/jsoncpp/.gitignore

This file was deleted.

Loading

0 comments on commit 5ec3569

Please sign in to comment.