You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/07/09 11:44:51 UTC

[plc4x] branch feature/s7-cpp updated: - Continued working on the c++ build -- Switched to Boost 3.14.0 in order to get boost 1.70.0 support

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/s7-cpp
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/feature/s7-cpp by this push:
     new 5436ac8  - Continued working on the c++ build -- Switched to Boost 3.14.0 in order to get boost 1.70.0 support
5436ac8 is described below

commit 5436ac8e2a792dfac5e4445afd73b2eb1eca69e4
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Jul 9 13:44:41 2019 +0200

    - Continued working on the c++ build
    -- Switched to Boost 3.14.0 in order to get boost 1.70.0 support
---
 plc4cpp/CMakeLists.txt                             |   7 +-
 plc4cpp/api/CMakeLists.txt                         |   6 +-
 plc4cpp/drivers/s7/CMakeLists.txt                  |   4 +-
 plc4cpp/examples/hello-world-plc4x/CMakeLists.txt  |   2 +-
 plc4cpp/pom.xml                                    | 265 ++++++++++++++++-----
 plc4cpp/protocols/driver-bases/base/CMakeLists.txt |   2 +-
 plc4cpp/utils/logger/CMakeLists.txt                |   2 +-
 plc4cpp/utils/systemconfig/CMakeLists.txt          |   6 +-
 8 files changed, 211 insertions(+), 83 deletions(-)

diff --git a/plc4cpp/CMakeLists.txt b/plc4cpp/CMakeLists.txt
index f880eea..cdc97ee 100644
--- a/plc4cpp/CMakeLists.txt
+++ b/plc4cpp/CMakeLists.txt
@@ -24,14 +24,13 @@ set(CMAKE_CXX_EXTENSIONS OFF)
 
 set(PLC4CPP_ROOT_DIR ${CMAKE_SOURCE_DIR})
 
-# Variable to help "find_package" find the root of boost.
-set(BOOST_ROOT "${PROJECT_SOURCE_DIR}/target/lib/boost/")
-set(BOOST_INCLUDEDIR "${PROJECT_SOURCE_DIR}/target/lib/boost/include/")
-set(BOOST_LIBRARYDIR "${PROJECT_SOURCE_DIR}/target/lib/boost/lib/")
+# Disable usage of Boost-CMake
+set(Boost_NO_BOOST_CMAKE ON)
 # Force CMake to use the boost version provided in BOOST_ROOT
 set(Boost_NO_SYSTEM_PATHS ON)
 set(Boost_USE_STATIC_LIBS ON)
 set(Boost_USE_MULTITHREADED ON)
+set(Boost_DEBUG ON)
 
 # Ensure the listed modules are found and environment variables for boost are set.
 find_package(Boost COMPONENTS thread date_time system regex log)
diff --git a/plc4cpp/api/CMakeLists.txt b/plc4cpp/api/CMakeLists.txt
index 6ba83c5..883940c 100644
--- a/plc4cpp/api/CMakeLists.txt
+++ b/plc4cpp/api/CMakeLists.txt
@@ -70,10 +70,6 @@ add_library(plc4cpp-api
         src/main/cpp/org/apache/plc4x/cpp/api/types/ValueTypeObject.cpp
         )
 
-#[[
-    Import the boost headers
-]]
-
-target_include_directories (plc4cpp-api PUBLIC ${BOOST_INCLUDEDIR})
+target_include_directories (plc4cpp-api PUBLIC ${Boost_INCLUDE_DIRS})
 target_include_directories (plc4cpp-api PUBLIC ../utils/logger/src/main/cpp)
 
diff --git a/plc4cpp/drivers/s7/CMakeLists.txt b/plc4cpp/drivers/s7/CMakeLists.txt
index 5f4727f..0873b16 100644
--- a/plc4cpp/drivers/s7/CMakeLists.txt
+++ b/plc4cpp/drivers/s7/CMakeLists.txt
@@ -27,9 +27,7 @@ add_library(plc4cpp-driver-s7 SHARED
         src/main/cpp/org/apache/plc4x/cpp/s7/S7PlcDriver.cpp
 		src/main/cpp/org/apache/plc4x/cpp/s7/connection/S7PlcConnection.cpp
             )
