Skip to content
Open
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
55 changes: 39 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,47 @@ project(

include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
include(cmake/options.cmake)

find_package(PkgConfig REQUIRED)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(BZip2 REQUIRED)
find_package(LibArchive REQUIRED)
find_package(ZLIB REQUIRED)
find_package(pcre2 CONFIG REQUIRED)
find_package(CURL REQUIRED)

set(lnav_LIBS
CURL::libcurl
unofficial::sqlite3::sqlite3
BZip2::BZip2
PCRE2::8BIT PCRE2::16BIT PCRE2::32BIT PCRE2::POSIX
LibArchive::LibArchive
ZLIB::ZLIB
${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libunistring.a
)

if (LNAV_USE_VCPKG)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(BZip2 REQUIRED)
find_package(LibArchive REQUIRED)
find_package(ZLIB REQUIRED)
find_package(pcre2 CONFIG REQUIRED)
find_package(CURL REQUIRED)

set(lnav_LIBS
CURL::libcurl
unofficial::sqlite3::sqlite3
BZip2::BZip2
PCRE2::8BIT PCRE2::16BIT PCRE2::32BIT PCRE2::POSIX
LibArchive::LibArchive
ZLIB::ZLIB
${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libunistring.a
)
else ()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/packages)

find_package(SQLite3 REQUIRED)
find_package(BZip2 REQUIRED)
find_package(LibArchive REQUIRED)
find_package(ZLIB REQUIRED)
find_package(pcre2 REQUIRED)
find_package(CURL REQUIRED)
find_package(Unistring REQUIRED)

set(lnav_LIBS
CURL::libcurl
SQLite3::SQLite3
BZip2::BZip2
pcre2::pcre2
LibArchive::LibArchive
ZLIB::ZLIB
Unistring::Unistring)
endif ()

add_subdirectory(src)
add_subdirectory(test)
Expand Down
1 change: 1 addition & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option(LNAV_USE_VCPKG "When disabled, libraries from the build host are used" ON)
16 changes: 16 additions & 0 deletions cmake/packages/FindUnistring.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(FindPackageHandleStandardArgs)

find_library(UNISTRING_LIBRARY NAMES unistring)
find_path(UNISTRING_HDR NAMES unistr.h)

find_package_handle_standard_args(Unistring
REQUIRED_VARS UNISTRING_LIBRARY UNISTRING_HDR)

if (Unistring_FOUND)
mark_as_advanced(UNISTRING_LIBRARY)
mark_as_advanced(UNISTRING_HDR)
add_library(Unistring::Unistring UNKNOWN IMPORTED)
set_property(TARGET Unistring::Unistring PROPERTY IMPORTED_LOCATION ${UNISTRING_LIBRARY})
cmake_path(GET UNISTRING_HDR PARENT_PATH UNISTRING_HDR)
target_include_directories(Unistring::Unistring INTERFACE ${UNISTRING_HDR_DIR})
endif ()
4 changes: 4 additions & 0 deletions cmake/packages/Findpcre2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
find_package(PkgConfig REQUIRED)

pkg_search_module(pcre2 REQUIRED libpcre2-8 libpcre2-16 libpcre2-32 libpcre2-posix IMPORTED_TARGET GLOBAL)
add_library(pcre2::pcre2 ALIAS PkgConfig::pcre2)
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ add_custom_command(
DEPENDS ptimec
COMMAND ptimec ${TIME_FORMATS} > time_fmts.cc)

add_library(lnavdt STATIC config.h.in ptimec.hh ptimec_spec.hh ptimec_rt.cc time_fmts.cc)
add_library(lnavdt STATIC ${CMAKE_BINARY_DIR}/src/config.h ptimec.hh ptimec_spec.hh ptimec_rt.cc time_fmts.cc)
target_include_directories(lnavdt PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -512,7 +512,7 @@ target_link_libraries(lnavfileio cppfmt spookyhash pcrepp base BZip2::BZip2 ZLIB
add_library(
diag STATIC
${GEN_SRCS}
config.h.in
${CMAKE_BINARY_DIR}/src/config.h
all_logs_vtab.cc
apps.cc
archive_manager.cc
Expand Down
2 changes: 1 addition & 1 deletion src/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(
base STATIC
../config.h.in
${CMAKE_BINARY_DIR}/src/config.h
ansi_scrubber.cc
attr_line.cc
attr_line.builder.cc
Expand Down
6 changes: 3 additions & 3 deletions src/base/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

#pragma once

#include <cstdlib>
#include <cstdio>
#include <exception>
#include <functional>
#include <type_traits>

#include <stdio.h>

namespace types {
template<typename T>
struct Ok {
Expand Down Expand Up @@ -818,7 +818,7 @@ struct Result {
{
if (!isOk()) {
::fprintf(stderr, "%s\n", str);
abort();
std::abort();
}
return expect_impl(std::is_same<T, void>());
}
Expand Down
4 changes: 2 additions & 2 deletions src/pcrepp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_library(pcrepp STATIC
../config.h.in
${CMAKE_BINARY_DIR}/src/config.h
pcre2pp.hh
pcre2pp_fwd.hh
pcre2pp.cc)

target_include_directories(pcrepp PUBLIC . .. ../third-party/scnlib/include
${CMAKE_CURRENT_BINARY_DIR}/..)
target_link_libraries(pcrepp cppfmt PCRE2::8BIT PCRE2::16BIT PCRE2::32BIT PCRE2::POSIX)
target_link_libraries(pcrepp cppfmt pcre2::pcre2)

add_executable(test_pcre2pp test_pcre2pp.cc)
target_include_directories(
Expand Down
2 changes: 1 addition & 1 deletion src/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_library(remote STATIC ../config.h.in remote.ssh.cc remote.ssh.hh)
add_library(remote STATIC ${CMAKE_BINARY_DIR}/src/config.h remote.ssh.cc remote.ssh.hh)

target_include_directories(remote PUBLIC . .. ../fmtlib
${CMAKE_CURRENT_BINARY_DIR}/..)
Expand Down
11 changes: 6 additions & 5 deletions src/yajlpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(
yajlpp STATIC
../config.h.in
${CMAKE_BINARY_DIR}/src/config.h
json_op.hh
json_ptr.hh
yajlpp.hh
Expand All @@ -16,22 +16,23 @@ target_include_directories(yajlpp PUBLIC . .. ../fmtlib
../third-party
)
target_link_libraries(yajlpp
base
pcrepp
yajl
${CURSES_LIBRARIES}
datepp
)

add_executable(test_yajlpp test_yajlpp.cc)
target_link_libraries(test_yajlpp yajlpp base ${lnav_LIBS})
target_link_libraries(test_yajlpp yajlpp)
add_test(NAME test_yajlpp COMMAND test_yajlpp)

add_executable(test_json_ptr test_json_ptr.cc)
target_link_libraries(test_json_ptr yajlpp base ${lnav_LIBS})
target_link_libraries(test_json_ptr yajlpp)
add_test(NAME test_json_ptr COMMAND test_json_ptr)

add_executable(drive_json_op drive_json_op.cc)
target_link_libraries(drive_json_op base yajlpp ${lnav_LIBS})
target_link_libraries(drive_json_op yajlpp)

add_executable(drive_json_ptr_walk drive_json_ptr_walk.cc)
target_link_libraries(drive_json_ptr_walk base yajlpp ${lnav_LIBS})
target_link_libraries(drive_json_ptr_walk yajlpp)