Skip to content

Commit

Permalink
Merge pull request #52 from open-license-manager/develop
Browse files Browse the repository at this point in the history
release 1.1.0
  • Loading branch information
gcontini authored Sep 19, 2019
2 parents 420adab + dfddf52 commit bb417ee
Show file tree
Hide file tree
Showing 20 changed files with 485 additions and 360 deletions.
120 changes: 90 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ matrix:
- libboost-system-dev
- libboost-thread-dev
- libboost-date-time-dev
script:
- cmake --build . --target install
- ctest
- ctest -T memcheck
- os: linux
dist: xenial
name: "Ubuntu 16.04 - Travis CI VM"
Expand All @@ -39,64 +43,120 @@ matrix:
- libboost-system-dev
- libboost-thread-dev
- libboost-date-time-dev

- os: linux
dist: bionic
name: "Ubuntu 18.04 - Travis CI VM - Debug build"
addons:
apt:
packages:
- cmake
- valgrind
- libssl-dev
- zlib1g-dev
- libboost-dev
- libboost-test-dev
- libboost-filesystem-dev
- libboost-iostreams-dev
- libboost-program-options-dev
- libboost-system-dev
- libboost-thread-dev
- libboost-date-time-dev
before_script:
- mkdir build
- cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install -DCMAKE_BUILD_TYPE=Debug ..
script:
- cmake --build . --target install
- ctest
- ctest -T memcheck

- os: linux
dist: bionic
name: "CentOS-7 Docker"
before_script:
- docker run --name centos7_toconfigure -v `pwd`:/root/open-license-manager centos:centos7 /bin/bash -c
"yum -y update && yum -y install cmake boost boost-devel boost-static openssl openssl-devel gcc-c++ valgrind valgrind-devel glibc-static centos-release-scl-rh &&
yum -y install devtoolset-3-gcc devtoolset-3-gcc-c++ && cd /root/open-license-manager && mkdir build && cd build &&
CC=/opt/rh/devtoolset-3/root/usr/bin/gcc XX=/opt/rh/devtoolset-3/root/usr/bin/g++ cmake .."
"yum -y update && yum -y install install centos-release-scl &&
yum -y install cmake boost boost-devel boost-static openssl openssl-devel glibc-static devtoolset-7-toolchain devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-valgrind-devel &&
cd /root/open-license-manager && mkdir build && cd build &&
CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++ cmake .."
- docker commit centos7_toconfigure centos7_configured
script:
- docker run --name centos7_make -v `pwd`:/root/open-license-manager centos7_configured /bin/bash -c
"cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test"

- os: linux
dist: bionic
name: "Ubuntu 18.04 - MinGW cross-compile for Windows x64"
addons:
apt:
packages:
- cmake
- binutils-mingw-w64
- mingw-w64
- mingw-w64-tools
- mingw-w64-x86-64-dev
- wine-development
before_script:
- mkdir build
- cd build
- wget -c https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2
- tar xjf boost_1_71_0.tar.bz2
- sudo ln -s /usr/bin/x86_64-w64-mingw32-g++ /usr/local/bin/g++-mingw
- cd boost_1_71_0
- ./bootstrap.sh
- travis_wait 30 ./b2 toolset=gcc-mingw target-os=windows address-model=64 --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system runtime-link=static --prefix=./dist release install
- cd ..
- cmake -DCMAKE_TOOLCHAIN_FILE=../modules/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/boost_1_71_0/dist ..
- os: windows
name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MD)"
env:
- CACHE_NAME=boost
cache:
directories:
- "/C/local/boost"
before_script:
#- Regsvr32.exe "C:\Widnows\System32\rsaenh.dll"
#Not sure this is necessary let's leave it here for some time, see if there are
#differences with the build (/MT)
- sc stop CryptSvc
- travis_wait 30 ./windows_download_boost.bat
- cd "/C/Users/travis/build/open-license-manager/open-license-manager"
- travis_wait 40 ./windows_download_boost.bat
- cd "${TRAVIS_BUILD_DIR}"
- mkdir build
- cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" ..
script:
- cmake --build . --target install --config Release
- ctest -C Release

- os: windows
name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MT)"
before_script:
- travis_wait 40 ./windows_download_boost.bat
- cd "${TRAVIS_BUILD_DIR}"
- mkdir build
- cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 ..

