Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #57 from frederikvannoote/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
frederikvannoote authored Aug 9, 2018
2 parents 8d63485 + 9ab8f76 commit aecdfb8
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 40 deletions.
83 changes: 83 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
image: Visual Studio 2017

platform:
- x64

configuration:
- Debug
- Release

environment:
QT_VERSION: 5.9
QT_COMPILED: msvc2017
matrix:
- SHARED: ON
- SHARED: OFF

install:
############################################################################
# Install Ninja
############################################################################
- set NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip"
- appveyor DownloadFile %NINJA_URL% -FileName ninja.zip
- 7z x ninja.zip -oC:\projects\deps\ninja > nul
- set PATH=C:\projects\deps\ninja;%PATH%
- ninja --version

############################################################################
# set correct QTDIR in the PATH environment variable
############################################################################
- set VS_FULL=%VS_VERSION% Win64
- set QTDIR=C:/Qt/%QT_VERSION%/%QT_COMPILED%_64
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
- set PATH=%PATH%;%QTDIR%/bin

build_script:
# Clone examples: they are the code to test against.
- git clone https://github.com/frederikvannoote/cmake-common-examples.git examples
- set CMAKE_COMMON=C:/projects/cmake-common
- mkdir installed

test_script:
# Build and install simplelib
- mkdir simplelib-build
- cd simplelib-build
- cmake -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=../installed -G Ninja ../examples/simplelib
- cmake --build . --config %configuration% --target all
- cmake --build . --config %configuration% --target install
- cmake --build . --config %configuration% --target sdk
- cd ..

# Relocate library
- xcopy /E installed relocated\

# Build and install Simpleapp
- mkdir simpleapp-build
- cd simpleapp-build
- cmake -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=../installed -DCC1simplelib_DIR=../relocated/lib/cmake/CC1simplelib -G Ninja ../examples/simpleapp
- cmake --build . --config %configuration% --target all
- cmake --build . --config %configuration% --target install
- cd ..

# Build and install QSimpleApp
- mkdir QSimpleApp-build
- cd QSimpleApp-build
- cmake -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=../installed -DCC1simplelib_DIR=../relocated/lib/cmake/CC1simplelib -G Ninja ../examples/QSimpleApp/
- cmake --build . --config %configuration% --target all
- cmake --build . --config %configuration% --target install
- cd ..

# Build and install complex lib
- mkdir complexlib-build
- cd complexlib-build
- cmake -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=../installed -G Ninja ../examples/complexlib
- cmake --build . --config %configuration% --target all
- cmake --build . --config %configuration% --target install
- cmake --build . --config %configuration% --target sdk
- cd ..

# uncomment following lines to be able to debug the appveyor image through RDP protocol when build finished
# https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
# on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

103 changes: 103 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
language: cpp
sudo: false
dist: trusty

os:
- linux
- osx

compiler:
- gcc
- clang

env:
global:
-

matrix:
- CMAKE_BUILD_TYPE=Debug
- CMAKE_BUILD_TYPE=Release

matrix:
exclude:
- os: linux
compiler: clang
- os: osx
compiler: gcc

addons:
apt:
packages:
- ninja-build
- qtbase5-dev

before_install:
- |
# Install cmake
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz"
cd /tmp
mkdir cmake
travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=/tmp/cmake/bin:${PATH}
else
if ! brew ls --version cmake &>/dev/null; then brew install cmake; fi
fi
- |
# Install cmake and ninja
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
export QTDIR=/usr/lib/x86_64-linux-gnu/qt5
export PATH="$QTDIR/bin:$PATH"
else
brew update > /dev/null
brew tap homebrew/versions
brew install ninja
brew install qt
export QTDIR="/usr/local/opt/qt5"
export PATH="$QTDIR/bin:$PATH"
fi
install:
# Clone examples: they are the code to test against.
- git clone https://github.com/frederikvannoote/cmake-common-examples.git ${HOME}/examples
- export CMAKE_COMMON=${TRAVIS_BUILD_DIR}
- mkdir /tmp/installed

