Skip to content

Commit

Permalink
[cmake] improve installation support
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed Oct 14, 2022
1 parent 1098f12 commit afee5d4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,31 @@ set(CMAKE_CXX_STANDARD "23" CMAKE_CXX_STANDARD_REQUIRED ON CMAKE_CXX_EXTENSIONS

include(CTest)
include(FetchContent)
include(GNUInstallDirs)

FetchContent_Declare(
eigen
URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.bz2"
URL_HASH MD5=132dde48fe2b563211675626d29f1707)
URL_HASH MD5=132dde48fe2b563211675626d29f1707
FIND_PACKAGE_ARGS NAMES Eigen3 3.4 REQUIRED NO_MODULE)

FetchContent_Declare(
fmt
URL "https://github.com/fmtlib/fmt/archive/refs/tags/9.1.0.tar.gz"
URL_HASH MD5=21fac48cae8f3b4a5783ae06b443973a)
URL_HASH MD5=21fac48cae8f3b4a5783ae06b443973a
FIND_PACKAGE_ARGS NAMES FMT)

FetchContent_Declare(
google_benchmark
URL "https://github.com/google/benchmark/archive/refs/tags/v1.6.2.tar.gz"
URL_HASH MD5=14d14849e075af116143a161bc3b927b)
URL_HASH MD5=14d14849e075af116143a161bc3b927b
FIND_PACKAGE_ARGS NAMES benchmark)

FetchContent_Declare(
google_test
URL "https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz"
URL_HASH MD5=e82199374acdfda3f425331028eb4e2a)
URL_HASH MD5=e82199374acdfda3f425331028eb4e2a
FIND_PACKAGE_ARGS NAMES GTest)

FetchContent_MakeAvailable(eigen fmt google_test google_benchmark)

Expand All @@ -78,3 +83,6 @@ add_subdirectory(sample)
add_subdirectory(source)
add_subdirectory(support)
add_subdirectory(test)

install(DIRECTORY "include/fcarouge"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Build and run the tests and samples on all platforms:
git clone --depth 1 https://github.com/FrancoisCarouge/Kalman.git "kalman"
cmake -S "kalman" -B "build" -G "Ninja Multi-Config"
cmake --build "build" --config "Debug" --parallel
ctest --test-dir "build" --tests-regex "kalman_(test|sample)" --output-on-failure --parallel
ctest --test-dir "build" --build-config "Debug" --tests-regex "kalman_(test|sample)" --output-on-failure --parallel
```

## Benchmarks
Expand Down
2 changes: 1 addition & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ foreach(BENCHMARK ${SOURCES})
"include")
target_link_libraries(
kalman_benchmark_${NAME}_driver
PRIVATE eigen kalman benchmark::benchmark_main benchmark::benchmark)
PRIVATE Eigen3::Eigen kalman benchmark::benchmark_main benchmark::benchmark)
add_test(kalman_benchmark_${NAME} kalman_benchmark_${NAME}_driver
"--benchmark_out=${NAME}.json")
endforeach()
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ endif()

add_library(kalman INTERFACE)
target_include_directories(kalman INTERFACE ".")
target_link_libraries(kalman INTERFACE ${LIBRARIES})
target_link_libraries(kalman INTERFACE ${LIBRARIES} Eigen3::Eigen)
target_compile_options(kalman INTERFACE ${OPTIONS})
3 changes: 2 additions & 1 deletion sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ set(SOURCES
foreach(SAMPLE ${SOURCES})
get_filename_component(NAME ${SAMPLE} NAME_WE)
add_executable(kalman_sample_${NAME}_driver ${SAMPLE})
target_link_libraries(kalman_sample_${NAME}_driver PRIVATE eigen kalman main)
target_link_libraries(kalman_sample_${NAME}_driver PRIVATE Eigen3::Eigen
kalman main)
add_test(kalman_sample_${NAME} kalman_sample_${NAME}_driver)
endforeach()
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ set(SOURCES
foreach(TEST ${SOURCES})
get_filename_component(NAME ${TEST} NAME_WE)
add_executable(kalman_test_${NAME}_driver ${TEST})
target_link_libraries(kalman_test_${NAME}_driver PRIVATE eigen kalman main)
target_link_libraries(kalman_test_${NAME}_driver PRIVATE Eigen3::Eigen kalman
main)
add_test(kalman_test_${NAME} kalman_test_${NAME}_driver)
endforeach()

0 comments on commit afee5d4

Please sign in to comment.