- os: windows
name: "Widnows server 1803 - MinGW Win64"
env:
- CACHE_NAME=boost
- CACHE_NAME=boost-mingw
cache:
name: boost-mingw
directories:
- "/C/local/boost"
before_script:
- travis_wait 30 ./windows_download_boost.bat
- cd "/C/Users/travis/build/open-license-manager/open-license-manager"
- |
if [ -d "/C/local/boost/lib" ]; then
echo "Boost already installed"
else
echo "Boost not cached, compiling it"
wget -q https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.7z
echo "Boost downloaded"
travis_wait 20 7z x boost_1_68_0.7z -oC:/local
cd "C:/local/boost_1_68_0"
./bootstrap.bat gcc
travis_wait 40 ./b2.exe -d0 --with-date_time --with-test --with-filesystem --with-program_options --with-regex --with-serialization --with-system runtime-link=static toolset=gcc --prefix=C:/local/boost install
echo "Boost installed"
cd /C/local/boost/lib
dir
fi
- cd "${TRAVIS_BUILD_DIR}"
- mkdir build
- cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 ..
script:
- cmake --build . --target install --config Release
- ctest -C Release

- cd build && cmake -G "MinGW Makefiles" --trace-expand -DBOOST_ROOT="C:/local/boost" -DBoost_ARCHITECTURE="-x64" -DCMAKE_CXX_COMPILER_ARCHITECTURE_ID="x64" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..

env:
- CTEST_OUTPUT_ON_FAILURE=1

before_script:
- mkdir build
- cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install ..

script:
- make
- make install
- make test
- cmake --build . --target install --config Release
- ctest -C Release

60 changes: 36 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE)
EVAL_CONDITION(RELEASE_BUILD ${_CMAKE_BUILD_TYPE} STREQUAL "release")
else(CMAKE_BUILD_TYPE)
set(RELEASE_BUILD 0)
SET(RELEASE_BUILD 0)
endif(CMAKE_BUILD_TYPE)

if(MSVC)
Expand All @@ -43,32 +43,19 @@ if(MSVC)
#SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES}
add_definitions("/D _CRT_SECURE_NO_WARNINGS")
else(MSVC)
#GCC or Mingw
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wuninitialized -fPIC") #-Wall
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -fmessage-length=0 -Wall -Wuninitialized -fPIC")
if(RELEASE_BUILD)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) #.so for dynamic libraries
else()
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
endif()
set (CMAKE_EXE_LINKER_FLAGS "-pthread")
SET(CMAKE_EXE_LINKER_FLAGS "-pthread -static-libstdc++")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,--strip-all -static-libstdc++") #-static
#you need to "force" the change in cmake_install_prefix after the project keyword
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix" FORCE)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
#find a static version of openssl crypto library
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
if(MINGW)
list(APPEND EXTERNAL_LIBS "-lcrypto -liphlpapi")
else(MINGW)
list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY})
list(APPEND EXTERNAL_LIBS "-lcrypt32 -lws2_32 -liphlpapi")
SET(CMAKE_EXE_LINKER_FLAGS "-static")
endif(MINGW)
MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ")

#Zlib required when openssl version < 1.0.1f
find_package(ZLIB REQUIRED)
list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES})

if(USE_DBUS_IDENTIFIER)
FIND_PACKAGE(Dbus REQUIRED)
Expand All @@ -77,22 +64,47 @@ else(MSVC)
include_directories(${DBUS_ARCH_INCLUDE_DIR})
list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES})
endif(USE_DBUS_IDENTIFIER)
if(NOT MINGW)
list(APPEND EXTERNAL_LIBS dl)
endif(NOT MINGW)
list(APPEND EXTERNAL_LIBS "-Wl,-Bdynamic")
endif(MSVC)

set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>)
if(UNIX) #this is true for all the linux systems but not for cross compiling
#find a static version of openssl crypto library
SET ( OPENSSL_USE_STATIC_LIBS ON )
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
include_directories(${OPENSSL_INCLUDE_DIR})
list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY})
MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ")
#Zlib required when openssl version < 1.0.1f
SET ( ZLIB_USE_STATIC_LIBS ON )
find_package(ZLIB REQUIRED)
list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES})
MESSAGE(STATUS "Found zlib version ${ZLIB_VERSION} ")
if(NOT MINGW)
list(APPEND EXTERNAL_LIBS "-ldl")
endif(NOT MINGW)
find_program( MEMORYCHECK_COMMAND valgrind )
set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" )
endif(UNIX)