script:
- |
# Build and install simplelib
mkdir /tmp/simplelib-build
cd /tmp/simplelib-build
cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/installed -G Ninja ${HOME}/examples/simplelib
cmake --build . --target all
cmake --build . --target install
cmake --build . --target sdk
- |
# Relocate library
cp -r /tmp/installed /tmp/relocated
- |
# Build and install Simpleapp
mkdir /tmp/simpleapp-build
cd /tmp/simpleapp-build
cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/installed -DCC1simplelib_DIR=/tmp/relocated/lib/cmake/CC1simplelib -G Ninja ${HOME}/examples/simpleapp
cmake --build . --target all
cmake --build . --target install
- |
# Build and install QSimpleApp
mkdir /tmp/QSimpleApp-build
cd /tmp/QSimpleApp-build
cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/installed -DCC1simplelib_DIR=/tmp/relocated/lib/cmake/CC1simplelib -G Ninja ${HOME}/examples/QSimpleApp/
cmake --build . --target all
cmake --build . --target install
- |
# Build and install complex lib
mkdir /tmp/complexlib-build
cd /tmp/complexlib-build
cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/installed -G Ninja ${HOME}/examples/complexlib
cmake --build . --target all
cmake --build . --target install
cmake --build . --target sdk
6 changes: 5 additions & 1 deletion AddQtTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ endmacro()

option(MANUAL_TESTS_ENABLED "Enable manual tests" OFF)
macro(add_manual_qt_test TEST_NAME SRCS)
find_package(Qt5Test REQUIRED)
add_executable(${TEST_NAME} ${SRCS})
target_link_libraries(${TEST_NAME} PUBLIC Qt5::Test)

if(DEFINED MANUAL_TESTS_ENABLED)
if(${MANUAL_TESTS_ENABLED})
add_qt_test(${TEST_NAME} "${SRCS}")
add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
endif(${MANUAL_TESTS_ENABLED})
endif(DEFINED MANUAL_TESTS_ENABLED)
endmacro()
8 changes: 6 additions & 2 deletions AddResourceInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ macro(add_resource_info PROJECT ISLIBRARY FILE_VER_MAJOR FILE_VER_MINOR FILE_VER
#If we are creating an RC file for a library, make sure it is a DLL and not a static one. If it's an application, no need to do this check.
set(IS_APPLICABLE_RESOURCE (NOT ${ISLIBRARY} OR (${BUILD_SHARED_LIBS} AND ${ISLIBRARY})))
if(WIN32 AND NOT UNIX AND ${IS_APPLICABLE_RESOURCE})
# Finish creating the relevant data for the RC file.
get_git_head_revision(GIT_REFSPEC GIT_COMMIT_HASH)

if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
# Finish creating the relevant data for the RC file.
get_git_head_revision(GIT_REFSPEC GIT_COMMIT_HASH)
endif()

string(TIMESTAMP CURRENT_YEAR "%Y")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCHITECTURE_DESC "32-bit")
Expand Down
3 changes: 2 additions & 1 deletion CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ if(CODE_COVERAGE)
COMMAND ${LCOV_EXECUTABLE} --quiet --capture --directory . --base-directory ${CMAKE_SOURCE_DIR} --no-external -o coverage.info
COMMAND ${LCOV_EXECUTABLE} --quiet --remove coverage.info ${CODE_COVERAGE_EXCLUDES} -o coverage.info
COMMAND ${LCOV_EXECUTABLE} --quiet --remove coverage.info \*test_\* -o coverage.info
COMMAND ${LCOV_EXECUTABLE} --quiet --remove coverage.info catch.hpp -o coverage.info
COMMAND ${LCOV_EXECUTABLE} --quiet --remove coverage.info \*catch.hpp\* -o coverage.info
COMMAND ${LCOV_EXECUTABLE} --quiet --remove coverage.info \*contract.cpp\* -o coverage.info
COMMAND ${LCOV_EXECUTABLE} --list coverage.info
COMMAND ${LCOV_EXECUTABLE} --summary coverage.info
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
Expand Down
1 change: 1 addition & 0 deletions CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
"/wd4714" # suppress warning: marked __forceinline but are not inlined
# Fixed in Qt 5.10.0 (https://bugreports.qt.io/browse/QTBUG-55042)
# Check later with Qt >= 5.10.0 if warning suppression can be removed
"/wd4718" # Workaround for https://bugreports.qt.io/browse/QTBUG-54089
"/nologo"
"/EHsc-" # disable exceptions
"/GR-" # disable RTTI
Expand Down
2 changes: 2 additions & 0 deletions Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ SORT_MEMBER_DOCS = YES
SORT_MEMBERS_CTORS_1ST = YES

