new gitlab ci for windows build
cmake- check if gtest is installed on build system validate compiler after setting of compiler paths
This commit is contained in:
parent
da53941cba
commit
fb65ef98fa
@ -1,45 +1,54 @@
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
|
||||
stages:
|
||||
- cmake
|
||||
- build
|
||||
- build_package
|
||||
- test
|
||||
- post
|
||||
|
||||
# Unix Build
|
||||
cmake:
|
||||
stage: cmake
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cmake -S . -B build
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- src/
|
||||
- inc/
|
||||
- tests/
|
||||
- postinst
|
||||
|
||||
cmake:
|
||||
stage: cmake
|
||||
script:
|
||||
- cmake -S . -B build
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cd build
|
||||
- make
|
||||
artifacts:
|
||||
paths:
|
||||
- "build/bin/*"
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
- postinst
|
||||
|
||||
|
||||
build_package:
|
||||
stage: build_package
|
||||
stage: post
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cd build
|
||||
- make package
|
||||
artifacts:
|
||||
paths:
|
||||
- "build/packages/*"
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
- postinst
|
||||
|
||||
test:
|
||||
stage: test
|
||||
stage: post
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cd build
|
||||
- make test
|
||||
@ -47,3 +56,48 @@ test:
|
||||
artifacts:
|
||||
reports:
|
||||
junit: build/report.xml
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
- postinst
|
||||
|
||||
# Windows Build
|
||||
cmake_win64:
|
||||
stage: cmake
|
||||
image: luki42/dynuiprefresher_build:windows
|
||||
script:
|
||||
- cmake -S . -B build -D WinBuild=ON
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
|
||||
build_win64:
|
||||
stage: build
|
||||
image: luki42/dynuiprefresher_build:windows
|
||||
script:
|
||||
- cd build
|
||||
- make iprefresher
|
||||
artifacts:
|
||||
paths:
|
||||
- "build/bin/*"
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
|
||||
|
||||
build_package_win64:
|
||||
stage: post
|
||||
image: luki42/dynuiprefresher_build:windows
|
||||
script:
|
||||
- cd build
|
||||
- make package
|
||||
artifacts:
|
||||
paths:
|
||||
- "build/packages/*"
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
@ -9,7 +9,7 @@
|
||||
# for test build gtest needs to be installed.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(iprefresher DESCRIPTION "Dynu ip refresher")
|
||||
project(iprefresher DESCRIPTION "Dynu ip refresher" LANGUAGES)
|
||||
SET(PROJECT_VERSION 1.3.3)
|
||||
|
||||
# CONFIGURATION
|
||||
@ -19,7 +19,7 @@ SET(LIB_METHOD STATIC) #SHARED / STATIC
|
||||
option(BUILD_DOC "Build documentation" ON) # additional dependency for Doxygen
|
||||
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
|
||||
option(TESTS "Build Tests" ON) # additional dependencies for GTEST - to build tests
|
||||
set(WinBuild false)
|
||||
option(WinBuild "cross compile for Windows Platform" OFF)
|
||||
|
||||
# helper variables
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
@ -31,6 +31,7 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
# setup winbuild compilers
|
||||
if (${WinBuild})
|
||||
message(STATUS "setup Mingw Toolchain for cross compile.")
|
||||
set(LIBSUFFIX .dll)
|
||||
set(SUFFIX .exe)
|
||||
|
||||
@ -40,9 +41,9 @@ if (${WinBuild})
|
||||
#set(TOOLCHAIN_PREFIX i686-w64-mingw32)
|
||||
|
||||
# cross compilers to use for C and C++
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++)
|
||||
set(CMAKE_RC_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-windres)
|
||||
|
||||
# target environment on the build host system
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
@ -67,6 +68,7 @@ if (${WinBuild})
|
||||
# windows config path is same as executable
|
||||
set(CONFIG_PATH "./iprefresher.cfg")
|
||||
else ()
|
||||
message(STATUS "using nativ gcc toolchain.")
|
||||
set(LIBSUFFIX .so)
|
||||
set(SUFFIX "")
|
||||
|
||||
@ -74,8 +76,16 @@ else ()
|
||||
set(CONFIG_PATH "/etc/iprefresher.cfg")
|
||||
endif ()
|
||||
|
||||
# test compiler settings and enable languages here
|
||||
message("")
|
||||
message(STATUS "Testing the C++ compiler!")
|
||||
enable_language(CXX)
|
||||
message("")
|
||||
message(STATUS "Testing the C compiler!")
|
||||
enable_language(C)
|
||||
|
||||
# config libs
|
||||
message("")
|
||||
message(STATUS "Config of Libraries")
|
||||
# libcurl
|
||||
if (${WinBuild})
|
||||
@ -313,7 +323,10 @@ endif (BUILD_DOC)
|
||||
|
||||
# Test Cases
|
||||
if (TESTS)
|
||||
include(GoogleTest)
|
||||
# include(GoogleTest)
|
||||
message(STATUS "Configuring GTEST")
|
||||
find_package(GTest)
|
||||
if (GTEST_FOUND)
|
||||
|
||||
mark_as_advanced(
|
||||
BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS
|
||||
@ -340,7 +353,7 @@ if (TESTS)
|
||||
package_add_test(test1 tests/UnitTest.cpp ${SOURCE})
|
||||
|
||||
add_custom_target(build-test
|
||||
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target test
|
||||
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target test1 test
|
||||
DEPENDS ${PROJECT_NAME}
|
||||
COMMENT "Packing ${PROJECT_NAME}")
|
||||
|
||||
@ -348,4 +361,7 @@ if (TESTS)
|
||||
"bin/test1" --gtest_output="xml:report.xml"
|
||||
DEPENDS ${PROJECT_NAME}
|
||||
COMMENT "Packing ${PROJECT_NAME}")
|
||||
else ()
|
||||
message(STATUS "GTEST environment not found!")
|
||||
endif ()
|
||||
ENDIF ()
|
Loading…
Reference in New Issue
Block a user