Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update googletest, cmake and cleanup build variables #38

Merged
merged 2 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "test/googletest"]
path = test/googletest
url = https://chromium.googlesource.com/external/googletest
url = https://github.com/google/googletest.git
23 changes: 10 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
#-----------------------------------------------------------------------------
#
# Configuration for continuous integration service at travis-ci.org
#
#-----------------------------------------------------------------------------
#
# This file is copy of https://github.com/mapbox/protozero/blob/master/.travis.yml

language: cpp

branches:
only:
- master

sudo: false

matrix:
include:
- os: linux
- dist: xenial
compiler: clang
env: INSTALL_CXX=clang++-3.5
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5', 'george-edison55-precise-backports']
packages: ['clang-3.5', 'lcov', 'cmake', 'cmake-data']
- os: linux
- dist: xenial
compiler: clang
env: INSTALL_CXX=clang++-3.6
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6', 'george-edison55-precise-backports']
packages: ['clang-3.6', 'lcov', 'cmake', 'cmake-data']
- os: linux
- dist: xenial
compiler: gcc-4.8
env: INSTALL_CXX=g++-4.8 INSTALL_CC=gcc-4.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'george-edison55-precise-backports']
packages: ['g++-4.8', 'lcov', 'cmake', 'cmake-data']
- os: linux
- dist: xenial
compiler: gcc-4.9
env: INSTALL_CXX=g++-4.9 INSTALL_CC=gcc-4.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'george-edison55-precise-backports']
packages: ['g++-4.9', 'lcov', 'cmake', 'cmake-data']
- os: osx
osx_image: xcode10.1
compiler: clang
env: INSTALL_CXX=clang++ INSTALL_CC=clang

Expand All @@ -50,7 +47,7 @@ before_install:
script:
- mkdir -p build
- cd build
- CC=$INSTALL_CC CXX=$INSTALL_CXX cmake ../ -DBUILD_COVERAGE:BOOL=ON
- CC=$INSTALL_CC CXX=$INSTALL_CXX cmake ../ -DMeshIO_BUILD_COVERAGE:BOOL=ON
- make -j4
- ctest --output-on-failure

Expand Down
148 changes: 81 additions & 67 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,67 +1,81 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)

PROJECT(MeshIO)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

OPTION(BUILD_DOCUMENTATION "Build Documentation" OFF)
OPTION(BUILD_EXAMPLES "Build examples" OFF)
OPTION(BUILD_TESTS "Build Tests" ON)
OPTION(BUILD_COVERAGE "Create test coverage report" OFF)
OPTION(USE_SYSTEM_GTEST "Use GTEST from system libraries" OFF)
OPTION(USE_RELATIVE_TEST_DIR "Use relative paths for the test data directory(For continious integration(CI) purposes only)" OFF)

# Set a default build type if none was specified
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
ENDIF()

### Marking BUILD_COVERAGE as advanced as it won't be
### used by regular developers
MARK_AS_ADVANCED(BUILD_COVERAGE)

IF(UNIX)
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSEIF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.7)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF()
ENDIF()

# Generate documentation
IF(BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY(docs)
ENDIF(BUILD_DOCUMENTATION)

IF(BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF()

IF(BUILD_TESTS)
ENABLE_TESTING()
ADD_SUBDIRECTORY(test)
ENDIF()

### Following commented out changes work only on CMAKE version >=3.0
ADD_LIBRARY(MeshIO INTERFACE)
TARGET_INCLUDE_DIRECTORIES(MeshIO INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/meshio>
)

INSTALL(TARGETS MeshIO EXPORT meshioExport)
INSTALL(EXPORT meshioExport NAMESPACE Upstream::
DESTINATION share/MeshIO/cmake
)

INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION .
COMPONENT Headers
FILES_MATCHING
PATTERN "*.hpp"
)
cmake_minimum_required(VERSION 3.12.3)

project(MeshIO VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if (NOT EXISTS "${MeshIO_SOURCE_DIR}/test/googletest")
message(WARNING "google/googletest is not available. Tests will not built.")
message("Did you miss the --recursive option when cloning?")
message("Run the following commands to correct this:")
message("git submodule init")
message("git submodule update")
message("git submodule foreach git pull origin master")
endif ()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

option(MeshIO_BUILD_DOCS "Build Documentation" OFF)
option(MeshIO_BUILD_EXAMPLES "Build examples" OFF)
option(MeshIO_BUILD_COVERAGE "Create test coverage report" OFF)

add_library(meshio INTERFACE)

target_include_directories(meshio INTERFACE
$<BUILD_INTERFACE:${MeshIO_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

include(CTest)
enable_testing()
add_subdirectory(test)

if(MeshIO_BUILD_DOCS)
add_subdirectory(docs)
endif(MeshIO_BUILD_DOCS)

if (MeshIO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()

include(CMakePackageConfigHelpers)
set(INCLUDE_DIRS include)
set(CMAKE_DIR share/meshio/cmake)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/MeshIOConfig.cmake.in"
"cmake_install/MeshIOConfig.cmake"
INSTALL_DESTINATION share/meshio/cmake
PATH_VARS INCLUDE_DIRS CMAKE_DIR
)

install(TARGETS meshio EXPORT MeshIOTargets COMPONENT meshio)

install(EXPORT MeshIOTargets
NAMESPACE MeshIO::
DESTINATION share/meshio/cmake
COMPONENT meshio
)

install(FILES
${MeshIO_BINARY_DIR}/cmake_install/MeshIOConfig.cmake
DESTINATION share/meshio/cmake
COMPONENT cmake
)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION .
COMPONENT Headers
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.inl"
)

mark_as_advanced(MeshIO_BUILD_COVERAGE)
98 changes: 0 additions & 98 deletions CMakeModules/build_gtest.cmake

This file was deleted.

42 changes: 42 additions & 0 deletions cmake/MeshIOConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#Copyright (c) 2019, Lakshman Anumolu, Pradeep Garigipati
#All rights reserved.
#
#This file is part of MeshIO whose distribution is governed by
#the BSD 2-Clause License contained in the accompanying LICENSE.txt
#file.

# MeshIO
# -----
#
# This is the cmake configuration file for MeshIO header library. It provides
# the following imported targets.
#
# ``MeshIO::meshio`` - the target for MeshIO
#
# This target can be used to link with your application using the
# ``target_link_library`` command. Here is an example of how to use these
# targets in your application:
#
# add_executable(mybinary source.cpp)
# target_link_library(mybinary PRIVATE MeshIO::meshio)
#
# This example creates a mybinary executable from the source.cpp file and links
# against the MeshIO library. Note you do *not* need to set the include
# directories as they are automatically included with the target.
#
# This is the recommended way of linking against MeshIO

@PACKAGE_INIT@

set_and_check(MeshIO_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@)

if (NOT TARGET MeshIO::meshio AND NOT TARGET meshio AND
EXISTS @PACKAGE_CMAKE_DIR@/MeshIOTargets.cmake)
include(@PACKAGE_CMAKE_DIR@/MeshIOTargets.cmake)
endif ()

if (TARGET MeshIO::meshio OR TARGET meshio)
if (TARGET meshio AND NOT TARGET MeshIO::meshio)
add_library(MeshIO::meshio ALIAS meshio)
endif ()
endif ()
Loading