Skip to content

Commit

Permalink
MINIFICPP-883: Add windows build script
Browse files Browse the repository at this point in the history
MINIFICPP-883: change appveyor to use winbuild

MINIFICPP-833: remove Win64 req

MINIFICPP-883: Minor update to move to new image

MINIFICPP-796: Enable tests

MINIFICPP-796: Update path creator

MINIFICPP-796: Minor update

MINIFICPP-796: more adjustments

MINIFICPP-796: Updates to tests and cmake

MINIFICPP-769: Fix inclusion of minifi

MINIFICPP-796: remove nanofi

MINIFICPP-796: Remove test

MINIFICPP-796: Updates

Update SecureSocketGetTCPTest.cpp

Update appveyor.yml

Update appveyor.yml

Update appveyor.yml

Update CMakeLists.txt

Approved on GH by apiri.

This closes #595.

Signed-off-by: Marc Parisi <phrocker@apache.org>
  • Loading branch information
phrocker committed Aug 16, 2019
1 parent 471b5cb commit a6876db
Show file tree
Hide file tree
Showing 142 changed files with 2,839 additions and 1,358 deletions.
139 changes: 84 additions & 55 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,51 @@ include(FeatureSummary)
include(ExternalProject)

option(SKIP_TESTS "Skips building all tests." OFF)

option(PORTABLE "Instructs the compiler to remove architecture specific optimizations" ON)

option(USE_SHARED_LIBS "Builds using shared libraries" ON)

option(ENABLE_PYTHON "Instructs the build system to enable building shared objects for the python lib" OFF)

cmake_dependent_option(STATIC_BUILD "Attempts to statically link as many dependencies as possible." ON "NOT ENABLE_PYTHON; NOT USE_SHARED_LIBS" OFF)

cmake_dependent_option(STATIC_BUILD "Attempts to statically link as many dependencies as possible." ON "NOT ENABLE_PYTHON; NOT USE_SHARED_LIBS" OFF)
cmake_dependent_option(USE_SYSTEM_OPENSSL "Instructs the build system to search for and use an SSL library available in the host system" ON "NOT STATIC_BUILD" OFF)
option(LIBC_STATIC "Instructs the build system to statically link libstdc++ and glibc into minifiexe. Experiemental" OFF)

option(OPENSSL_OFF "Disables OpenSSL" OFF)
option(ENABLE_OPS "Enable Operations/zlib Tools" ON)
option(USE_SYSTEM_UUID "Instructs the build system to search for and use a UUID library available in the host system" OFF)

option(ENABLE_JNI "Instructs the build system to enable the JNI extension" OFF)
option(ENABLE_OPENCV "Instructs the build system to enable the OpenCV extension" OFF)
cmake_dependent_option(USE_SYSTEM_CURL "Instructs the build system to search for and use a cURL library available in the host system" ON "NOT STATIC_BUILD" OFF)
option(BUILD_SHARED_LIBS "Build yaml cpp shared lib" OFF)

cmake_dependent_option(USE_SYSTEM_ZLIB "Instructs the build system to search for and use a zlib library available in the host system" ON "NOT STATIC_BUILD" OFF)

cmake_dependent_option(USE_SYSTEM_LIBSSH2 "Instructs the build system to search for and use a libssh2 library available in the host system" OFF "NOT STATIC_BUILD" OFF)

option(USE_SYSTEM_BZIP2 "Instructs the build system to search for and use a bzip2 library available in the host system" ON)
option(BUILD_ROCKSDB "Instructs the build system to use RocksDB from the third party directory" ON)
option(FORCE_WINDOWS "Instructs the build system to force Windows builds when WIN32 is specified" OFF)
option(DISABLE_CURL "Disables libCurl Properties." OFF)

option(USE_GOLD_LINKER "Use Gold Linker" OFF)

if (OPENSSL_ROOT_DIR )
set(OPENSSL_PASSTHROUGH "-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}")
endif()