-#[[
-    Import the headers for boost and the plc4cpp-api module
-]]
+
 target_include_directories (plc4cpp-driver-s7 PUBLIC ${Boost_INCLUDE_DIRS})
 target_include_directories (plc4cpp-driver-s7 PUBLIC ../../api/src/main/cpp)
 target_include_directories (plc4cpp-driver-s7 PUBLIC ../../protocols/driver-bases/base/src/main/cpp)
diff --git a/plc4cpp/examples/hello-world-plc4x/CMakeLists.txt b/plc4cpp/examples/hello-world-plc4x/CMakeLists.txt
index f729b71..6e79849 100644
--- a/plc4cpp/examples/hello-world-plc4x/CMakeLists.txt
+++ b/plc4cpp/examples/hello-world-plc4x/CMakeLists.txt
@@ -31,7 +31,7 @@ add_executable(helloplc4x
 
 TARGET_LINK_LIBRARIES (helloplc4x ${Boost_LIBRARIES} plc4cpp-driver-s7 plc4cpp-utils-logger plc4cpp-api)
 
-target_include_directories (helloplc4x PUBLIC ${BOOST_INCLUDEDIR})
+target_include_directories (helloplc4x PUBLIC ${Boost_INCLUDE_DIRS})
 target_include_directories (helloplc4x PUBLIC ../../api/src/main/cpp)
 target_include_directories (helloplc4x PUBLIC ../../utils/logger/src/main/cpp)
 
diff --git a/plc4cpp/pom.xml b/plc4cpp/pom.xml
index 585c36e..4b17f69 100644
--- a/plc4cpp/pom.xml
+++ b/plc4cpp/pom.xml
@@ -38,11 +38,103 @@
     <sonar.language>c++</sonar.language>
   </properties-->
 
+  <!--
+    Notes:
+    - It turns out that the default version of CMake the cmake-maven-plugin uses is too
+    old to detect the recent boost version. So we need to manually download a newer version
+    and tell the plugin to use that instead.
+    - As downloading and building boost takes quite some time, we only do this, if no
+    target/lib/boost is found.
+  -->
+
   <properties>
-    <boost-includes.dir>${project.build.directory}/lib/boost/includes</boost-includes.dir>
+    <cmake-version>3.14.5</cmake-version>
   </properties>
 
   <profiles>
+    <!-- Profile for linux -->
+    <profile>
+      <id>unix</id>
+      <activation>
+        <os>
+          <family>unix</family>
+        </os>
+      </activation>
+      <properties>
+        <cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-Linux-x86_64.tar.gz</cmake.url>
+        <cmake.root-dir>${project.build.directory}/cmake-${cmake-version}-Linux-x86_64</cmake.root-dir>
+        <cmake.child-dir>bin/cmake</cmake.child-dir>
+      </properties>
+      <!-- Make the cmake executable executable -->
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>
+            <executions>
+              <execution>
+                <id>make-cmake-executable</id>
+                <phase>process-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <basedir>${cmake.root-dir}</basedir>
+                  <executable>chmod</executable>
+                  <arguments>
+                    <argument>+x</argument>
+                    <argument>${cmake.child-dir}</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <!-- Profile for mac -->
+    <profile>
+      <id>mac</id>
+      <activation>
+        <os>
+          <family>mac</family>
+        </os>
+      </activation>
+      <properties>
+        <cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-Darwin-x86_64.tar.gz</cmake.url>
+        <cmake.root-dir>${project.build.directory}/cmake-${cmake-version}-Darwin-x86_64</cmake.root-dir>
+        <cmake.child-dir>CMake.app/Contents/BIN/cmake</cmake.child-dir>
+      </properties>
+      <!-- Make the cmake executable executable -->
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>
+            <executions>
+              <execution>
+                <id>make-cmake-executable</id>
+                <phase>process-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <basedir>${cmake.root-dir}</basedir>
+                  <executable>chmod</executable>
+                  <arguments>
+                    <argument>+x</argument>
+                    <argument>${cmake.child-dir}</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <!-- profile for windows -->
     <profile>
       <id>windows</id>
       <activation>
@@ -51,9 +143,98 @@
         </os>
       </activation>
       <properties>
-        <boost-includes.dir>${project.build.directory}/lib/boost/includes/boost-${boost.version.underline-short}</boost-includes.dir>
+        <cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-win64-x64.zip</cmake.url>
+        <cmake.root-dir>${project.build.directory}/cmake-${cmake-version}-win64-x64</cmake.root-dir>
+        <cmake.child-dir>bin/cmake.exe</cmake.child-dir>
       </properties>
-   </profile>
+    </profile>
+    <!--
+      Build Boost, if it's not available yet.
+    -->
+    <profile>
+      <id>build-boost</id>
+      <activation>
+        <file>
+          <missing>target/lib/boost</missing>
+        </file>
+      </activation>
+      <build>
+        <plugins>
+          <!-- First download the sources for building the boost library -->
+          <plugin>
+            <groupId>com.googlecode.maven-download-plugin</groupId>
+            <artifactId>download-maven-plugin</artifactId>
+            <version>1.4.0</version>
+            <executions>
+              <execution>
+                <id>get-boost</id>
+                <phase>generate-sources</phase>
+                <goals>
+                  <goal>wget</goal>
+                </goals>
+                <configuration>
+                  <url>${boost.url}</url>
+                  <unpack>true</unpack>
+                  <outputDirectory>${project.build.directory}</outputDirectory>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <!--
+            Then execute two boost build phases:
+
+            1) bootstrap the boost build
+            2) Perform the actual boost build and install
+          -->
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>
+            <executions>
+              <execution>
+                <id>bootstrap-boost</id>
+                <phase>process-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <executable>${boost.bootstrap.executable}</executable>
+                  <arguments>
+                    <argument>gcc</argument>
+                  </arguments>
+                  <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
+                </configuration>
+              </execution>
+              <execution>
+                <id>compile-boost</id>
+                <phase>process-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <executable>${boost.build.executable}</executable>
+                  <arguments>
+                    <!-- Have the build install the built libraries -->
+                    <argument>install</argument>
+                    <!-- Tell it where to install the libraries and header files -->
+                    <argument>--prefix=${project.build.directory}/lib/boost</argument>
+                    <!-- List of modules to build -->
+                    <argument>--with-system</argument>
+                    <argument>--with-thread</argument>
+                    <argument>--with-date_time</argument>
+                    <argument>--with-regex</argument>
+                    <argument>--with-log</argument>
+                    <!-- On Windows machines the build failed, if this was not explicitly set -->
+                    <argument>address-model=64</argument>
+                  </arguments>
+                  <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
   </profiles>
 
   <build>
