-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-14244. Refactor the libhdfspp cmake build files. #485
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
60b31af
279fc51
2fb535c
357dc50
f56ac0f
243dfb8
771f4df
ee65828
67fd896
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *~ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Allow either Cyrus or GSASL for a SASL implementation | ||
| if (HDFSPP_SASL_IMPL STREQUAL "CYRUS") | ||
| find_package(CyrusSASL REQUIRED) | ||
| set (SASL_LIBRARIES sasl2) | ||
| set (CMAKE_USING_CYRUS_SASL 1) | ||
| add_definitions(-DUSE_SASL -DUSE_CYRUS_SASL) | ||
| elseif (HDFSPP_SASL_IMPL STREQUAL "GSASL") | ||
| find_package(GSasl REQUIRED) | ||
| set (SASL_LIBRARIES gsasl) | ||
| set (CMAKE_USING_GSASL 1) | ||
| add_definitions(-DUSE_SASL -DUSE_GSASL) | ||
| else () | ||
| message(STATUS "Compiling with NO SASL SUPPORT") | ||
| set (SASL_LIBRARIES) | ||
| endif () |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| findPackageExtension("asio.hpp" "" true) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,15 @@ | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
| # - Find Cyrus SASL (sasl.h, libsasl2.so) | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # This module defines | ||
| # CYRUS_SASL_INCLUDE_DIR, directory containing headers | ||
| # CYRUS_SASL_SHARED_LIB, path to Cyrus SASL's shared library | ||
| # CYRUS_SASL_FOUND, whether Cyrus SASL and its plugins have been found | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # N.B: we do _not_ include sasl in thirdparty, for a fairly subtle reason. The | ||
| # TLDR version is that newer versions of cyrus-sasl (>=2.1.26) have a bug fix | ||
| # for https://bugzilla.cyrusimap.org/show_bug.cgi?id=3590, but that bug fix | ||
| # relied on a change both on the plugin side and on the library side. If you | ||
| # then try to run the new version of sasl (e.g from our thirdparty tree) with | ||
| # an older version of a plugin (eg from RHEL6 install), you'll get a SASL_NOMECH | ||
| # error due to this bug. | ||
| # | ||
| # In practice, Cyrus-SASL is so commonly used and generally non-ABI-breaking that | ||
| # we should be OK to depend on the host installation. | ||
|
|
||
| # Note that this is modified from the version that was copied from our | ||
| # friends at the Kudu project. The original version implicitly required | ||
| # the Cyrus SASL. This version will only complain if REQUIRED is added. | ||
|
|
||
|
|
||
| find_path(CYRUS_SASL_INCLUDE_DIR sasl/sasl.h) | ||
| find_library(CYRUS_SASL_SHARED_LIB sasl2) | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(CYRUS_SASL DEFAULT_MSG | ||
| CYRUS_SASL_SHARED_LIB CYRUS_SASL_INCLUDE_DIR) | ||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| MARK_AS_ADVANCED(CYRUS_SASL_INCLUDE_DIR CYRUS_SASL_SHARED_LIB) | ||
| findPackageExtension("sasl/sasl.h" "sasl2" false) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| findPackageExtension("gmock/gmock.h" "gtest;gmock;gmock_main" true) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| if (NOT HDFSPP_FOUND) | ||
|
|
||
| findPackageExtension("hdfspp/hdfspp.h" "hdfspp" true) | ||
| if (HDFSPP_FOUND) | ||
| find_package(CyrusSASL) | ||
| find_package(OpenSSL) | ||
| find_package(Protobuf) | ||
| find_package(URIparser) | ||
| find_package(Threads) | ||
| set_property(TARGET hdfspp | ||
| PROPERTY INTERFACE_LINK_LIBRARIES | ||
| sasl2 ssl crypto protobuf uriparser dl ${CMAKE_THREAD_LIBS_INIT} | ||
| ) | ||
| endif () | ||
| endif () |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| findPackageExtension("krb5.h" "krb5;gssapi_krb5" false) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| findPackageExtension("openssl/opensslv.h" "ssl;crypto" false) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Input: | ||
| # h_file: the name of a header file to find | ||
| # lib_names: a list of library names to find | ||
| # allow_any: Allow either static or shared libraries | ||
|
|
||
| # Environment: | ||
| # CMAKE_FIND_PACKAGE_NAME: the name of the package to build | ||
| # <name>_HOME: variable is used to check for headers and library | ||
| # BUILD_SHARED_LIBRARIES: whether to find shared instead of static libraries | ||
|
|
||
| # Outputs: | ||
| # <name>_INCLUDE_DIR: directory containing headers | ||
| # <name>_LIBRARIES: libraries to link with | ||
| # <name>_FOUND: whether uriparser has been found | ||
|
|
||
| function (findPackageExtension h_file lib_names allow_any) | ||
| set (_name ${CMAKE_FIND_PACKAGE_NAME}) | ||
| string (TOUPPER ${_name} _upper_name) | ||
|
|
||
| # protect against running it a second time | ||
| if (NOT DEFINED ${_upper_name}_FOUND) | ||
|
|
||
| # find the name of the home variable and get it from the environment | ||
| set (_home_name "${_upper_name}_HOME") | ||
| if (DEFINED ENV{${_home_name}}) | ||
| set(_home "$ENV{${_home_name}}") | ||
| elseif (DEFINED ${_home_name}) | ||
| set(_home ${${_home_name}}) | ||
| endif () | ||
|
||
|
|
||
| # If <name>_HOME is set, use that alone as the path, otherwise use | ||
| # PACKAGE_SEARCH_PATH ahead of the default_path. | ||
| if(DEFINED _home AND NOT ${_home} STREQUAL "") | ||
| set(_no_default TRUE) | ||
| else() | ||
| set(_no_default FALSE) | ||
| endif() | ||
|
|
||
| set (_include_dir "${h_file}-NOTFOUND") | ||
| if (_no_default) | ||
| find_path (_include_dir ${h_file} | ||
| PATHS ${_home} NO_DEFAULT_PATH | ||
| PATH_SUFFIXES "include") | ||
| else () | ||
| find_path (_include_dir ${h_file} | ||
| PATH_SUFFIXES "include") | ||
| endif (_no_default) | ||
|
|
||
| set(_libraries) | ||
| foreach (lib ${lib_names}) | ||
| expandLibName(${lib} ${allow_any} _full) | ||
| set (_match "${_full}-NOTFOUND") | ||
| if (_no_default) | ||
| find_library (_match NAMES ${_full} | ||
| PATHS ${_home} | ||
| NO_DEFAULT_PATH | ||
| PATH_SUFFIXES "lib" "lib64") | ||
| else () | ||
| find_library (_match NAMES ${_full} | ||
| HINTS ${_include_dir}/.. | ||
| PATH_SUFFIXES "lib" "lib64") | ||
| endif (_no_default) | ||
| if (_match) | ||
| list (APPEND _libraries ${_match}) | ||
| endif () | ||
| unset(_full) | ||
| endforeach () | ||
|
|
||
| list (LENGTH _libraries _libraries_len) | ||
| list (LENGTH lib_names _name_len) | ||
|
|
||
| if (_include_dir AND _libraries_len EQUAL _name_len) | ||
| message (STATUS "Found the ${_name} header: ${_include_dir}") | ||
| if (NOT _libraries_len EQUAL 0) | ||
| message (STATUS "Found the ${_name} libraries: ${_libraries}") | ||
| endif () | ||
| set(${_upper_name}_FOUND TRUE PARENT_SCOPE) | ||
| set(${_upper_name}_INCLUDE_DIR ${_include_dir} PARENT_SCOPE) | ||
| set(${_upper_name}_LIBRARIES "${_libraries}" PARENT_SCOPE) | ||
|
|
||
|
||
| # Create the libraries | ||
| set(i 0) | ||
| foreach (lib ${lib_names}) | ||
| list (GET _libraries ${i} _path) | ||
| if (NOT TARGET ${lib}) | ||
| if (BUILD_SHARED_LIBRARIES) | ||
| add_library(${lib} SHARED IMPORTED) | ||
| else () | ||
| add_library(${lib} STATIC IMPORTED) | ||
| endif (BUILD_SHARED_LIBRARIES) | ||
| set_target_properties(${lib} PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES ${_include_dir}) | ||
| set_property(TARGET ${lib} APPEND PROPERTY | ||
| IMPORTED_LOCATION ${_path}) | ||
| endif () | ||
| math(EXPR i ${i}+1) | ||
| endforeach () | ||
| elseif (${_name}_FIND_REQUIRED) | ||
| message (STATUS "ERROR: Did not find required library ${_name}") | ||
| message (STATUS "Include dir: ${_include_dir}") | ||
| message (STATUS "Libraries: ${lib_names} -> ${_libraries}") | ||
| message (STATUS "Search path: ${CMAKE_PREFIX_PATH}") | ||
| message (FATAL_ERROR "STOP: Did not find ${_name} for ${CMAKE_CURRENT_SOURCE_DIR}") | ||
| else () | ||
| message (STATUS "Did not find ${_name}") | ||
| endif () | ||
| else () | ||
| message (STATUS "Skipped checking ${_name}") | ||
| endif () | ||
| endfunction (findPackageExtension) | ||
|
|
||
| function (expandLibName name allow_any result) | ||
| if (allow_any) | ||
| set(${result} ${name} PARENT_SCOPE) | ||
| elseif (BUILD_SHARED_LIBS) | ||
| set(${result} | ||
| "${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX}" | ||
| PARENT_SCOPE) | ||
| else () | ||
| set(${result} | ||
| "${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}" | ||
| PARENT_SCOPE) | ||
| endif (allow_any) | ||
| endfunction (expandLibName) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/FindPackageExtension.cmake) | ||
|
|
||
| if (NOT PROTOBUF_FOUND) | ||
| findPackageExtension("google/protobuf/io/coded_stream.h" "protobuf;protoc" | ||
| false) | ||
|
|
||
| if (PROTOBUF_FOUND) | ||
| find_program(PROTOBUF_PROTOC_EXECUTABLE protoc | ||
| HINTS ${PROTOBUF_INCLUDE_DIR}/.. | ||
| PATH_SUFFIXES "bin") | ||
| message (STATUS | ||
| "Found the Protobuf executable: ${PROTOBUF_PROTOC_EXECUTABLE}") | ||
| endif () | ||
| endif () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace:end of line