From 4b4bacb9511106d245dbef128a987b1653292a07 Mon Sep 17 00:00:00 2001 From: Mateo de Mayo Date: Fri, 6 May 2022 15:52:27 -0300 Subject: [PATCH] Build file improvements: pkgconfig, BUILD_TESTS flag, and other fixes --- .gitignore | 2 ++ CMakeLists.txt | 19 ++++++++++++++----- cmake_modules/basalt.pc.in | 10 ++++++++++ thirdparty/CMakeLists.txt | 5 +---- 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 cmake_modules/basalt.pc.in diff --git a/.gitignore b/.gitignore index a208c1a..a9ad93d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ cmake-build* +.cache +.vscode .idea CMakeLists.txt.user build* diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d975e2..3a62d4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,7 @@ set(CMAKE_CXX_FLAGS_CIDEBUG "-O0 -DEIGEN_INITIALIZE_MATRICES_BY_NAN") set(CMAKE_CXX_FLAGS_CIRELWITHDEBINFO "-O3 -DEIGEN_INITIALIZE_MATRICES_BY_NAN") # CI version with no debug symbols # base set of compile flags -set(BASALT_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-parameter -ftemplate-backtrace-limit=0") +set(BASALT_CXX_FLAGS "-Wall -Wextra -Wno-error=unused-parameter -ftemplate-backtrace-limit=0") # clang-specific compile flags if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") @@ -460,14 +460,23 @@ file(GLOB CONFIG_FILES "${CMAKE_CURRENT_SOURCE_DIR}/data/*.json") install(FILES ${CONFIG_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/basalt) +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/cmake_modules/basalt.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/basalt.pc + @ONLY +) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/basalt.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) + # Replace install() to do-nothing macro. macro(install) endmacro() -# Include subproject (or any other CMake code) with "disabled" install(). -enable_testing() -add_subdirectory(thirdparty/basalt-headers/test) -add_subdirectory(test) +if (BUILD_TESTS) + # Include subproject (or any other CMake code) with "disabled" install(). + enable_testing() + add_subdirectory(thirdparty/basalt-headers/test) + add_subdirectory(test) +endif() # Restore original install() behavior. macro(install) _install(${ARGN}) diff --git a/cmake_modules/basalt.pc.in b/cmake_modules/basalt.pc.in new file mode 100644 index 0000000..f0497e5 --- /dev/null +++ b/cmake_modules/basalt.pc.in @@ -0,0 +1,10 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: Basalt +Description: Visual-Inertial Mapping with Non-Linear Factor Recovery +Version: 0.1 +URL: https://gitlab.freedesktop.org/mateosss/basalt +Libs: -L${libdir} -lbasalt +Cflags: -isystem ${includedir} diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index c687aba..0e799ad 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -56,7 +56,7 @@ set_target_properties(opengv PROPERTIES target_compile_options(opengv PRIVATE -Wno-unused-private-field ${BASALT_MARCH_FLAGS} - ${BASALT_PASSED_CXX_FLAGS}) + "SHELL:${BASALT_PASSED_CXX_FLAGS}") # TODO: enable once mpark issue is fixed upstream pangolin #set_target_properties(pangolin PROPERTIES @@ -142,6 +142,3 @@ if (EIGEN3_INCLUDE_DIR MATCHES "^${CMAKE_SOURCE_DIR}.*") set_target_properties(${_target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_include_dirs_new}") endforeach() endif() - - -