Skip to content

Commit bb417ee

Browse files
authored
Merge pull request #52 from open-license-manager/develop
release 1.1.0
2 parents 420adab + dfddf52 commit bb417ee

File tree

20 files changed

+485
-360
lines changed

20 files changed

+485
-360
lines changed

.travis.yml

Lines changed: 90 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ matrix:
2121
- libboost-system-dev
2222
- libboost-thread-dev
2323
- libboost-date-time-dev
24+
script:
25+
- cmake --build . --target install
26+
- ctest
27+
- ctest -T memcheck
2428
- os: linux
2529
dist: xenial
2630
name: "Ubuntu 16.04 - Travis CI VM"
@@ -39,64 +43,120 @@ matrix:
3943
- libboost-system-dev
4044
- libboost-thread-dev
4145
- libboost-date-time-dev
42-
46+
- os: linux
47+
dist: bionic
48+
name: "Ubuntu 18.04 - Travis CI VM - Debug build"
49+
addons:
50+
apt:
51+
packages:
52+
- cmake
53+
- valgrind
54+
- libssl-dev
55+
- zlib1g-dev
56+
- libboost-dev
57+
- libboost-test-dev
58+
- libboost-filesystem-dev
59+
- libboost-iostreams-dev
60+
- libboost-program-options-dev
61+
- libboost-system-dev
62+
- libboost-thread-dev
63+
- libboost-date-time-dev
64+
before_script:
65+
- mkdir build
66+
- cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install -DCMAKE_BUILD_TYPE=Debug ..
67+
script:
68+
- cmake --build . --target install
69+
- ctest
70+
- ctest -T memcheck
71+
4372
- os: linux
4473
dist: bionic
4574
name: "CentOS-7 Docker"
4675
before_script:
4776
- docker run --name centos7_toconfigure -v `pwd`:/root/open-license-manager centos:centos7 /bin/bash -c
48-
"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 &&
49-
yum -y install devtoolset-3-gcc devtoolset-3-gcc-c++ && cd /root/open-license-manager && mkdir build && cd build &&
50-
CC=/opt/rh/devtoolset-3/root/usr/bin/gcc XX=/opt/rh/devtoolset-3/root/usr/bin/g++ cmake .."
77+
"yum -y update && yum -y install install centos-release-scl &&
78+
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 &&
79+
cd /root/open-license-manager && mkdir build && cd build &&
80+
CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++ cmake .."
5181
- docker commit centos7_toconfigure centos7_configured
5282
script:
5383
- docker run --name centos7_make -v `pwd`:/root/open-license-manager centos7_configured /bin/bash -c
5484
"cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test"
55-
85+
- os: linux
86+
dist: bionic
87+
name: "Ubuntu 18.04 - MinGW cross-compile for Windows x64"
88+
addons:
89+
apt:
90+
packages:
91+
- cmake
92+
- binutils-mingw-w64
93+
- mingw-w64
94+
- mingw-w64-tools
95+
- mingw-w64-x86-64-dev
96+
- wine-development
97+
before_script:
98+
- mkdir build
99+
- cd build
100+
- wget -c https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2
101+
- tar xjf boost_1_71_0.tar.bz2
102+
- sudo ln -s /usr/bin/x86_64-w64-mingw32-g++ /usr/local/bin/g++-mingw
103+
- cd boost_1_71_0
104+
- ./bootstrap.sh
105+
- 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
106+
- cd ..
107+
- cmake -DCMAKE_TOOLCHAIN_FILE=../modules/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/boost_1_71_0/dist ..
56108
- os: windows
57109
name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MD)"
58-
env:
59-
- CACHE_NAME=boost
60-
cache:
61-
directories:
62-
- "/C/local/boost"
63110
before_script:
64-
#- Regsvr32.exe "C:\Widnows\System32\rsaenh.dll"
65-
#Not sure this is necessary let's leave it here for some time, see if there are
66-
#differences with the build (/MT)
67-
- sc stop CryptSvc
68-
- travis_wait 30 ./windows_download_boost.bat
69-
- cd "/C/Users/travis/build/open-license-manager/open-license-manager"
111+
- travis_wait 40 ./windows_download_boost.bat
112+
- cd "${TRAVIS_BUILD_DIR}"
70113
- mkdir build
71114
- cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" ..
72-
script:
73-
- cmake --build . --target install --config Release
74-
- ctest -C Release
75115

