Skip to content

Commit 2b7f215

Browse files
committed
CMake fix
1 parent 8b5ea40 commit 2b7f215

File tree

13 files changed

+192
-45
lines changed

13 files changed

+192
-45
lines changed

CMake/AxiomUtils.cmake

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
include_guard(GLOBAL)
15+
function(axiom_get_rpath_origin VAR)
16+
if(APPLE)
17+
set(_origin @loader_path)
18+
else()
19+
set(_origin "\$ORIGIN")
20+
endif()
21+
set(${VAR}
22+
${_origin}
23+
PARENT_SCOPE)
24+
endfunction()
25+
26+
# TODO use file sets
27+
function(axiom_install_library_headers)
28+
# Find any headers and install them relative to the source tree in include.
29+
file(GLOB _hdrs "*.h")
30+
if(NOT "${_hdrs}" STREQUAL "")
31+
cmake_path(
32+
RELATIVE_PATH
33+
CMAKE_CURRENT_SOURCE_DIR
34+
BASE_DIRECTORY
35+
"${CMAKE_SOURCE_DIR}"
36+
OUTPUT_VARIABLE
37+
_hdr_dir)
38+
install(FILES ${_hdrs} DESTINATION include/${_hdr_dir})
39+
endif()
40+
endfunction()
41+
42+
# Base add axiom library call to add a library and install it.
43+
function(axiom_base_add_library TARGET)
44+
add_library(${TARGET} ${ARGN})
45+
install(TARGETS ${TARGET} DESTINATION lib/axiom)
46+
axiom_install_library_headers()
47+
endfunction()
48+
49+
# This is extremely hackish but presents an easy path to installation.
50+
function(axiom_add_library TARGET)
51+
set(options OBJECT STATIC SHARED INTERFACE)
52+
set(oneValueArgs)
53+
set(multiValueArgs)
54+
cmake_parse_arguments(
55+
AXIOM
56+
"${options}"
57+
"${oneValueArgs}"
58+
"${multiValueArgs}"
59+
${ARGN})
60+
61+
# Remove library type specifiers from ARGN
62+
set(library_type)
63+
if(AXIOM_OBJECT)
64+
set(library_type OBJECT)
65+
elseif(AXIOM_STATIC)
66+
set(library_type STATIC)
67+
elseif(AXIOM_SHARED)
68+
set(library_type SHARED)
69+
elseif(AXIOM_INTERFACE)
70+
set(library_type INTERFACE)
71+
endif()
72+
73+
list(REMOVE_ITEM ARGN OBJECT)
74+
list(REMOVE_ITEM ARGN STATIC)
75+
list(REMOVE_ITEM ARGN SHARED)
76+
list(REMOVE_ITEM ARGN INTERFACE)
77+
# Propagate to the underlying add_library and then install the target.
78+
if(AXIOM_MONO_LIBRARY)
79+
if(TARGET axiom)
80+
# Target already exists, append sources to it.
81+
target_sources(axiom PRIVATE ${ARGN})
82+
else()
83+
set(_type STATIC)
84+
if(AXIOM_BUILD_SHARED)
85+
set(_type SHARED)
86+
endif()
87+
# Create the target if this is the first invocation.
88+
add_library(axiom ${_type} ${ARGN})
89+
set_target_properties(axiom PROPERTIES LIBRARY_OUTPUT_DIRECTORY
90+
${PROJECT_BINARY_DIR}/lib)
91+
set_target_properties(axiom PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
92+
${PROJECT_BINARY_DIR}/lib)
93+
install(TARGETS axiom DESTINATION lib/axiom EXPORT axiom_targets)
94+
endif()
95+
# create alias for compatability
96+
if(NOT TARGET ${TARGET})
97+
add_library(${TARGET} ALIAS axiom)
98+
endif()
99+
else()
100+
# Create a library for each invocation.
101+
axiom_base_add_library(${TARGET} ${library_type} ${ARGN})
102+
endif()
103+
axiom_install_library_headers()
104+
endfunction()
105+
106+
function(axiom_link_libraries TARGET)
107+
# TODO(assignUser): Handle scope keywords (they currently are empty calls ala
108+
# target_link_libraries(target PRIVATE))
109+
if(AXIOM_MONO_LIBRARY)
110+
# These targets follow the axiom_* name for consistency but are NOT actually
111+
# aliases to axiom when building the mono lib and need to be linked
112+
# explicitly (this is a hack)
113+
set(explicit_targets)
114+
115+
foreach(_arg ${ARGN})
116+
list(FIND explicit_targets ${_arg} _explicit)
117+
if(_explicit EQUAL -1 AND "${_arg}" MATCHES "^axiom_*")
118+
message(DEBUG "\t\tDROP: ${_arg}")
119+
else()
120+
message(DEBUG "\t\tADDING: ${_arg}")
121+
target_link_libraries(axiom ${_arg})
122+
endif()
123+
endforeach()
124+
else()
125+
target_link_libraries(${TARGET} ${ARGN})
126+
endif()
127+
endfunction()
128+
129+
function(axiom_include_directories TARGET)
130+
if(AXIOM_MONO_LIBRARY)
131+
target_include_directories(axiom ${ARGN})
132+
else()
133+
target_include_directories(${TARGET} ${ARGN})
134+
endif()
135+
endfunction()
136+
137+
function(axiom_compile_definitions TARGET)
138+
if(AXIOM_MONO_LIBRARY)
139+
target_compile_definitions(axiom ${ARGN})
140+
else()
141+
target_compile_definitions(${TARGET} ${ARGN})
142+
endif()
143+
endfunction()
144+
145+
function(axiom_sources TARGET)
146+
if(AXIOM_MONO_LIBRARY)
147+
target_sources(axiom ${ARGN})
148+
else()
149+
target_sources(${TARGET} ${ARGN})
150+
endif()
151+
endfunction()

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ list(
4040
"${PROJECT_SOURCE_DIR}/CMake/resolve_dependency_modules"
4141
"${PROJECT_SOURCE_DIR}/velox/CMake")
4242
include(ResolveDependency)
43+
include(AxiomUtils)
4344