@@ -65,71 +246,19 @@
         <version>1.4.0</version>
         <executions>
           <execution>
-            <id>get-boost</id>
+            <id>get-cmake</id>
             <phase>generate-sources</phase>
             <goals>
               <goal>wget</goal>
             </goals>
             <configuration>
-              <url>${boost.url}</url>
+              <url>${cmake.url}</url>
               <unpack>true</unpack>
               <outputDirectory>${project.build.directory}</outputDirectory>
             </configuration>
           </execution>
         </executions>
       </plugin>
-      <!--
-        Then execute two boost build phases:
-
-        1) bootstrap the boost build
-        2) Perform the actual boost build and install
-      -->
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>exec-maven-plugin</artifactId>
-        <version>1.6.0</version>
-        <executions>
-          <execution>
-            <id>bootstrap</id>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-            <configuration>
-              <executable>${boost.bootstrap.executable}</executable>
-              <arguments>
-                <argument>gcc</argument>
-              </arguments>
-              <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
-            </configuration>
-          </execution>
-          <execution>
-            <id>compile</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-            <configuration>
-              <executable>${boost.build.executable}</executable>
-              <arguments>
-                <!-- Have the build install the built libraries -->
-                <argument>install</argument>
-                <!-- Tell it where to install the libraries and header files -->
-                <argument>--prefix=${project.build.directory}/lib/boost</argument>
-                <!-- List of modules to build -->
-                <argument>--with-system</argument>
-                <argument>--with-thread</argument>
-                <argument>--with-date_time</argument>
-                <argument>--with-regex</argument>
-                <argument>--with-log</argument>
-                <!-- On Windows machines the build failed, if this was not explicitly set -->
-                <argument>address-model=64</argument>
-              </arguments>
-              <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
 
       <plugin>
         <groupId>com.googlecode.cmake-maven-project</groupId>
@@ -145,6 +274,13 @@
             </goals>
             <configuration>
               <!--
+                We need to use a newer version of cmake, so disable downloading
+                and tell the plugin where to find that version.
+              -->
+              <downloadBinaries>false</downloadBinaries>
+              <cmakeRootDir>${cmake.root-dir}</cmakeRootDir>
+              <cmakeChildDir>${cmake.child-dir}</cmakeChildDir>
+              <!--
                 Actually the path to the CMakeList.txt file which then again
                 tells to tool where to find the sources.
               -->
