|
| 1 | +################################################################################ |
| 2 | +# |
| 3 | +# Project: openCONFIGURATOR |
| 4 | +# |
| 5 | +# (c) Bernecker + Rainer Industrie-Elektronik Ges.m.b.H. |
| 6 | +# B&R Strasse 1, A-5142 Eggelsberg |
| 7 | +# www.br-automation.com |
| 8 | +# |
| 9 | +# Description: Main CMAKE file of openCONFIGURATOR library |
| 10 | +# |
| 11 | +# License: |
| 12 | +# |
| 13 | +# Redistribution and use in source and binary forms, with or without |
| 14 | +# modification, are permitted provided that the following conditions |
| 15 | +# are met: |
| 16 | +# |
| 17 | +# 1. Redistributions of source code must retain the above copyright |
| 18 | +# notice, this list of conditions and the following disclaimer. |
| 19 | +# |
| 20 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 21 | +# notice, this list of conditions and the following disclaimer in the |
| 22 | +# documentation and/or other materials provided with the distribution. |
| 23 | +# |
| 24 | +# 3. Neither the name of the copyright holders nor the names of its |
| 25 | +# contributors may be used to endorse or promote products derived |
| 26 | +# from this software without prior written permission. For written |
| 27 | +# permission, please contact [email protected]. |
| 28 | +# |
| 29 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 30 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 31 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 32 | +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 33 | +# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 34 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 35 | +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 36 | +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 37 | +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 38 | +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 39 | +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 40 | +# POSSIBILITY OF SUCH DAMAGE. |
| 41 | +# |
| 42 | +# Severability Clause: |
| 43 | +# |
| 44 | +# If a provision of this License is or becomes illegal, invalid or |
| 45 | +# unenforceable in any jurisdiction, that shall not affect: |
| 46 | +# 1. the validity or enforceability in that jurisdiction of any other |
| 47 | +# provision of this License; or |
| 48 | +# 2. the validity or enforceability in other jurisdictions of that or |
| 49 | +# any other provision of this License. |
| 50 | +# |
| 51 | +################################################################################ |
| 52 | +# Ensure working support of ADD_JAR command |
| 53 | +CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12) |
| 54 | + |
| 55 | +INCLUDE(CMakeDependentOption) |
| 56 | + |
| 57 | +PROJECT (OPEN_CONFIGURATOR) |
| 58 | +############################################################################### |
| 59 | +# Compiler flags for MS Visual Studio |
| 60 | +############################################################################### |
| 61 | +IF(MSVC) |
| 62 | + SET(CMAKE_CXX_FLAGS "/wd\"4512\" /wd\"4251\" /Zi /nologo /W4 /WX- /Od /Oy- /Ob0 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /Gm- /EHsc /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /errorReport:queue /GR") |
| 63 | + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") |
| 64 | + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /DDEBUG") |
| 65 | + STRING(FIND "${CMAKE_GENERATOR}" "Win64" FOUND) |
| 66 | + IF(${FOUND} EQUAL -1) |
| 67 | + SET(INSTALL_DIR "${CMAKE_SOURCE_DIR}/bin/win32/x86/\${BUILD_TYPE}") |
| 68 | + SET(INSTALL_DIR_VS "${CMAKE_SOURCE_DIR}/bin/win32/x86/$(Configuration)") |
| 69 | + ELSE() |
| 70 | + SET(INSTALL_DIR "${CMAKE_SOURCE_DIR}/bin/win32/x86_64/\${BUILD_TYPE}") |
| 71 | + SET(INSTALL_DIR_VS "${CMAKE_SOURCE_DIR}/bin/win32/x86_64/$(Configuration)") |
| 72 | + ENDIF() |
| 73 | +ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) |
| 74 | + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Weffc++ -std=c++11") |
| 75 | + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") |
| 76 | + IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") |
| 77 | + SET(INSTALL_DIR "${CMAKE_SOURCE_DIR}/bin/linux/x86_64") |
| 78 | + ELSE() |
| 79 | + SET(INSTALL_DIR "${CMAKE_SOURCE_DIR}/bin/linux/x86") |
| 80 | + ENDIF() |
| 81 | + IF(MINGW) |
| 82 | + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U__STRICT_ANSI__ -D__NO_INLINE__ -Wl,--kill-at") |
| 83 | + ENDIF(MINGW) |
| 84 | +ENDIF(MSVC) |
| 85 | +############################################################################### |
| 86 | +# Find BOOST libraries |
| 87 | +############################################################################### |
| 88 | +SET(Boost_DEBUG TRUE) |
| 89 | +SET(Boost_USE_STATIC_RUNTIME OFF) |
| 90 | +SET(Boost_ADDITIONAL_VERSIONS "1.54.0" "1.55.0") |
| 91 | +FIND_PACKAGE(Boost COMPONENTS log date_time filesystem system thread REQUIRED) |
| 92 | +# Necessary for Auto-Linking under VS, ignored under Unix |
| 93 | +ADD_DEFINITIONS(/DBOOST_ALL_DYN_LINK) |
| 94 | +IF(NOT Boost_FOUND) |
| 95 | + MESSAGE(SEND_ERROR "Boost libraries not found. Please add BOOST_ROOT environment variable to system.") |
| 96 | +ENDIF() |
| 97 | + |
| 98 | +############################################################################### |
| 99 | +# Set options |
| 100 | +############################################################################### |
| 101 | +OPTION (OPEN_CONFIGURATOR_CORE_NET_WRAPPER "Build openCONFIGURATOR core C# wrapper library." OFF) |
| 102 | +OPTION (OPEN_CONFIGURATOR_CORE_JAVA_WRAPPER "Build openCONFIGURATOR core Java wrapper library." OFF) |
| 103 | +OPTION (OPEN_CONFIGURATOR_CORE_UNIT_TESTS "Build openCONFIGURATOR core unit tests." OFF) |
| 104 | +OPTION (OPEN_CONFIGURATOR_CORE_DOCUMENTATION "Build openCONFIGURATOR core source code documentation." OFF) |
| 105 | + |
| 106 | +############################################################################### |
| 107 | +# Add a target to generate API documentation with Doxygen |
| 108 | +############################################################################### |
| 109 | +IF(OPEN_CONFIGURATOR_CORE_DOCUMENTATION) |
| 110 | + FIND_PACKAGE(Doxygen REQUIRED) |
| 111 | + IF(DOXYGEN_FOUND) |
| 112 | + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/resources/doc/openconfigurator_core.doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) |
| 113 | + ADD_CUSTOM_TARGET( |
| 114 | + DOCUMENTATION ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile |
| 115 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 116 | + COMMENT "Generating API documentation with Doxygen" VERBATIM |
| 117 | + ) |
| 118 | + ELSE(DOXYGEN_FOUND) |
| 119 | + MESSAGE(SEND_ERROR "Doxygen installation not found. Please install doxygen and add binary to system path.") |
| 120 | + ENDIF(DOXYGEN_FOUND) |
| 121 | +ENDIF() |
| 122 | + |
| 123 | +############################################################################### |
| 124 | +# Add a target to generate the openCONFIGURATOR library |
| 125 | +############################################################################### |
| 126 | +ADD_SUBDIRECTORY(library) |
| 127 | + |
| 128 | +############################################################################### |
| 129 | +# Add a target to generate .NET wrapper |
| 130 | +############################################################################### |
| 131 | +IF(OPEN_CONFIGURATOR_CORE_NET_WRAPPER) |
| 132 | +# ADD_SUBDIRECTORY(wrapper/csharp) |
| 133 | +ENDIF() |
| 134 | + |
| 135 | +############################################################################### |
| 136 | +# Add a target to generate Java wrapper |
| 137 | +############################################################################### |
| 138 | +IF(OPEN_CONFIGURATOR_CORE_JAVA_WRAPPER) |
| 139 | +# ADD_SUBDIRECTORY(wrapper/java) |
| 140 | +ENDIF() |
| 141 | + |
| 142 | +############################################################################### |
| 143 | +# Add a target to generate CPPUNIT tests |
| 144 | +############################################################################### |
| 145 | +IF(OPEN_CONFIGURATOR_CORE_UNIT_TESTS) |
| 146 | + ADD_SUBDIRECTORY(test) |
| 147 | +ENDIF() |
| 148 | + |
0 commit comments