Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify CMake config and optimize includes #1618

Merged
merged 15 commits into from
Nov 18, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
pip3 install pyaml pyicu

- name: Install dependencies
run: |
run: |
brew install llvm@16
brew install conan@2
echo 'export PATH="/usr/local/opt/llvm@16/bin:$PATH"' >> ~/.bash_profile
Expand Down Expand Up @@ -66,10 +66,10 @@ jobs:
conan install .. -pr:b=../conanprofiles/clang-16-macos -pr:h=../conanprofiles/clang-16-macos -of=. --build=missing;
- name: Configure CMake
# For std::ranges::join_view we need the -fexperimental-library flag on libc++16, which on Mac requires to manually tinker with the linking flags.
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.build-type}} -DCMAKE_TOOLCHAIN_FILE="$(pwd)/build/conan_toolchain.cmake" -DUSE_PARALLEL=true -DRUN_EXPENSIVE_TESTS=false -DENABLE_EXPENSIVE_CHECKS=true -DCMAKE_CXX_COMPILER=clang++ -DADDITIONAL_COMPILER_FLAGS="-fexperimental-library" -D_NO_TIMING_TESTS=ON -DADDITIONAL_LINKER_FLAGS="-L$(brew --prefix llvm)/lib/c++"
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_TOOLCHAIN_FILE="$(pwd)/build/conan_toolchain.cmake" -DUSE_PARALLEL=true -DRUN_EXPENSIVE_TESTS=false -DENABLE_EXPENSIVE_CHECKS=true -DCMAKE_CXX_COMPILER=clang++ -DADDITIONAL_COMPILER_FLAGS="-fexperimental-library" -D_NO_TIMING_TESTS=ON -DADDITIONAL_LINKER_FLAGS="-L$(brew --prefix llvm)/lib/c++"

- name: Build
# Build your program with the given configuration
# Build your program with the given configuration
# Sourcing the conanrun.sh even for building is required to make gtest_discover_tests pass reliably.
run: >
df -h;
Expand Down
46 changes: 16 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,43 +76,26 @@ FetchContent_Declare(
################################
# NLOHMANN JSON
################################
# Use URL to avoid downloading large repository as recommended here:
# https://json.nlohmann.me/integration/cmake/#fetchcontent
FetchContent_Declare(
nlohmann-json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03 # release-3.11.3
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
URL_HASH SHA3_224=b9237e8e8242e915de5be631aa944369c38a377c5e79aa505ba741a9
)
# We only want to include a single file from the nlohmann GitHub repository, so we initialize the submodule
# manually
FetchContent_GetProperties(nlohmann-json)
if (NOT nlohmann-json_POPULATED)
FetchContent_Populate(nlohmann-json)
include_directories(SYSTEM ${nlohmann-json_SOURCE_DIR}/single_include)
endif ()


###############################
# ANTLR CPP RUNTIME FOR THE SPARQL PARSER
###############################
set(ANTLR_BUILD_CPP_TESTS OFF CACHE BOOL "don't try to build googletest twice")
set(ANTLR_BUILD_SHARED OFF CACHE BOOL "We're only interested in the static library")
FetchContent_Declare(
antlr
GIT_REPOSITORY https://github.com/antlr/antlr4.git
GIT_TAG 9239e6ff444420516b44b7621e8dc7691fcf0e16
GIT_TAG cc82115a4e7f53d71d9d905caa2c2dfa4da58899 # 4.13.12
SOURCE_SUBDIR runtime/Cpp
RobinTF marked this conversation as resolved.
Show resolved Hide resolved
)

# From ANTLR we actually don't want the toplevel directory (which doesn't
# have a proper `CMakeLists.txt` anyway), but only the C++ runtime which
# resides in a subdirectory. We additionally need to suppress some warnings
# only for ANTLR. We therefore have to perform the initialization for
# ANTLR using `FetchContent` manually.
FetchContent_GetProperties(antlr)
if (NOT antlr_POPULATED)
FetchContent_Populate(antlr)
set(ANTLR_BUILD_CPP_TESTS OFF CACHE BOOL "don't try to build googletest twice")
add_subdirectory(${antlr_SOURCE_DIR}/runtime/Cpp EXCLUDE_FROM_ALL)
target_compile_options(antlr4_static PRIVATE -Wno-all -Wno-extra -Wno-unqualified-std-cast-call -Wno-error -Wno-deprecated-declarations)
include_directories(SYSTEM ${antlr_SOURCE_DIR}/runtime/Cpp/runtime/src)
endif ()

################################
# Threading
################################
Expand Down Expand Up @@ -184,7 +167,7 @@ find_package(OpenSSL REQUIRED)
function(qlever_target_link_libraries target)
target_link_libraries(${target} ${ARGN} absl::flat_hash_map
absl::flat_hash_set absl::strings absl::str_format ICU::uc
ICU::i18n OpenSSL::SSL OpenSSL::Crypto GTest::gtest GTest::gmock stxxl fsst)
ICU::i18n OpenSSL::SSL OpenSSL::Crypto GTest::gtest GTest::gmock stxxl fsst nlohmann_json::nlohmann_json)
RobinTF marked this conversation as resolved.
Show resolved Hide resolved

