From e3e83c70085d9a9c82b643b46d918fe3a2d21e03 Mon Sep 17 00:00:00 2001
From: Gabriele Contini <contini.mailing@gmail.com>
Date: 周六, 14 12月 2019 11:35:52 +0800
Subject: [PATCH] fix windows compilation, better cmake output

---
 src/library/CMakeLists.txt                    |    2 
 CONTRIBUTING.md                               |   70 +++++++++++-----------
 src/library/os/windows/signature_verifier.cpp |    7 --
 .travis.yml                                   |    2 
 include/licensecc/datatypes.h                 |    2 
 CMakeLists.txt                                |    7 +-
 cmake/Findlcc.cmake                           |    2 
 src/library/os/CMakeLists.txt                 |    5 +
 test/CMakeLists.txt                           |   12 +---
 README.md                                     |   20 +++---
 10 files changed, 59 insertions(+), 70 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 925d1cc..9207dba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -101,7 +101,7 @@
              wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1d.tar.gz && 
              tar xzf OpenSSL_1_1_1d.tar.gz && cd openssl-OpenSSL_1_1_1d && 
              ./config && make -j 8 && make install && 
-             cd /root/lcc-license-manager/build && cmake .."
+             cd /root/open-license-manager/build && cmake .."
         - docker commit centos8_toconfigure centos8_configured
      script: 
         - docker run --name centos8_make -v `pwd`:/root/open-license-manager centos8_configured /bin/bash -c \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 939aeaf..e8fddab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,11 +35,9 @@
 ENDIF()
 
 SET (OPENSSL_USE_STATIC_LIBS ON)
-find_package(OpenSSL COMPONENTS Crypto)
+find_package(OpenSSL COMPONENTS Crypto QUIET)
 IF(OPENSSL_FOUND)
 	MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION}")
-ELSE(OPENSSL_FOUND)
-	MESSAGE(STATUS "OpenSSL not found")
 ENDIF(OPENSSL_FOUND)
 
 if(UNIX) #this is true for all the linux systems but not for cross compiling "linux->windows"
@@ -68,6 +66,9 @@
 	endif(USE_DBUS_IDENTIFIER)  
 	set(main_lib_dest "lib/${PROJECT_NAME}")  
 else(UNIX)