USE_MATHJAX = YES

EXAMPLE_PATH = @CMAKE_SOURCE_DIR@
38 changes: 20 additions & 18 deletions Doxygen.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_LIST_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
if (NOT TARGET doxygen)
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_LIST_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")

# note the option ALL which allows to build the docs together with the application
add_custom_target(doxygen
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
# note the option ALL which allows to build the docs together with the application
add_custom_target(doxygen
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif()
4 changes: 2 additions & 2 deletions FindGcov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ if(GCOV_EXECUTABLE AND NOT EXISTS "${GCOV_EXECUTABLE}")
set(GCOV_EXECUTABLE "notfound" CACHE PATH FORCE "")
endif()

IF(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
MESSAGE(WARNING "Compiler is not GNU gcc or Clang!")
set(GCOV_EXECUTABLE "notfound" CACHE PATH FORCE "")
ELSEIF( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
MESSAGE(WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
set(GCOV_EXECUTABLE "notfound" CACHE PATH FORCE "")
ELSE()
find_program(GCOV_EXECUTABLE NAMES gcov)
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( Gcov DEFAULT_MSG
Expand Down
24 changes: 8 additions & 16 deletions GeneratePackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ write_basic_package_version_file(

# Create import targets
install(TARGETS ${TARGET_NAME} EXPORT ${TARGET_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}
PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}/private
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}
PRIVATE_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/private
)

# Export the import targets
export(EXPORT ${TARGET_NAME}Targets
FILE "${CMAKE_BINARY_DIR}/${CMAKE_CONFIG_FILE_BASE_NAME}Targets.cmake"
install(EXPORT ${TARGET_NAME}Targets
FILE "${CMAKE_CONFIG_FILE_BASE_NAME}Targets.cmake"
NAMESPACE ${PROJECT_NAMESPACE}::
DESTINATION ${CMAKE_INSTALL_DIR}
)

# Now install the 3 config files
Expand All @@ -68,15 +69,6 @@ install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_CONFIG_FILE_BASE_NAME}Config.cmake
DESTINATION ${CMAKE_INSTALL_DIR}
)

install(EXPORT ${TARGET_NAME}Targets
FILE
${CMAKE_CONFIG_FILE_BASE_NAME}Targets.cmake
NAMESPACE
${PROJECT_NAMESPACE}::
DESTINATION
${CMAKE_INSTALL_DIR}
)

# Create and install a global module include file
# This makes it possible to include all header files of the module by using
# #include <${PROJECT_NAME}>
Expand Down
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ You can fetch the files during your git clone using a submodule.
git submodule add -b <tag> [email protected]:barco-healthcare/cmake-common.git path/to/cmake/common
```

## Cloning during cmake run
Add this snippet to your CMakeLists.txt
```
# Download build system
if(NOT EXISTS "${CMAKE_BINARY_DIR}/buildsys/v2.0")
message(STATUS "Downloading buildsystem...")
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} clone --branch v2.0 https://github.com/frederikvannoote/cmake-common.git ${CMAKE_BINARY_DIR}/buildsys/v2.0)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/buildsys/v2.0")
```

# Usage

You can include these files in your CMakeLists.txt
Expand Down

0 comments on commit aecdfb8

Please sign in to comment.