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

Improve cmake and directory organization. #99

Merged
merged 7 commits into from
Mar 29, 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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? I thought we went 4.0 and 6.0? I can't even get 3.8 on 18.04 without sacrificing chickens...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was originally 3.8 and below, then at the beginning of this PR it was switched and I just reverted back to 3.8 since I can't get 4.0 to install on travis. #100

)
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