76116
- os: windows
77117
name: "Widnows server 1803 - Visual Studio 15 2017 Win64 - (/MT)"
118+
before_script:
119+
- travis_wait 40 ./windows_download_boost.bat
120+
- cd "${TRAVIS_BUILD_DIR}"
121+
- mkdir build
122+
- cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 ..
123+
124+
- os: windows
125+
name: "Widnows server 1803 - MinGW Win64"
78126
env:
79-
- CACHE_NAME=boost
127+
- CACHE_NAME=boost-mingw
80128
cache:
129+
name: boost-mingw
81130
directories:
82131
- "/C/local/boost"
83132
before_script:
84-
- travis_wait 30 ./windows_download_boost.bat
85-
- cd "/C/Users/travis/build/open-license-manager/open-license-manager"
133+
- |
134+
if [ -d "/C/local/boost/lib" ]; then
135+
echo "Boost already installed"
136+
else
137+
echo "Boost not cached, compiling it"
138+
wget -q https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.7z
139+
echo "Boost downloaded"
140+
travis_wait 20 7z x boost_1_68_0.7z -oC:/local
141+
cd "C:/local/boost_1_68_0"
142+
./bootstrap.bat gcc
143+
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
144+
echo "Boost installed"
145+
cd /C/local/boost/lib
146+
dir
147+
fi
148+
- cd "${TRAVIS_BUILD_DIR}"
86149
- mkdir build
87-
- cd build && cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:/local/boost" -DSTATIC_RUNTIME=1 ..
88-
script:
89-
- cmake --build . --target install --config Release
90-
- ctest -C Release
91-
150+
- 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" ..
151+
92152
env:
93153
- CTEST_OUTPUT_ON_FAILURE=1
154+
94155
before_script:
95156
- mkdir build
96157
- cd build && cmake -DCMAKE_INSTALL_PREFIX=../../install ..
97158

98159
script:
99-
- make
100-
- make install
101-
- make test
160+
- cmake --build . --target install --config Release
161+
- ctest -C Release
102162

CMakeLists.txt

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if(CMAKE_BUILD_TYPE)
2222
string(TOLOWER ${CMAKE_BUILD_TYPE} _CMAKE_BUILD_TYPE)
2323
EVAL_CONDITION(RELEASE_BUILD ${_CMAKE_BUILD_TYPE} STREQUAL "release")
2424
else(CMAKE_BUILD_TYPE)
25-
set(RELEASE_BUILD 0)
25+
SET(RELEASE_BUILD 0)
2626
endif(CMAKE_BUILD_TYPE)
2727

2828
if(MSVC)
@@ -43,32 +43,19 @@ if(MSVC)
4343
#SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES}
4444
add_definitions("/D _CRT_SECURE_NO_WARNINGS")
4545
else(MSVC)
46+
#GCC or Mingw
4647
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wuninitialized -fPIC") #-Wall
4748
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -fmessage-length=0 -Wall -Wuninitialized -fPIC")
48-
if(RELEASE_BUILD)
49-
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) #.so for dynamic libraries
50-
else()
51-
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
52-
endif()
53-
set (CMAKE_EXE_LINKER_FLAGS "-pthread")
49+
SET(CMAKE_EXE_LINKER_FLAGS "-pthread -static-libstdc++")
5450
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,--strip-all -static-libstdc++") #-static
5551
#you need to "force" the change in cmake_install_prefix after the project keyword
5652
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
5753
SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix" FORCE)
5854
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
59-
#find a static version of openssl crypto library
60-
find_package(OpenSSL REQUIRED)
61-
include_directories(${OPENSSL_INCLUDE_DIR})
6255
if(MINGW)
63-
list(APPEND EXTERNAL_LIBS "-lcrypto -liphlpapi")
64-
else(MINGW)
65-
list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY})
56+
list(APPEND EXTERNAL_LIBS "-lcrypt32 -lws2_32 -liphlpapi")
57+
SET(CMAKE_EXE_LINKER_FLAGS "-static")
6658
endif(MINGW)
67-
MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION} ")
68-
69-
#Zlib required when openssl version < 1.0.1f
70-
find_package(ZLIB REQUIRED)
71-
list(APPEND EXTERNAL_LIBS ${ZLIB_LIBRARIES})
7259

7360
if(USE_DBUS_IDENTIFIER)
7461
FIND_PACKAGE(Dbus REQUIRED)
@@ -77,22 +64,47 @@ else(MSVC)
7764
include_directories(${DBUS_ARCH_INCLUDE_DIR})
7865
list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES})
7966
endif(USE_DBUS_IDENTIFIER)
80-
if(NOT MINGW)
81-
list(APPEND EXTERNAL_LIBS dl)
82-
endif(NOT MINGW)
83-
list(APPEND EXTERNAL_LIBS "-Wl,-Bdynamic")
8467
endif(MSVC)
8568

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

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