set(PASSTHROUGH_CMAKE_ARGS -DANDROID_ABI=${ANDROID_ABI}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_STL=${ANDROID_STL}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DANDROID_NDK=${ANDROID_NDK}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=${CMAKE_FIND_ROOT_PATH_MODE_PROGRAM}
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY}
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=${CMAKE_FIND_ROOT_PATH_MODE_INCLUDE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
${OPENSSL_PASSTHROUGH}
-G${CMAKE_GENERATOR})

if(NOT WIN32)
if (ENABLE_JNI)
if (NOT DISABLE_JEMALLOC)
Expand Down Expand Up @@ -130,6 +143,8 @@ endif()
include(CheckCXXCompilerFlag)
if (WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_options("/W1")
if ((MSVC_VERSION GREATER "1900") OR (MSVC_VERSION EQUAL "1900"))
CHECK_CXX_COMPILER_FLAG("/std:c++14" _cpp_latest_flag_supported)
if (_cpp_latest_flag_supported)
Expand All @@ -150,7 +165,7 @@ endif()
endif()

if (WIN32)
add_definitions(-DSERVICE_NAME="MiNiFi")
add_definitions(-DSERVICE_NAME="Apache NiFi MINiFi")
endif()

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
Expand Down Expand Up @@ -178,6 +193,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

if (NOT OPENSSL_OFF)
if(USE_SYSTEM_OPENSSL)

# Set the right openssl root path
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl/")
Expand All @@ -188,8 +204,8 @@ if (NOT OPENSSL_OFF)
endif()
else()
include(LibreSSL)
use_libre_ssl(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/ssl")
use_libre_ssl("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ssl")
endif()

find_package (OpenSSL REQUIRED)
Expand Down Expand Up @@ -267,8 +283,8 @@ endif(DISABLE_CURL)
if(NOT DISABLE_CURL AND (NOT USE_SYSTEM_CURL))
message("Using bundled cURL")

set(CURL_C_FLAGS "-I${OPENSSL_INCLUDE_DIR}")
set(CURL_CXX_FLAGS "${CURL_C_FLAGS}")
set(CURL_C_FLAGS "${CMAKE_C_FLAGS}")
set(CURL_CXX_FLAGS "${CMAKE_CXX_FLAGS}")


get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
Expand All @@ -280,13 +296,9 @@ else()
endif()

if (WIN32)
if (CMAKE_BUILD_TYPE MATCHES RelWithDebInfo OR CMAKE_BUILD_TYPE MATCHES Release)
set(BYPRODUCT "lib/libcurl.lib")
else()
set(BYPRODUCT "lib/libcurl-d.lib")
endif()
set(BYPRODUCT "lib/libcurl.lib")
else()
set(BYPRODUCT "lib${LIBSUFFIX}/libcurl.a")
set(BYPRODUCT "lib${LIBSUFFIX}/libcurl.a")
endif()

if (WIN32)
Expand All @@ -305,10 +317,11 @@ endif()
-DBUILD_TESTING=OFF
-DBUILD_SHARED_LIBS=OFF
-DHTTP_ONLY=ON
-DLIBRESSL_BIN_DIR=${LIBRESSL_BIN_DIR}
-DLIBRESSL_SRC_DIR=${LIBRESSL_SRC_DIR}
"-DLIBRESSL_BIN_DIR=${LIBRESSL_BIN_DIR}"
"-DLIBRESSL_SRC_DIR=${LIBRESSL_SRC_DIR}"
-DCURL_DISABLE_CRYPTO_AUTH=ON
-DCMAKE_USE_LIBSSH2=OFF
"-DCMAKE_DEBUG_POSTFIX="
-DHAVE_GLIBC_STRERROR_R=1
-DHAVE_GLIBC_STRERROR_R__TRYRUN_OUTPUT=""
-DHAVE_POSIX_STRERROR_R=0
Expand All @@ -318,6 +331,7 @@ endif()
-DHAVE_FSETXATTR_5__TRYRUN_OUTPUT=""
"-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/cmake/ssl"
"-DCMAKE_C_FLAGS=${CURL_C_FLAGS}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_CXX_FLAGS=${CURL_CXX_FLAGS}"
${PC}
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/curl-install/${BYPRODUCT}"
Expand All @@ -330,13 +344,10 @@ endif()
set(CURL_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/" CACHE STRING "" FORCE)
set(CURL_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/curl-install/" CACHE STRING "" FORCE)
set(CURL_BYPRODUCT_DIR "${BYPRODUCT}" CACHE STRING "" FORCE)


list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/curl/dummy")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/curl/dummy")
add_library(curl STATIC IMPORTED)
set_target_properties(curl PROPERTIES IMPORTED_LOCATION "${CURL_BIN_DIR}${BYPRODUCT}")



if (OPENSSL_FOUND)
if (NOT WIN32)
set_target_properties(curl PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBRARIES})
Expand All @@ -346,7 +357,7 @@ endif()
set(CURL_FOUND "YES")
set(CURL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/include")
set(CURL_LIBRARY "${CURL_BIN_DIR}${BYPRODUCT}" CACHE STRING "" FORCE)
set(CURL_LIBRARIES ${CURL_LIBRARY} CACHE STRING "" FORCE)
set(CURL_LIBRARIES "${CURL_LIBRARY}" CACHE STRING "" FORCE)
else()
message("Using System cURL")
endif()
Expand Down Expand Up @@ -385,33 +396,21 @@ include_directories(thirdparty/yaml-cpp-yaml-cpp-20171024/include)
include_directories(thirdparty/rapidjson-1.1.0/include)

## Expression language extensions
option(DISABLE_EXPRESSION_LANGUAGE "Disables the scripting extensions." OFF)
include_directories("extensions/expression-language/common")
if (DISABLE_EXPRESSION_LANGUAGE)
# Build expression language NoOp implementation, if necessary
include_directories("extensions/expression-language/noop")
add_subdirectory(extensions/expression-language/noop)
else()
include_directories("extensions/expression-language/impl")
createExtension(EXPRESSION-LANGUAGE-EXTENSIONS "EXPRESSION LANGUAGE EXTENSIONS" "This enables NiFi expression language" "extensions/expression-language" "${TEST_DIR}/expression-language-tests")
if(NOT USE_SYSTEM_CURL)
message("minifi-expression-language-extensions will depend on curl-external")
add_dependencies(minifi-expression-language-extensions curl-external)
endif()
endif()

if(BOOTSTRAP)
# display an error message for those using the bootstrap
message(FATAL_ERROR "Bootstrapping is no longer needed within the agent")
endif()


add_subdirectory(libminifi)

if(NOT USE_SYSTEM_OPENSSL OR USE_SYSTEM_OPENSSL STREQUAL "OFF")
add_dependencies(minifi libressl-portable)
endif()

if(NOT USE_SYSTEM_CURL)
add_dependencies(minifi curl-external)
endif()

if (WIN32 OR NOT USE_SYSTEM_ZLIB)
add_dependencies(minifi zlib-external)
endif(WIN32 OR NOT USE_SYSTEM_ZLIB)
Expand All @@ -428,9 +427,23 @@ if ((DISABLE_CURL STREQUAL "OFF" OR NOT DISABLE_CURL) AND NOT DISABLE_CIVET)
endif()
endif()

option(DISABLE_EXPRESSION_LANGUAGE "Disables the scripting extensions." OFF)
if (NOT DISABLE_EXPRESSION_LANGUAGE)
createExtension(EXPRESSION-LANGUAGE-EXTENSIONS "EXPRESSION LANGUAGE EXTENSIONS" "This enables NiFi expression language" "extensions/expression-language" "extensions/expression-language/tests")
if(NOT USE_SYSTEM_OPENSSL OR USE_SYSTEM_OPENSSL STREQUAL "OFF")
add_dependencies(minifi-expression-language-extensions libressl-portable)
endif()
if(NOT USE_SYSTEM_CURL)
message("minifi-expression-language-extensions will depend on curl-external")
add_dependencies(minifi-expression-language-extensions curl-external)
endif()
endif()



option(DISABLE_CIVET "Disables CivetWeb components." OFF)
if (NOT DISABLE_CIVET)
createExtension(CIVETWEB CIVETWEB "This enables ListenHTTP" "extensions/civetweb" "${TEST_DIR}/civetweb-tests")
createExtension(CIVETWEB CIVETWEB "This enables ListenHTTP" "extensions/civetweb")
endif()

## Add the rocks DB extension
Expand Down Expand Up @@ -468,7 +481,7 @@ endif()
if (WIN32)
option(ENABLE_WEL "Enables the suite of Windows Event Log extensions." OFF)
if (ENABLE_ALL OR ENABLE_WEL)
createExtension(WEL-EXTENSION "WEL EXTENSIONS" "Enables the suite of Windows Event Log extensions." "extensions/windows-event-log" "${TEST_DIR}/windows-event-log-tests")
createExtension(WEL-EXTENSION "WEL EXTENSIONS" "Enables the suite of Windows Event Log extensions." "extensions/windows-event-log" "extensions/windows-event-log/tests")
endif()
endif(WIN32)

Expand Down Expand Up @@ -537,6 +550,7 @@ if (ENABLE_OPENCV)
createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enabled OpenCV support" "extensions/opencv" "extensions/opencv/tests")
endif()


## Bustache/template extensions
option(ENABLE_BUSTACHE "Enables Bustache (ApplyTemplate) support." OFF)
if (ENABLE_BUSTACHE)
Expand Down Expand Up @@ -571,6 +585,7 @@ if ((ENABLE_ALL OR ENABLE_SFTP) AND NOT DISABLE_CURL)
endif()
endif()


## NOW WE CAN ADD LIBRARIES AND EXTENSIONS TO MAIN

add_subdirectory(main)
Expand Down Expand Up @@ -643,7 +658,14 @@ set(CPACK_ALL_INSTALL_TYPES Full Developer)
set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
set(CPACK_WIX_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/msi/WixWin64.wsi")
set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/msi/minifi-logo-png-banner.png")
set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/msi/bgr.png")

file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conf/")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/README.md" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/NOTICE" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
set(CPACK_WIX_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/msi/WixWin.wsi")
else()
set(CPACK_SOURCE_GENERATOR "TGZ")
endif(WIN32)
Expand All @@ -659,9 +681,11 @@ install(DIRECTORY extensions/pythonprocessors/
DESTINATION minifi-python
COMPONENT bin)

if (NOT WIN32)
install(PROGRAMS bin/minifi.sh
DESTINATION bin
COMPONENT bin)
endif()

install(FILES LICENSE README.md NOTICE
DESTINATION .
Expand All @@ -672,19 +696,22 @@ if(WIN32)
#but that leaves the onus up to the developer, so until we can automate some of that build let's enforce
#the exe here temporarily
#TODO: Remove this and automate this step.
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/main/minifi.exe
DESTINATION bin
COMPONENT bin)
#install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/main/minifi.exe
#DESTINATION bin
#COMPONENT bin)
else()
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/main/minifi
DESTINATION bin
COMPONENT bin)

endif()

endif()

if (WIN32)
set(CPACK_GENERATOR "WIX")

set(CPACK_WIX_UPGRADE_GUID, "FE29F801-3486-4E9E-AFF9-838C1A5C8D59")
set(CPACK_WIX_PRODUCT_ICON,"${CMAKE_CURRENT_SOURCE_DIR}/msi/minifi-logo-ico.ico")
else()
set(CPACK_GENERATOR "TGZ")
endif()
Expand All @@ -697,11 +724,13 @@ set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/msi/LICENSE.txt")
set(CPACK_PACKAGE_FILE_NAME "${ASSEMBLY_BASE_NAME}")
if(NOT WIN32)
set(CPACK_PACKAGE_FILE_NAME "${ASSEMBLY_BASE_NAME}")
set(CPACK_GENERATOR "TGZ")
set(CPACK_BINARY_TGZ, "ON")
endif()
set(CPACK_PACKAGE_FILE_NAME "minifi-agent-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ApacheNiFiMiNiFi/${CMAKE_PROJECT_NAME}")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_RDKAFKA_COMPONENT_INSTALL ON)
set(CPACK_MQTT_COMPONENT_INSTALL ON)
Expand Down

0 comments on commit a6876db

Please sign in to comment.