Build file improvements: pkgconfig, BUILD_TESTS flag, and other fixes

This commit is contained in:
Mateo de Mayo 2022-05-06 15:52:27 -03:00
parent c2f052f9f8
commit 4b4bacb951
4 changed files with 27 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
cmake-build* cmake-build*
.cache
.vscode
.idea .idea
CMakeLists.txt.user CMakeLists.txt.user
build* build*

View File

@ -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 set(CMAKE_CXX_FLAGS_CIRELWITHDEBINFO "-O3 -DEIGEN_INITIALIZE_MATRICES_BY_NAN") # CI version with no debug symbols
# base set of compile flags # 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 # clang-specific compile flags
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 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} install(FILES ${CONFIG_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/basalt) 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. # Replace install() to do-nothing macro.
macro(install) macro(install)
endmacro() endmacro()
if (BUILD_TESTS)
# Include subproject (or any other CMake code) with "disabled" install(). # Include subproject (or any other CMake code) with "disabled" install().
enable_testing() enable_testing()
add_subdirectory(thirdparty/basalt-headers/test) add_subdirectory(thirdparty/basalt-headers/test)
add_subdirectory(test) add_subdirectory(test)
endif()
# Restore original install() behavior. # Restore original install() behavior.
macro(install) macro(install)
_install(${ARGN}) _install(${ARGN})

View File

@ -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}

View File

@ -56,7 +56,7 @@ set_target_properties(opengv PROPERTIES
target_compile_options(opengv PRIVATE target_compile_options(opengv PRIVATE
-Wno-unused-private-field -Wno-unused-private-field
${BASALT_MARCH_FLAGS} ${BASALT_MARCH_FLAGS}
${BASALT_PASSED_CXX_FLAGS}) "SHELL:${BASALT_PASSED_CXX_FLAGS}")
# TODO: enable once mpark issue is fixed upstream pangolin # TODO: enable once mpark issue is fixed upstream pangolin
#set_target_properties(pangolin PROPERTIES #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}") set_target_properties(${_target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_include_dirs_new}")
endforeach() endforeach()
endif() endif()