8990
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
9091
SET(HAVE_64BIT_SIZE_T 1)
9192
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
9293
SET(HAVE_64BIT_SIZE_T 0)
9394
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
9495

95-
set( Boost_USE_STATIC_LIBS ON )
96+
#bug in cmake win32 - can't find boost compiled with mingw
97+
if(WIN32 AND "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x")
98+
message(WARNING "WIN32 compiler does not specify CMAKE_CXX_COMPILER_ARCHITECTURE_ID -- filling in manually")
99+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
100+
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x64")
101+
else()
102+
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x86")
103+
endif()
104+
message(STATUS "Compiler architecture: ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
105+
endif()
106+
107+
SET( Boost_USE_STATIC_LIBS ON )
96108
find_package(Boost REQUIRED COMPONENTS date_time unit_test_framework program_options system filesystem)
97109
#set below in case of dynamic linking in debug.
98110
#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:BOOST_TEST_DYN_LINK>)

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ software closed :smirk: . A comprehensive [list of features](https://github.com/
1111

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

1616

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

31-
#How to build
31+
# How to build
3232

3333
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.
3434

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

3939
```
4040
git clone https://github.com/open-license-manager/open-license-manager.git
@@ -94,3 +94,7 @@ $ ../install/bin/license_generator example -s Jaaa-aaaa-MG9F-ZhBB -o example.lic
9494
$ ./example
9595
licence OK
9696
```
97+
98+
# How to contribute
99+
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)
100+
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.

example/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ if(MSVC)
1010
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib )
1111
else(MSVC)
1212
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
13-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicense++_static.a")
13+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicensepp_static.a")
1414
find_package(OpenSSL REQUIRED)
1515
endif(MSVC)
1616

1717
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
1818

1919
add_executable(example example.cpp)
2020

21-
target_link_libraries(example license++_static os base tools_base)
21+
target_link_libraries(example licensepp_static os base tools_base)
2222

2323
if(NOT MSVC)
2424
target_link_libraries(example crypto pthread dl z)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
2+
#
3+
# Typical usage:
4+
# *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
5+
# *) cd build
6+
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake ..
7+
8+
set(CMAKE_SYSTEM_NAME Windows)
9+
set(CMAKE_HOST_SYSTEM_NAME Linux)
10+
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
11+
12+
# cross compilers to use for C and C++
13+
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
14+
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
15+
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
16+
17+
# target environment on the build host system
18+
# set 1st to dir with the cross compiler's C/C++ headers/libs
19+
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
20+
21+
# modify default behavior of FIND_XXX() commands to
22+
# search for headers/libs in the target environment and
23+
# search for programs in the build host environment
24+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
25+
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26+
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

src/library/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ add_subdirectory("os")
22
add_subdirectory("base")
33
add_subdirectory("ini")
44

5-
ADD_LIBRARY(license++_static STATIC
5+
ADD_LIBRARY(licensepp_static STATIC
66
license++.cpp
77
LicenseReader.cpp
88
pc-identifiers.c
99
)
1010

1111
target_link_libraries(
12-
license++_static
12+
licensepp_static
1313
ini
1414
os
1515
)
1616

17-
install(TARGETS license++_static ARCHIVE DESTINATION lib)
17+
install(TARGETS licensepp_static ARCHIVE DESTINATION lib)
1818
install(FILES api/datatypes.h api/license++.h DESTINATION include/api)
1919
install(FILES base/base.h DESTINATION include/base)
2020
install(FILES pc-identifiers.h DESTINATION include/)

src/library/os/os-linux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
#include <sys/stat.h>
33
#include "os.h"
44
#include "../base/logger.h"
5-
6-
//#include <openssl/evp.h>
7-
//#include <openssl/bio.h>
85
#include <openssl/pem.h>
96
#include <openssl/err.h>
107

118
#include <mntent.h>
129
#include <dirent.h>
13-
1410
#include <sys/utsname.h>
11+
#ifdef _DEBUG
12+
#include <valgrind/memcheck.h>
13+
#endif
14+
1515
#ifdef USE_DBUS
1616
#include <dbus-1.0/dbus/dbus.h>
1717
#endif

0 commit comments

Comments
 (0)