@@ -165,9 +301,7 @@
               -->
               <classifier>${os.classifier}</classifier>
               <environmentVariables>
-                <BOOST_ROOT>${project.build.directory}/lib</BOOST_ROOT>
-                <BOOST_INCLUDEDIR>${boost-includes.dir}</BOOST_INCLUDEDIR>
-                <BOOST_LIBRARYDIR>${project.build.directory}/lib/boost/lib</BOOST_LIBRARYDIR>
+                <BOOST_ROOT>${project.build.directory}</BOOST_ROOT>
                 <Boost_NO_SYSTEM_PATHS>ON</Boost_NO_SYSTEM_PATHS>
               </environmentVariables>
             </configuration>
@@ -180,13 +314,18 @@
               <goal>compile</goal>
             </goals>
             <configuration>
+              <!--
+                We need to use a newer version of cmake, so disable downloading
+                and tell the plugin where to find that version.
+              -->
+              <downloadBinaries>false</downloadBinaries>
+              <cmakeRootDir>${cmake.root-dir}</cmakeRootDir>
+              <cmakeChildDir>${cmake.child-dir}</cmakeChildDir>
               <!-- The directory where the "generate" step generated the build configuration -->
               <projectDirectory>${project.build.directory}/build</projectDirectory>
               <classifier>${os.classifier}</classifier>
               <environmentVariables>
-                <BOOST_ROOT>${project.build.directory}/lib</BOOST_ROOT>
-                <BOOST_INCLUDEDIR>${boost-includes.dir}</BOOST_INCLUDEDIR>
-                <BOOST_LIBRARYDIR>${project.build.directory}/lib/boost/lib</BOOST_LIBRARYDIR>
+                <BOOST_ROOT>${project.build.directory}</BOOST_ROOT>
                 <Boost_NO_SYSTEM_PATHS>ON</Boost_NO_SYSTEM_PATHS>
               </environmentVariables>
             </configuration>
diff --git a/plc4cpp/protocols/driver-bases/base/CMakeLists.txt b/plc4cpp/protocols/driver-bases/base/CMakeLists.txt
index e4b141d..310ca0d 100644
--- a/plc4cpp/protocols/driver-bases/base/CMakeLists.txt
+++ b/plc4cpp/protocols/driver-bases/base/CMakeLists.txt
@@ -65,7 +65,7 @@ add_library(plc4cpp-protocols-driver-base-base
     Import the headers for boost and the plc4cpp-api module
 ]]
 
-target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ${BOOST_INCLUDEDIR})
+target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ${Boost_INCLUDE_DIRS})
 target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ../../../api/src/main/cpp)
 target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ../../../protocols/driver-bases/base/src/main/cpp)
 target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ../../../utils/logger/src/main/cpp)
diff --git a/plc4cpp/utils/logger/CMakeLists.txt b/plc4cpp/utils/logger/CMakeLists.txt
index bf18472..a43bb53 100644
--- a/plc4cpp/utils/logger/CMakeLists.txt
+++ b/plc4cpp/utils/logger/CMakeLists.txt
@@ -34,5 +34,5 @@ add_library(plc4cpp-utils-logger
 
 TARGET_LINK_LIBRARIES (plc4cpp-utils-logger ${Boost_LIBRARIES})
 
-target_include_directories (plc4cpp-utils-logger PUBLIC ${BOOST_INCLUDEDIR})
+target_include_directories (plc4cpp-utils-logger PUBLIC ${Boost_INCLUDE_DIRS})
 
diff --git a/plc4cpp/utils/systemconfig/CMakeLists.txt b/plc4cpp/utils/systemconfig/CMakeLists.txt
index 6e1e519..478ff39 100644
--- a/plc4cpp/utils/systemconfig/CMakeLists.txt
+++ b/plc4cpp/utils/systemconfig/CMakeLists.txt
@@ -26,8 +26,4 @@ add_library(plc4cpp-utils-systemconfig
 		src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.cpp
         )
 
-#[[
-    Import the headers for boost and the plc4cpp-utils module
-]]
-
-target_include_directories (plc4cpp-utils-systemconfig PUBLIC ${BOOST_INCLUDEDIR})
+target_include_directories (plc4cpp-utils-systemconfig PUBLIC ${Boost_INCLUDE_DIRS})