Skip to content

Commit

Permalink
Merge pull request #99 from akleeman/directory_reorg
Browse files Browse the repository at this point in the history
Improve cmake and directory organization.
  • Loading branch information
akleeman authored Mar 29, 2019
2 parents 313c9bf + f99223f commit 2ed667a
Show file tree
Hide file tree
Showing 93 changed files with 381 additions and 417 deletions.
111 changes: 49 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ cmake_minimum_required(VERSION 2.8.7)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(ClangTools)

# Enable Clang auto-formatting, defaults to on.
option(ENABLE_AUTOFORMAT "Enable automatic formatting and replacement with clang-format." ON)
# Enable Clang auto-linting, defaults to off.
option(ENABLE_AUTOLINT "Enable automatic linting and warning with clang-tidy. " OFF)
# Enable static stack analyzer, defaults to off.
option(ENABLE_STACK_ANALYSIS "Enable stack analysis. Requires gcc." OFF)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -17,68 +14,58 @@ endif()

add_subdirectory(third_party/googletest)

include_directories(SYSTEM ${gtest_SOURCE_DIR} ${gtest_SOURCE_DIR}/include)
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/eigen/")
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/cereal/include")
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/third_party/fast-cpp-csv-parser/")
add_library(albatross INTERFACE)
target_include_directories(albatross INTERFACE
"${PROJECT_SOURCE_DIR}/include"
)
target_include_directories(albatross SYSTEM INTERFACE
"${PROJECT_SOURCE_DIR}/third_party/eigen/"
"${PROJECT_SOURCE_DIR}/third_party/cereal/include"
"${PROJECT_SOURCE_DIR}/third_party/fast-cpp-csv-parser/"
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -fexceptions -frtti")
set(CMAKE_CXX_FLAGS "-std=c++14 -Wshadow -Wswitch-default -Wswitch-enum -Wundef -Wpointer-arith -Wcast-align -Wformat=2 -Wredundant-decls ${CMAKE_CXX_FLAGS}")
set("LOG_LEVEL=8")

include_directories("${PROJECT_SOURCE_DIR}/albatross")
include(${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake)

set(albatross_HEADERS
albatross/cereal/eigen.h
albatross/cereal/traits.h
albatross/core/dataset.h
albatross/core/declarations.h
albatross/core/distribution.h
albatross/core/fit_model.h
albatross/core/indexing.h
albatross/core/keys.h
albatross/core/model.h
albatross/core/parameter_handling_mixin.h
albatross/core/parameter_macros.h
albatross/core/prediction.h
albatross/core/priors.h
albatross/core/serialize.h
albatross/core/traits.h
albatross/covariance_functions/call_trace.h
albatross/covariance_functions/covariance_function.h
albatross/covariance_functions/distance_metrics.h
albatross/covariance_functions/noise.h
albatross/covariance_functions/polynomials.h
albatross/covariance_functions/radial.h
albatross/covariance_functions/scaling_function.h
albatross/covariance_functions/traits.h
albatross/csv_utils.h
albatross/eigen/serializable_diagonal_matrix.h
albatross/eigen/serializable_ldlt.h
albatross/eigen_utils.h
albatross/evaluation/cross_validation.h
albatross/evaluation/cross_validation_utils.h
albatross/evaluation/evaluate.h
albatross/evaluation/folds.h
albatross/map_utils.h
albatross/models/gp.h
albatross/models/least_squares.h
albatross/models/ransac.h
albatross/random_utils.h
albatross/tune.h
albatross/tuning_metrics.h
examples/example_utils.h
examples/sinc_example_utils.h
examples/temperature_example/temperature_example_utils.h
tests/mock_model.h
tests/test_core_distribution.h
tests/test_models.h
tests/test_serialize.h
tests/test_utils.h
)

add_custom_target(albatross DEPENDS ${albatross_HEADERS} COMMENT "albatross dependencies")
set(albatross_COMPILE_OPTIONS
-Werror
-Wall
-Wno-unused-value
-Wcast-align
-Wchar-subscripts
-Wcomment
-Wdisabled-optimization
-Wformat
-Wformat=2
-Wformat-nonliteral
-Wformat-security
-Wformat-y2k
-Wimport
-Winit-self
-Winvalid-pch
-Wmissing-braces
-Wmissing-field-initializers
-Wmissing-format-attribute
-Wmissing-include-dirs
-Wparentheses
-Wpointer-arith
-Wredundant-decls
-Wreturn-type
-Wsequence-point
-Wsign-compare
-Wstack-protector
-Wswitch
-Wtrigraphs
-Wuninitialized
-Wunknown-pragmas
-Wunused
-Wunused-function
-Wunused-label
-Wunused-variable
-Wunused-value
-Wunused-variable
-Wvolatile-register-var
-Wwrite-strings
)

add_subdirectory(tests)
add_subdirectory(examples)
33 changes: 0 additions & 33 deletions albatross/CovarianceFunctions

This file was deleted.

71 changes: 33 additions & 38 deletions cmake/ClangTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Do not use clang tooling when cross compiling.
if(CMAKE_CROSSCOMPILING)
return()
return()
endif(CMAKE_CROSSCOMPILING)

################################################################################
Expand All @@ -21,27 +21,22 @@ endif(CMAKE_CROSSCOMPILING)
# Check for Clang format
set(CLANG_FORMAT_PATH "NOTSET" CACHE STRING "Absolute path to the clang-format executable")
if("${CLANG_FORMAT_PATH}" STREQUAL "NOTSET")
find_program(CLANG_FORMAT NAMES
clang-format39 clang-format-3.9
clang-format38 clang-format-3.8
clang-format37 clang-format-3.7
clang-format36 clang-format-3.6
clang-format35 clang-format-3.5
clang-format34 clang-format-3.4
clang-format)
message(STATUS "Using clang format: ${CLANG_FORMAT}")
if("${CLANG_FORMAT}" STREQUAL "CLANG_FORMAT-NOTFOUND")
message(WARNING "Could not find 'clang-format' please set CLANG_FORMAT_PATH:STRING")
else()
set(CLANG_FORMAT_PATH ${CLANG_FORMAT})
message(STATUS "Found: ${CLANG_FORMAT_PATH}")
endif()
find_program(CLANG_FORMAT NAMES
clang-format-3.8
)
message(STATUS "Using clang format: ${CLANG_FORMAT}")
if("${CLANG_FORMAT}" STREQUAL "CLANG_FORMAT-NOTFOUND")
message(WARNING "Could not find 'clang-format' please set CLANG_FORMAT_PATH:STRING")
else()
set(CLANG_FORMAT_PATH ${CLANG_FORMAT})
message(STATUS "Found: ${CLANG_FORMAT_PATH}")
endif()
else()
if(NOT EXISTS ${CLANG_FORMAT_PATH})
message(WARNING "Could not find 'clang-format': ${CLANG_FORMAT_PATH}")
else()
message(STATUS "Found: ${CLANG_FORMAT_PATH}")
endif()
if(NOT EXISTS ${CLANG_FORMAT_PATH})
message(WARNING "Could not find 'clang-format': ${CLANG_FORMAT_PATH}")
else()
message(STATUS "Found: ${CLANG_FORMAT_PATH}")
endif()
endif()

################################################################################
Expand All @@ -50,24 +45,24 @@ endif()


if (EXISTS ${CLANG_FORMAT_PATH})
# Format all files .cc files (and their headers) in project
add_custom_target(clang-format-all
COMMAND git ls-files -- '../*.cc' '../*.h'
| sed 's/^...//' | sed 's\#\^\#${CMAKE_SOURCE_DIR}/\#'
| xargs "${CLANG_FORMAT_PATH}" -i
)
# In-place format *.cc files that differ from master, and are not listed as
# being DELETED.
add_custom_target(clang-format-diff
COMMAND git diff --diff-filter=ACMRTUXB --name-only master -- '../*.cc' '../*.h'
| sed 's\#\^\#${CMAKE_SOURCE_DIR}/\#'
| xargs "${CLANG_FORMAT_PATH}" -i
)
# Format all files .cc files (and their headers) in project
add_custom_target(clang-format-all
COMMAND git ls-files -- '../*.cc' '../*.h'
| sed 's/^...//' | sed 's\#^\#${CMAKE_SOURCE_DIR}/\#'
| xargs "${CLANG_FORMAT_PATH}" -i
)
# In-place format *.cc files that differ from master, and are not listed as
# being DELETED.
add_custom_target(clang-format-diff
COMMAND git diff --diff-filter=ACMRTUXB --name-only master -- '../*.cc' '../*.h'
| sed 's\#^\#${CMAKE_SOURCE_DIR}/\#'
| xargs "${CLANG_FORMAT_PATH}" -i
)
endif()
if (EXISTS ${CPPCHECK_PATH})
add_custom_target(cppcheck-all
COMMAND git ls-files -- '../*.cc' '../*.h'
| ${CPPCHECK_PATH} --enable=all --std=c++14 -I../include -isystem../third_party/eigen -q --file-list=-
)
add_custom_target(cppcheck-all
COMMAND git ls-files -- '../*.cc' '../*.h'
| ${CPPCHECK_PATH} --enable=all --std=c++14 -I../include -isystem../third_party/eigen -q --file-list=-
)
endif()

Loading

0 comments on commit 2ed667a

Please sign in to comment.