Skip to content

Commit

Permalink
Import standard cmake modules, standardise dependency resolution [ESD…
Browse files Browse the repository at this point in the history
…-1246] [ESD-1247] (#126)

* Start importing common cmake repo

* Finish importing cmake modules

* Swift to swift fork of eigen

* Use https for common cmake modules

* Use https for eigen

* Fix CI errors

* Make unit tests and examples optional

* Include tests directory in interface

* Update swift project options

* Update project options

* Bump cmake modules

* Revert to old unit test run targets

* Fix example build targets

* Change cereal to be header only interface target

* Don't clobber global compiler flags

* Bump cmake modules

* cmake compile features not available in higher level projects

* Re-add clang-format support

* Bump cmake modules

* Include gzip headers as system

* Remove clang-format hack

* Bump cmake

* Import merged submodules

* Enforce no compiler extensions

* Bump cmake modules

* Bump cmake modules

* Bump cmake modules

* Bump cmake modules
  • Loading branch information
woodfell authored Jun 6, 2019
1 parent 10e7206 commit f035af9
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 142 deletions.
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
[submodule "third_party/eigen"]
path = third_party/eigen
url = https://github.com/PX4/eigen.git
url = https://github.com/swift-nav/eigen.git
[submodule "third_party/gflags"]
path = third_party/gflags
path = third_party/googleflags
url = https://github.com/gflags/gflags.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
[submodule "third_party/fast-cpp-csv-parser"]
path = third_party/fast-cpp-csv-parser
url = https://github.com/ben-strasser/fast-cpp-csv-parser.git
url = https://github.com/swift-nav/fast-cpp-csv-parser.git
[submodule "third_party/cereal"]
path = third_party/cereal
url = https://github.com/USCiLab/cereal.git
[submodule "third_party/gzip-hpp"]
path = third_party/gzip-hpp
url = https://github.com/mapbox/gzip-hpp.git
[submodule "cmake/cmake"]
path = cmake/common
url = https://github.com/swift-nav/cmake.git
51 changes: 33 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
project(albatross)
cmake_minimum_required(VERSION 2.8.7)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(ClangTools)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" "${CMAKE_CURRENT_LIST_DIR}/cmake/common")

include(CCache)
include(SwiftCmakeOptions)
swift_create_project_options(
HAS_TESTS
HAS_EXAMPLES
TEST_PACKAGES "Googletest" "GFlags"
)

include(ClangFormat)
swift_setup_clang_format()

option(ENABLE_AUTOFORMAT "Enable automatic formatting and replacement with clang-format." ON)
option(ENABLE_AUTOLINT "Enable automatic linting and warning with clang-tidy. " OFF)
option(ENABLE_STACK_ANALYSIS "Enable stack analysis. Requires gcc." OFF)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
if(albatross_BUILD_EXAMPLES)
find_package(GFlags REQUIRED)
endif()

add_subdirectory(third_party/googletest)
set(JUST_INSTALL_CEREAL YES CACHE BOOL "" FORCE) #Don't generate docs, it conflicts with Eigen
find_package(Cereal REQUIRED)
find_package(Eigen REQUIRED)
find_package(FastCSV REQUIRED)
find_package(Gzip-Hpp REQUIRED)

add_library(albatross INTERFACE)
target_include_directories(albatross INTERFACE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/tests"
)
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/"
"${PROJECT_SOURCE_DIR}/third_party/gzip-hpp/include"
)

include(${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake)
target_link_libraries(albatross
INTERFACE
eigen
cereal
fast-csv
gzip-hpp
)

set(albatross_COMPILE_OPTIONS
-Werror
Expand Down Expand Up @@ -67,7 +79,10 @@ set(albatross_COMPILE_OPTIONS
-Wvolatile-register-var
-Wwrite-strings
)
target_compile_features(albatross INTERFACE cxx_std_14)

add_subdirectory(tests)
add_subdirectory(examples)
if(albatross_BUILD_TESTS)
add_subdirectory(tests)
endif()
if(albatross_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
68 changes: 0 additions & 68 deletions cmake/ClangTools.cmake

This file was deleted.

11 changes: 11 additions & 0 deletions cmake/FindCereal.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Cereal throws lots of compiler errors if we add_subdirectory it, but we
# only want the headers anyway
if(TARGET cereal)
return()
endif()

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cereal/include")
add_library(cereal INTERFACE)

target_include_directories(cereal SYSTEM INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cereal/include")
endif()
50 changes: 0 additions & 50 deletions cmake/FindGFlags.cmake

This file was deleted.

12 changes: 12 additions & 0 deletions cmake/FindGzip-Hpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Non-swift code that doesn't nicely export a library target, can't use the generic module
if(EXISTS "${PROJECT_SOURCE_DIR}/third_party/gzip-hpp/CMakeLists.txt")
add_library(gzip-hpp INTERFACE)
target_include_directories(gzip-hpp SYSTEM INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/gzip-hpp/include>)
else()
if(Gzip-Hpp_FIND_REQUIRED)
message(FATAL_ERROR "Could not find REQUIRED package Gzip-Hpp")
else()
message(WARNING "Could not find package Gzip-Hpp")
endif()
endif()

1 change: 1 addition & 0 deletions cmake/common
Submodule common added at ed4494
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ set(albatross_example_BINARIES
)
foreach(TARGET IN LISTS albatross_example_BINARIES)
target_compile_options(${TARGET} PRIVATE ${albatross_COMPILE_OPTIONS})
set_target_properties(${TARGET} PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF)
endforeach()

4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(albatross_unit_tests EXCLUDE_FROM_ALL
add_executable(albatross_unit_tests
test_block_utils.cc
test_call_trace.cc
test_core_dataset.cc
Expand Down Expand Up @@ -50,6 +50,8 @@ target_link_libraries(albatross_unit_tests
nlopt
z
)
set_target_properties(albatross_unit_tests PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF)

add_custom_target(run_albatross_unit_tests ALL
COMMAND albatross_unit_tests
COMMENT "Running unit tests"
Expand Down
2 changes: 1 addition & 1 deletion third_party/eigen
Submodule eigen updated 372 files
2 changes: 1 addition & 1 deletion third_party/fast-cpp-csv-parser
Submodule fast-cpp-csv-parser updated 2 files
+6 −0 CMakeLists.txt
+1,140 −1,198 csv.h

0 comments on commit f035af9

Please sign in to comment.