+	IF(NOT OPENSSL_FOUND)
+		MESSAGE(STATUS "Openssl not found, configuring the library without it (running in wine not supported).")
+	ENDIF(NOT OPENSSL_FOUND)
 	if(MSVC)
 		include(target_arch)
 		target_architecture( TARGET_ARCHITECTURE )
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index cf74297..df84870 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,7 +4,7 @@
 
 The following is a set of guidelines for contributing to Open License Manager and its packages, which are hosted in the [Open License Manager organization](https://github.com/open-license-manager) on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
 
-## How Can I Contribute?
+## How to Contribute
 
 ### Reporting Bugs
 
@@ -12,30 +12,30 @@
 
 Before creating bug reports, please [check the repository](https://github.com/open-license-manager/open-license-manager/issues) to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). 
 
-#### How Do I Submit A (Good) Bug Report?
+#### How to Submit A (Good) Bug Report
 
 Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). Explain the problem and include additional details to help maintainers reproduce the problem:
 
-* **Use a clear and descriptive title** for the issue to identify the problem.
-* **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how are you using Open License Manager. 
-* **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or licenses, which can cause the bug. If you're providing code snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). 
-* **Provide a unit test to demonstrate the bug**. The best way to report a bug, and to have it fixed **forever** is to design a test to demonstrate it. 
-* **If you're reporting that Open License Manager crashed**, include a crash dump and the associated message. 
-* **Label the issue as bug.**
+*  **Use a clear and descriptive title** for the issue to identify the problem.
+*  **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how are you using Open License Manager. 
+*  **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or licenses, which can cause the bug. If you're providing code snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). 
+*  **Provide a unit test to demonstrate the bug**. The best way to report a bug, and to have it fixed **forever** is to design a test to demonstrate it. 
+*  **If you're reporting that Open License Manager crashed**, include a crash dump and the associated message. 
+*  **Label the issue as bug.**
 
 Provide more context by answering these questions:
 
-* **Can you reproduce the problem using the example application?**
-* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens.
-* If the problem is related integrating Open License Manager with your application, **produce a minimal example to demonstrate it** Does the problem happen only with some license type? Does the problem only happen in Linux/Docker/Windows?
+*  **Can you reproduce the problem using the example application?**
+*  **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens.
+*  If the problem is related integrating Open License Manager with your application, **produce a minimal example to demonstrate it** Does the problem happen only with some license type? Does the problem only happen in Linux/Docker/Windows?
 
 Include details about your configuration and environment:
 
-* **Update Open License Manager to the latest version** If possible try to pull the latest changes from `develop` branch.
-* **What's the name and version of the OS you're using**?
-* **What's the name and version of the compiler you're using**? Are you cross compiling? If you're cross compiling specify the host and the target operating system.
-* **What's are the `cmake` command line you used to generate your build scripts**? 
-* **Are you running Open License Manager in a virtual machine/docker?** If so, which VM software are you using and which operating systems and versions are used for the guest?
+*  **Update Open License Manager to the latest version** If possible try to pull the latest changes from `develop` branch.
+*  **What's the name and version of the OS you're using**?
+*  **What's the name and version of the compiler you're using**? Are you cross compiling? If you're cross compiling specify the host and the target operating system.
+*  **What's are the `cmake` command line you used to generate your build scripts**? 
+*  **Are you running Open License Manager in a virtual machine/docker?** If so, which VM software are you using and which operating systems and versions are used for the guest?
 
 ### Suggesting Enhancements
 
@@ -45,20 +45,20 @@
 
 Please also check for the [current and planned features](https://github.com/open-license-manager/open-license-manager/wiki/features) in the wiki to see where the project is heading to.
 
-#### How Do I Submit A (Good) Enhancement Suggestion?
+#### How to submit a (Good) enhancement suggestion
 
 Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). 
 
-* **Use a clear and descriptive title** for the issue to identify the suggestion.
-* **Provide a detailed description of the suggested enhancement** in as many details as possible.
-* **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets of code which we could use, or reference to other libraries, algorithms, open source code.
-* **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
-* **Explain why this enhancement would be useful** to most Open License Manager users and isn't something that can or should be implemented.
-* **List some other software protection where this enhancement exists.**
-* **Specify the name and version of the OS you're proposing the enhancement for.** If applicable include all the environment informations: is this for running the application in a VM? in a Docker?
-* **Label the issue as enhancement.**
+*  **Use a clear and descriptive title** for the issue to identify the suggestion.
+*  **Provide a detailed description of the suggested enhancement** in as many details as possible.
+*  **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets of code which we could use, or reference to other libraries, algorithms, open source code.
+*  **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
+*  **Explain why this enhancement would be useful** to most Open License Manager users and isn't something that can or should be implemented.
+*  **List some other software protection where this enhancement exists.**
+*  **Specify the name and version of the OS you're proposing the enhancement for.** If applicable include all the environment informations: is this for running the application in a VM? in a Docker?
+*  **Label the issue as enhancement.**
 
-### Your First Code Contribution
+### Your first code contribution
 
 Unsure where to begin contributing to Open License Manager? You can start by looking through the [`good first issue`](https://github.com/open-license-manager/open-license-manager/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and [`help-wanted`](https://github.com/open-license-manager/open-license-manager/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) issues. 
 
@@ -72,16 +72,16 @@
 
 Supposing you already know how to contribute to an open source project on GitHub (if you have doubts you can check this short [guide](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) ), you're working on an existing issue the code is already committed on your fork. 
 
-* Ensure your feature branch is up to date with the `develop`, eventually merge the latest changes from the `develop` branch. This will help us save time.
-* Reformat the changed code using "clang-format" to keep consistent formatting style. The style we use is in `.clang-format` at the base of the project.
-* Prepare your pull request, in the pull request comment reference the issue the pull request will fix.
-* Check your pull request compiles and pass the checks on Travis CI
-* In the pull request comment reference the issue you want to fix.
+*  Ensure your feature branch is up to date with the `develop`, eventually merge the latest changes from the `develop` branch. This will help us save time.
+*  Reformat the changed code using "clang-format" to keep consistent formatting style. The style we use is in `.clang-format` at the base of the project.
+*  Prepare your pull request, in the pull request comment reference the issue the pull request will fix.
+*  Check your pull request compiles and pass the checks on Travis CI
+*  In the pull request comment reference the issue you want to fix.
 
 ##### Don't
-* Don't reformat the code following your personal likes, it introduce a lot of "noise" and makes very hard to merge. Use the clang-format style provided at the base of the project.
-* Very large pull requests with few comments, no corresponding issue explaining what's it about will probably be rejected.
-    * We understand that the project is still in a very alpha stage, however we would like to discuss it with you before we take project changing decision. Please contact the project maintainer at `contini.mailing[AT]gmail.com` if you have time and plan to do a large contribution.
-    * Even it it's in alpha stage it's used ( _by some really courageous people!_ ) in production. We can't break current functionality, user established habits without documenting the change.
+*  Don't reformat the code following your personal likes, it introduce a lot of "noise" and makes very hard to merge. Use the clang-format style provided at the base of the project.
+*  Very large pull requests with few comments, no corresponding issue explaining what's it about will probably be rejected.
+    *  We understand that the project is still in beta stage, however we would like to discuss it with you before we take project changing decision. Please contact the project maintainer at `contini.mailing[AT]gmail.com` if you have time and plan to do a large contribution.
+    *  Even it it's in beta stage it's used ( _by some really courageous people!_ ) in production. We can't break current functionality, user established habits without documenting the change.
 
   
\ No newline at end of file
diff --git a/README.md b/README.md
index c6d077b..7041566 100644
--- a/README.md
+++ b/README.md
@@ -20,22 +20,22 @@
 
 ## Project Structure
 The software is made by 2 main sub-components:
-* a C++ library with a nice C api, `licensecc` with minimal (or no) external dependencies (the part you have to integrate in your software) that is the project you're currently in.
-* a license generator lcc-license-generator `lcc` for customizing the library and generate the licenses.
+*  a C++ library with a nice C api, `licensecc` with minimal (or no) external dependencies (the part you have to integrate in your software) that is the project you're currently in.
+*  a license generator lcc-license-generator `lcc` for customizing the library and generate the licenses.
  
 The following modules are planned...
-* a license [backoffice](../../issues/7) in php (in order to handle multiple licenses).
-* a license debugger to be sent to the final customer when there are licensing problems. 
-* a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system.
+*  a license [backoffice](../../issues/7) in php (in order to handle multiple licenses).
+*  a license debugger to be sent to the final customer when there are licensing problems. 
+*  a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system.
 
 # How to build
 Below an overview of the basic build procedure, you can find detailed instructions for [linux](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) or [windows](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library-win) in the wiki. 
 
 ## prerequisites
-* Operating system: Linux(Ubuntu, CentOS), Windows
-* compilers       : GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) 
-* tools           : cmake(>3.6), git, make/ninja(linux)
-* libs            : If target is linux Openssl is required. Windows depends only on system libraries. Boost is necessary to build license generator and to run the tests but it's NOT a dependency of the final `licensecc` library. 
+*  Operating system: Linux(Ubuntu, CentOS), Windows
+*  compilers       : GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) 
+*  tools           : cmake(>3.6), git, make/ninja(linux)
+*  libs            : If target is Linux Openssl is required. Windows depends only on system libraries. Boost is necessary to build license generator and to run the tests but it's NOT a dependency of the final `licensecc` library. 
 
 For a complete list of dependencies and supported environments see [the wiki](https://github.com/open-license-manager/open-license-manager/wiki/Dependencies)
 
@@ -100,5 +100,5 @@
 ```
 
 # 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)
+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](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. 
diff --git a/cmake/Findlcc.cmake b/cmake/Findlcc.cmake
index 27f63b8..bc994eb 100644
--- a/cmake/Findlcc.cmake
+++ b/cmake/Findlcc.cmake
@@ -67,7 +67,7 @@
 		    if(GIT_SUBMODULE)
 		        message(STATUS "Submodule update")
 		        execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
-		                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+		                        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 		                        RESULT_VARIABLE GIT_SUBMOD_RESULT)
 		        if(NOT GIT_SUBMOD_RESULT EQUAL "0")
 		            set(failure_messge  "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
diff --git a/include/licensecc/datatypes.h b/include/licensecc/datatypes.h
index c5d6bc5..7a95afb 100644
--- a/include/licensecc/datatypes.h
+++ b/include/licensecc/datatypes.h
@@ -23,7 +23,7 @@
 #endif
 
 // define api structure sizes
-#define PC_IDENTIFIER_SIZE 18
+#define PC_IDENTIFIER_SIZE 19
 #define PROPRIETARY_DATA_SIZE 16
 #define AUDIT_EVENT_NUM 5
 
diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt
index d3a4388..a9f75d8 100644
--- a/src/library/CMakeLists.txt
+++ b/src/library/CMakeLists.txt
@@ -18,7 +18,7 @@
 	target_link_libraries(licensecc_static PUBLIC base OpenSSL::Crypto ${EXTERNAL_LIBS} ${CMAKE_DL_LIBS})
 ELSE(UNIX OR OPENSSL_FOUND)
 	set_target_properties(licensecc_static PROPERTIES WITH_OPENSSL 0)
-	target_link_libraries(licensecc_static ${EXTERNAL_LIBS})
+	target_link_libraries(licensecc_static PUBLIC base ${EXTERNAL_LIBS})
 ENDIF(UNIX OR OPENSSL_FOUND)
 
 target_include_directories(licensecc_static
diff --git a/src/library/os/CMakeLists.txt b/src/library/os/CMakeLists.txt
index 1e3bc46..e9e74df 100644
--- a/src/library/os/CMakeLists.txt
+++ b/src/library/os/CMakeLists.txt
@@ -5,11 +5,12 @@
 		    ${CMAKE_CURRENT_SOURCE_DIR}/os-linux.c 
 		    ${CMAKE_CURRENT_SOURCE_DIR}/network_id.c)
 	ELSE(UNIX)
-  	    target_sources(licensecc_static PRIVATE 
+  	    target_sources(licensecc_static PRIVATE
+		    ${CMAKE_CURRENT_SOURCE_DIR}/openssl/signature_verifier.cpp
   	    	${CMAKE_CURRENT_SOURCE_DIR}/os-win.c)
 	ENDIF(UNIX)
 ELSE(UNIX OR OPENSSL_FOUND)
-    target_sources(licensecc_static STATIC
+    target_sources(licensecc_static PRIVATE
         ${CMAKE_CURRENT_SOURCE_DIR}/windows/signature_verifier.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/os-win.c)
 ENDIF(UNIX OR OPENSSL_FOUND)
diff --git a/src/library/os/windows/signature_verifier.cpp b/src/library/os/windows/signature_verifier.cpp
index 88194a2..677e698 100644
--- a/src/library/os/windows/signature_verifier.cpp
+++ b/src/library/os/windows/signature_verifier.cpp
@@ -43,13 +43,6 @@
 } PUBKEY_BLOB, *P_PUBKEY_BLOB;
 #pragma pack(pop)
 
-static BCRYPT_ALG_HANDLE openSignatureProvider() {
-	DWORD status;
-	BCRYPT_ALG_HANDLE hSignAlg = nullptr;
-
-	return hSignAlg;
-}
-
 static BCRYPT_ALG_HANDLE openHashProvider() {
 	DWORD status;
 	BCRYPT_ALG_HANDLE hHashAlg = nullptr;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ca37f3d..ec61aef 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -8,16 +8,10 @@
 	"${CMAKE_CURRENT_SOURCE_DIR}/../src/templates/licensecc_properties_test.h.in" 
 	"${CMAKE_BINARY_DIR}/licensecc_properties_test.h.tmp"
 )
-IF(${CMAKE_VERSION} VERSION_GREATER  3.0)
-	file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/include/$<CONFIG>/licensecc_properties_test.h" 
+file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/include/$<CONFIG>/licensecc_properties_test.h" 
 		INPUT "${CMAKE_BINARY_DIR}/licensecc_properties_test.h.tmp")
-	include_directories ( ${CMAKE_BINARY_DIR}/include/$<CONFIG> )
-ELSE(${CMAKE_VERSION} VERSION_GREATER  3.0)
-#patch for Centos 7 cmake 2.8.11 :(
-	file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/include/$<CONFIGURATION>/licensecc_properties_test.h" 
-		INPUT "${CMAKE_BINARY_DIR}/licensecc_properties_test.h.tmp")
-	include_directories ( ${CMAKE_BINARY_DIR}/include/$<CONFIGURATION> )
-endif(${CMAKE_VERSION} VERSION_GREATER  3.0)
+include_directories ( ${CMAKE_BINARY_DIR}/include/$<CONFIG> )
+
 
 add_subdirectory(library)
 add_subdirectory(functional)
\ No newline at end of file

--
Gitblit v1.9.1