4445
set(VELOX_BUILD_VECTOR_TEST_UTILS
4546
ON

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BUILD_BASE_DIR=_build
1717
BUILD_DIR=release
1818
BUILD_TYPE=Release
1919

20-
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DAXIOM_BUILD_TESTING=ON
20+
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DAXIOM_BUILD_TESTING=ON -DVELOX_MONO_LIBRARY=ON -DAXIOM_MONO_LIBRARY=ON
2121

2222
# Use Ninja if available. If Ninja is used, pass through parallelism control flags.
2323
USE_NINJA ?= 1

axiom/connectors/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(AXIOM_BUILD_TESTING)
2424
add_subdirectory(tests)
2525
endif()
2626

27-
velox_add_library(axiom_connector_metadata ConnectorMetadata.cpp)
27+
axiom_add_library(axiom_connector_metadata ConnectorMetadata.cpp)
2828

29-
velox_link_libraries(axiom_connector_metadata velox_common_base velox_memory
29+
axiom_link_libraries(axiom_connector_metadata velox_common_base velox_memory
3030
velox_connector)

axiom/connectors/hive/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
velox_add_library(
15+
axiom_add_library(
1616
axiom_hive_connector_metadata
1717
OBJECT
1818
HiveConnectorMetadata.cpp
1919
LocalHiveConnectorMetadata.cpp
2020
StatisticsBuilder.cpp)
2121

22-
velox_link_libraries(
22+
axiom_link_libraries(
2323
axiom_hive_connector_metadata
2424
axiom_connector_metadata
2525
velox_hive_connector

axiom/connectors/tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
velox_add_library(axiom_test_connector TestConnector.cpp)
15+
axiom_add_library(axiom_test_connector OBJECT TestConnector.cpp)
1616

17-
velox_link_libraries(
17+
axiom_link_libraries(
1818
axiom_test_connector
1919
axiom_connector_metadata
2020
velox_common_base

axiom/connectors/tpch/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
velox_add_library(axiom_tpch_connector_metadata OBJECT
15+
axiom_add_library(axiom_tpch_connector_metadata OBJECT
1616
TpchConnectorMetadata.cpp)
1717

18-
velox_link_libraries(
18+
axiom_link_libraries(
1919
axiom_tpch_connector_metadata
2020
axiom_connector_metadata
2121
axiom_schema_resolver

axiom/logical_plan/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
velox_add_library(
15+
axiom_add_library(
1616
axiom_logical_plan
1717
Expr.cpp
1818
ExprPrinter.cpp
1919
LogicalPlanNode.cpp
2020
PlanPrinter.cpp
2121
ExprApi.cpp)
2222

23-
velox_link_libraries(axiom_logical_plan velox_type)
23+
axiom_link_libraries(axiom_logical_plan velox_type)
2424

25-
velox_add_library(axiom_logical_plan_builder PlanBuilder.cpp NameAllocator.cpp
25+
axiom_add_library(axiom_logical_plan_builder PlanBuilder.cpp NameAllocator.cpp
2626
NameMappings.cpp)
2727

28-
velox_link_libraries(
28+
axiom_link_libraries(
2929
axiom_logical_plan_builder
3030
axiom_logical_plan
3131
axiom_connector_metadata

axiom/optimizer/CMakeLists.txt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ if(AXIOM_BUILD_TESTING)
1616
add_subdirectory(tests)
1717
endif()
1818

19-
add_library(axiom_model Model.cpp)
19+
axiom_add_library(axiom_model Model.cpp)
2020

21-
target_link_libraries(
22-
axiom_model velox_exception)
21+
axiom_link_libraries(axiom_model velox_exception)
2322

24-
add_library(axiom_schema_resolver SchemaResolver.cpp SchemaUtils.cpp)
23+
axiom_add_library(axiom_schema_resolver SchemaResolver.cpp SchemaUtils.cpp)
2524

26-
target_link_libraries(
27-
axiom_schema_resolver axiom_connector_metadata velox_exception velox_vector)
25+
axiom_link_libraries(axiom_schema_resolver axiom_connector_metadata
26+
velox_exception velox_vector)
2827

29-
add_library(
28+
axiom_add_library(
3029
axiom_optimizer
3130
DerivedTable.cpp
3231
DerivedTablePrinter.cpp
@@ -49,9 +48,7 @@ add_library(
4948
VeloxHistory.cpp
5049
JoinSample.cpp)
5150

52-
add_dependencies(axiom_optimizer velox_hive_connector)
53-
54-
target_link_libraries(
51+
axiom_link_libraries(
5552
axiom_optimizer
5653
velox_core
5754
axiom_connector_metadata

axiom/optimizer/tests/CMakeLists.txt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
velox_add_library(axiom_optimizer_tests_parquet_tpch ParquetTpchTest.cpp)
15+
add_library(axiom_optimizer_tests_parquet_tpch ParquetTpchTest.cpp)
1616

17-
velox_link_libraries(
17+
target_link_libraries(
1818
axiom_optimizer_tests_parquet_tpch
1919
axiom_logical_plan_builder
2020
axiom_optimizer
@@ -29,9 +29,9 @@ velox_link_libraries(
2929
gtest
3030
gtest_main)
3131

32-
velox_add_library(axiom_optimizer_tests_query_test_base QueryTestBase.cpp)
32+
add_library(axiom_optimizer_tests_query_test_base QueryTestBase.cpp)
3333

34-
velox_link_libraries(
34+
target_link_libraries(
3535
axiom_optimizer_tests_query_test_base
3636
axiom_optimizer
3737
axiom_schema_resolver
@@ -44,16 +44,16 @@ velox_link_libraries(
4444
gtest
4545
gtest_main)
4646

47-
velox_add_library(axiom_optimizer_tests_presto_parser PrestoParser.cpp)
47+
add_library(axiom_optimizer_tests_presto_parser PrestoParser.cpp)
4848

49-
velox_link_libraries(
49+
target_link_libraries(
5050
axiom_optimizer_tests_presto_parser axiom_logical_plan_builder
5151
axiom_sql_presto_ast antlr4_shared)
5252

53-
velox_add_library(axiom_optimizer_tests_plan_matcher PlanMatcher.cpp
54-
LogicalPlanMatcher.cpp)
53+
add_library(axiom_optimizer_tests_plan_matcher PlanMatcher.cpp
54+
LogicalPlanMatcher.cpp)
5555

56-
velox_link_libraries(
56+
target_link_libraries(
5757
axiom_optimizer_tests_plan_matcher
5858
velox_hive_connector
5959
velox_parse_parser
@@ -62,10 +62,10 @@ velox_link_libraries(
6262
GTest::gtest
6363
GTest::gtest_main)
6464

65-
velox_add_library(axiom_optimizer_tests_hive_queries_test_base
66-
HiveQueriesTestBase.cpp)
65+
add_library(axiom_optimizer_tests_hive_queries_test_base
66+
HiveQueriesTestBase.cpp)
6767

68-
velox_link_libraries(
68+
target_link_libraries(
6969
axiom_optimizer_tests_hive_queries_test_base
7070
axiom_optimizer_tests_parquet_tpch
7171
axiom_optimizer_tests_plan_matcher
@@ -98,7 +98,6 @@ add_executable(
9898
PlanTest.cpp
9999
UnnestTest.cpp
100100
ParquetTpchTest.cpp
101-
QueryTestBase.cpp
102101
SubfieldTest.cpp
103102
FeatureGen.cpp
104103
Genies.cpp

0 commit comments

Comments
 (0)