Skip to content

Commit

Permalink
Merge pull request #32 from 9prady9/cmake_and_docs_changes
Browse files Browse the repository at this point in the history
Cmake and docs changes
  • Loading branch information
9prady9 authored Apr 5, 2017
2 parents 17b5278 + 13a2468 commit 785a78e
Show file tree
Hide file tree
Showing 13 changed files with 4,257 additions and 32 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ matrix:
env: INSTALL_CXX=clang++-3.5
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
packages: ['clang-3.5', 'lcov']
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5', 'george-edison55-precise-backports']
packages: ['clang-3.5', 'lcov', 'cmake', 'cmake-data']
- os: linux
compiler: clang
env: INSTALL_CXX=clang++-3.6
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['clang-3.6', 'lcov']
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6', 'george-edison55-precise-backports']
packages: ['clang-3.6', 'lcov', 'cmake', 'cmake-data']
- os: linux
compiler: gcc-4.8
env: INSTALL_CXX=g++-4.8 INSTALL_CC=gcc-4.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8', 'lcov']
sources: ['ubuntu-toolchain-r-test', 'george-edison55-precise-backports']
packages: ['g++-4.8', 'lcov', 'cmake', 'cmake-data']
- os: linux
compiler: gcc-4.9
env: INSTALL_CXX=g++-4.9 INSTALL_CC=gcc-4.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'lcov']
sources: ['ubuntu-toolchain-r-test', 'george-edison55-precise-backports']
packages: ['g++-4.9', 'lcov', 'cmake', 'cmake-data']
- os: osx
compiler: clang
env: INSTALL_CXX=clang++ INSTALL_CC=clang
Expand All @@ -59,6 +59,6 @@ after_success:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null;
brew install lcov;
fi
- lcov --directory test --base-directory ../include/meshio/ --capture --output-file coverage.info
- lcov --directory test --base-directory ../include/meshio/ --capture --no-external --output-file coverage.info
- lcov --remove coverage.info '/usr*' -o coverage.info
- coveralls-lcov coverage.info
42 changes: 30 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
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")
Expand All @@ -20,6 +33,11 @@ IF(UNIX)
ENDIF()
ENDIF()

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

IF(BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF()
Expand All @@ -29,17 +47,17 @@ IF(BUILD_TESTS)
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 lib/cmake/MeshIO
# )
### 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 .
Expand Down
5 changes: 2 additions & 3 deletions CMakeModules/build_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Check if Google Test exists
SET(GTEST_SOURCE_DIR "${CMAKE_SOURCE_DIR}/test/googletest")
IF(NOT EXISTS "${GTEST_SOURCE_DIR}/README")
MESSAGE(WARNING "GTest Source is not available. Tests will not build.")
MESSAGE(WARNING "GTest Source 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")
Expand Down Expand Up @@ -75,8 +75,7 @@ ENDFUNCTION(GTEST_BUILD)

GTEST_BUILD(googletest ${CMAKE_BUILD_TYPE} ${binary_dir} "${byproducts}")

# If we are on OSX and using the clang compiler go ahead and build
# GTest using libstdc++ just in case we compile the CUDA backend
# If we are on OSX and using the clang compiler go ahead and build GTest using libstdc++
IF("${APPLE}" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
GTEST_BUILD(googletest_libstdcpp LibStdCpp ${stdlib_binary_dir} "${byproducts_libstdcpp}")
ENDIF("${APPLE}" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
Expand Down
40 changes: 40 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FIND_PACKAGE(Doxygen REQUIRED)

# Documentation
IF(NOT DEFINED MESHIO_INSTALL_DOC_DIR)
SET(MESHIO_INSTALL_DOC_DIR "${CMAKE_INSTALL_PREFIX}/doc" CACHE PATH "Installation path for documentation")
ENDIF()

SET(MESHIO_DOCS_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/doxygen.mk")
SET(MESHIO_DOCS_CONFIG_OUT "${CMAKE_CURRENT_BINARY_DIR}/doxygen.mk.out")

SET(MESHIO_DOCS_LAYOUT "${CMAKE_CURRENT_SOURCE_DIR}/layout.xml")
SET(MESHIO_DOCS_LAYOUT_OUT "${CMAKE_CURRENT_BINARY_DIR}/layout.xml.out")

SET(DOCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
SET(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
#SET(EXAMPLES_DIR "${PROJECT_SOURCE_DIR}/examples")
#Re-enable test snippets directory setting when doc examples are added
#SET(SNIPPETS_DIR "${PROJECT_SOURCE_DIR}/test")
CONFIGURE_FILE(${MESHIO_DOCS_CONFIG} ${MESHIO_DOCS_CONFIG_OUT})
CONFIGURE_FILE(${MESHIO_DOCS_LAYOUT} ${MESHIO_DOCS_LAYOUT_OUT})

ADD_CUSTOM_TARGET(docs
ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${MESHIO_DOCS_CONFIG_OUT}
COMMAND cmake -E copy_directory ${ASSETS_DIR} ${CMAKE_CURRENT_BINARY_DIR}/html
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Documentation"
VERBATIM)

# Install Doxygen documentation
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${MESHIO_INSTALL_DOC_DIR}
COMPONENT documentation
PATTERN "*"
PATTERN ".git" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "man" EXCLUDE
)

Loading

0 comments on commit 785a78e

Please sign in to comment.