-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update googletest, cmake and cleanup build variables (#38)
* Update googletest, cmake and cleanup build variables * Moved github templates to .github folder * Replaced chrome/googletest with googletest/googltest * Refactored cmake scripts to modern cmake syntax * Increased minimum required CMake version to 3.12.3 * Cleanup documentation generation cmake script
- Loading branch information
Showing
11 changed files
with
222 additions
and
278 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () |
Oops, something went wrong.