# memorySize is a utility library for defining memory sizes.
if (NOT ${target} STREQUAL "memorySize")
Expand Down Expand Up @@ -247,11 +230,11 @@ FetchContent_Declare(
################################
# S2 Geometry
################################
SET (BUILD_TESTS OFF CACHE BOOL "no tests for s2")
set(BUILD_TESTS OFF CACHE BOOL "no tests for s2")
FetchContent_Declare(
s2
GIT_REPOSITORY https://github.com/google/s2geometry.git
GI_TAG 5b5eccd54a08ae03b4467e79ffbb076d0b5f221e #version 0.11.1
GIT_TAG 5b5eccd54a08ae03b4467e79ffbb076d0b5f221e #version 0.11.1
SYSTEM
)

Expand Down Expand Up @@ -338,9 +321,9 @@ FetchContent_Declare(
################################
# Apply FetchContent
################################
FetchContent_MakeAvailable(googletest ctre abseil re2 stxxl fsst s2)
FetchContent_MakeAvailable(googletest ctre abseil re2 stxxl fsst s2 nlohmann-json antlr)
# Disable some warnings in RE2, STXXL, and GTEST
target_compile_options(s2 PRIVATE -Wno-sign-compare -Wno-unused-parameter -Wno-class-memaccess -Wno-comment -Wno-redundant-move -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wno-class-memaccess)
target_compile_options(s2 PRIVATE -Wno-sign-compare -Wno-unused-parameter -Wno-class-memaccess -Wno-comment -Wno-redundant-move -Wno-unknown-warning-option -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-unused-but-set-variable -Wno-unused-function)
target_compile_options(re2 PRIVATE -Wno-unused-parameter)
target_compile_options(stxxl PRIVATE -Wno-deprecated-declarations)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand All @@ -350,6 +333,9 @@ include_directories(${ctre_SOURCE_DIR}/single-header)
target_compile_options(fsst PRIVATE -Wno-extra -Wno-all -Wno-error)
target_compile_options(fsst12 PRIVATE -Wno-extra -Wno-all -Wno-error)
include_directories(${fsst_SOURCE_DIR})
target_compile_options(antlr4_static PRIVATE -Wno-all -Wno-extra -Wno-error -Wno-deprecated-declarations)
# Only required because a lot of classes that do not explicitly link against antlr4_static use the headers.
include_directories(SYSTEM "${antlr_SOURCE_DIR}/runtime/Cpp/runtime/src")

message(STATUS ---)
message(STATUS "CXX_FLAGS are : " ${CMAKE_CXX_FLAGS})
Expand Down
1 change: 1 addition & 0 deletions src/parser/sparqlParser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ add_library(sparqlParser SparqlQleverVisitor.h
generated/SparqlAutomaticParser.h generated/SparqlAutomaticParser.cpp
generated/SparqlAutomaticVisitor.h generated/SparqlAutomaticVisitor.cpp)
qlever_target_link_libraries(sparqlParser antlr4_static sparqlExpressions rdfEscaping util)
target_precompile_headers(sparqlParser PRIVATE "${antlr_SOURCE_DIR}/runtime/Cpp/runtime/src/antlr4-runtime.h")
# Silence warnings in files that are auto-generated by ANTLR.
# TODO<joka921> Submit a pull request to ANTLR to fix those warnings.
target_compile_options(sparqlParser PRIVATE -Wno-logical-op-parentheses -Wno-parentheses)
16 changes: 16 additions & 0 deletions src/parser/sparqlParser/DatasetClause.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2024, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Robin Textor-Falconi <[email protected]>

#pragma once

#include "parser/TripleComponent.h"

// A named or default graph
struct DatasetClause {
TripleComponent::Iri dataset_;
bool isNamed_;

// For testing
bool operator==(const DatasetClause& other) const = default;
};
10 changes: 1 addition & 9 deletions src/parser/sparqlParser/SparqlQleverVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "engine/sparqlExpressions/NaryExpression.h"
#include "engine/sparqlExpressions/StdevExpression.h"
#include "parser/data/GraphRef.h"
#include "parser/sparqlParser/DatasetClause.h"
#undef EOF
#include "parser/sparqlParser/generated/SparqlAutomaticVisitor.h"
#define EOF std::char_traits<char>::eof()
Expand All @@ -28,15 +29,6 @@ class Reversed {
auto end() { return _iterable.rend(); }
};

// A named or default graph
struct DatasetClause {
TripleComponent::Iri dataset_;
bool isNamed_;

// For testing
bool operator==(const DatasetClause& other) const = default;
};

/**
* This is a visitor that takes the parse tree from ANTLR and transforms it into
* a `ParsedQuery`.
Expand Down
5 changes: 5 additions & 0 deletions src/util/ConfigManager/ConfigShorthandVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
// Author: Andre Schlegel (March of 2023, [email protected])
#pragma once

// ANTLR runtime uses this as a variable name.
#ifdef EOF
#undef EOF
RobinTF marked this conversation as resolved.
Show resolved Hide resolved
#endif
#include <antlr4-runtime.h>

#include "util/ConfigManager/generated/ConfigShorthandParser.h"
#define EOF std::char_traits<char>::eof()
#include "util/json.h"

/*
Expand Down
5 changes: 5 additions & 0 deletions src/util/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
#define LOGLEVEL INFO
#endif

// Abseil does also define its own LOG macro, so we need to undefine it here.
#ifdef LOG
#undef LOG
#endif

#define LOG(x) \
if (x > LOGLEVEL) \
; \
Expand Down
1 change: 1 addition & 0 deletions src/util/http/HttpParser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ add_library(httpParser AcceptHeaderQleverVisitor.h AcceptHeaderQleverVisitor.cpp
generated/AcceptHeaderParser.h generated/AcceptHeaderParser.cpp
generated/AcceptHeaderVisitor.h generated/AcceptHeaderVisitor.cpp)
qlever_target_link_libraries(httpParser antlr4_static util)
target_precompile_headers(httpParser PRIVATE "${antlr_SOURCE_DIR}/runtime/Cpp/runtime/src/antlr4-runtime.h")
2 changes: 1 addition & 1 deletion src/util/http/UrlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>
#include <string_view>

#include "parser/sparqlParser/SparqlQleverVisitor.h"
#include "parser/sparqlParser/DatasetClause.h"
#include "util/HashMap.h"

/**
Expand Down
Loading