SET_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(HAVE_64BIT_SIZE_T 1)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(HAVE_64BIT_SIZE_T 0)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)

set( Boost_USE_STATIC_LIBS ON )
#bug in cmake win32 - can't find boost compiled with mingw
if(WIN32 AND "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x")
message(WARNING "WIN32 compiler does not specify CMAKE_CXX_COMPILER_ARCHITECTURE_ID -- filling in manually")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x64")
else()
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x86")
endif()
message(STATUS "Compiler architecture: ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
endif()

SET( Boost_USE_STATIC_LIBS ON )
find_package(Boost REQUIRED COMPONENTS date_time unit_test_framework program_options system filesystem)
#set below in case of dynamic linking in debug.
#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>)
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ software closed :smirk: . A comprehensive [list of features](https://github.com/

## License
The project is donated to the community. It comes with a very large freedom of use for everyone, and it will always be.
It uses a [BSD 3 clauses](https://opensource.org/licenses/BSD-3-Clause) licensing schema, that allows the inclusion in commercial software.
It uses a [BSD 3 clauses](https://opensource.org/licenses/BSD-3-Clause) licensing schema, that allows free modification and inclusion in commercial software.


## Project Structure
Expand All @@ -28,13 +28,13 @@ You can notice 2 more sub-projects:
* bootstrap: allows to generate private keys and modify the library on the fly after the downloading.
* testing : runs the tests (and publish the results on cdash)

#How to build
# How to build

Below an overview of the basic build procedure, you can find detailed instructions for each [supported environment](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) in the wiki.

## prerequisites
* compilsers: GCC (Linux), MINGW or MSVC (Windows)
* tools/libs: cmake, boost, openssl (Linux/MINGW).
* compilsers: GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows)
* tools/libs: cmake, boost. If target is linux openssl is necessary.

```
git clone https://github.com/open-license-manager/open-license-manager.git
Expand Down Expand Up @@ -94,3 +94,7 @@ $ ../install/bin/license_generator example -s Jaaa-aaaa-MG9F-ZhBB -o example.lic
$ ./example
licence OK
```

# How to contribute
The project is not dead but we take our time to answer. The best interaction you can have with us is through the issue system. Have a look to the [contribution guidelines](blob/develop/CONTRIBUTING.md)
We use [GitFlow](https://datasift.github.io/gitflow/IntroducingGitFlow.html) (or at least a subset of it). Remember to install the gitflow git plugin and use `develop` as default branch for your pull requests.
4 changes: 2 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ if(MSVC)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib )
else(MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicense++_static.a")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicensepp_static.a")
find_package(OpenSSL REQUIRED)
endif(MSVC)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

add_executable(example example.cpp)

target_link_libraries(example license++_static os base tools_base)
target_link_libraries(example licensepp_static os base tools_base)

if(NOT MSVC)
target_link_libraries(example crypto pthread dl z)
Expand Down
27 changes: 27 additions & 0 deletions modules/toolchain-ubuntu-mingw64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
# *) cd build
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake ..

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_HOST_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)

# cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)

# target environment on the build host system
# set 1st to dir with the cross compiler's C/C++ headers/libs
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})

# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# search for programs in the build host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
6 changes: 3 additions & 3 deletions src/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ add_subdirectory("os")
add_subdirectory("base")
add_subdirectory("ini")

ADD_LIBRARY(license++_static STATIC
ADD_LIBRARY(licensepp_static STATIC
license++.cpp
LicenseReader.cpp
pc-identifiers.c
)

target_link_libraries(
license++_static
licensepp_static
ini
os
)

install(TARGETS license++_static ARCHIVE DESTINATION lib)
install(TARGETS licensepp_static ARCHIVE DESTINATION lib)
install(FILES api/datatypes.h api/license++.h DESTINATION include/api)
install(FILES base/base.h DESTINATION include/base)
install(FILES pc-identifiers.h DESTINATION include/)
Expand Down
8 changes: 4 additions & 4 deletions src/library/os/os-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
#include <sys/stat.h>
#include "os.h"
#include "../base/logger.h"

//#include <openssl/evp.h>
//#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/err.h>

#include <mntent.h>
#include <dirent.h>

#include <sys/utsname.h>
#ifdef _DEBUG
#include <valgrind/memcheck.h>
#endif

#ifdef USE_DBUS
#include <dbus-1.0/dbus/dbus.h>
#endif
Expand Down
Loading

0 comments on commit bb417ee

Please sign in to comment.