Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reactivate install
Browse files Browse the repository at this point in the history
assignUser committed May 28, 2024
1 parent 01f1866 commit f651ccb
Showing 1 changed file with 54 additions and 11 deletions.
65 changes: 54 additions & 11 deletions CMake/VeloxUtils.cmake
Original file line number Diff line number Diff line change
@@ -11,15 +11,23 @@
# 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_guard(GLOBAL)

function(velox_add_dependencies TARGET)
if(VELOX_MONO_LIBRARY AND "${TARGET}" MATCHES "^velox_*")

else()
add_dependencies(${TARGET} ${ARGN})
endif()
endfunction()

# TODO use file sets
function(velox_install_library_headers)
# Find any headers and install them relative to the source tree in include.
file(GLOB _hdrs "*.h")
if(NOT "${_hdrs}" STREQUAL "")
cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR
BASE_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE _hdr_dir)
cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY
"${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE _hdr_dir)
install(FILES ${_hdrs} DESTINATION include/${_hdr_dir})
endif()
endfunction()
@@ -28,11 +36,30 @@ endfunction()
function(velox_base_add_library TARGET)
add_library(${TARGET} ${ARGN})
install(TARGETS ${TARGET} DESTINATION lib/velox)
# velox_install_library_headers()
velox_install_library_headers()
endfunction()

# This is extremely hackish but presents an easy path to installation.
function(velox_add_library TARGET)
set(options OBJECT STATIC SHARED)
set(oneValueArgs)
set(multiValueArgs)
cmake_parse_arguments(VELOX "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})

# Remove library type specifiers from ARGN
set(library_type)
if(VELOX_OBJECT)
set(library_type OBJECT)
elseif(VELOX_STATIC)
set(library_type STATIC)
elseif(VELOX_SHARED)
set(library_type SHARED)
endif()

list(REMOVE_ITEM ARGN OBJECT)
list(REMOVE_ITEM ARGN STATIC)
list(REMOVE_ITEM ARGN SHARED)
# Propagate to the underlying add_library and then install the target.
if(VELOX_MONO_LIBRARY)
if(TARGET velox)
@@ -41,25 +68,33 @@ function(velox_add_library TARGET)
else()
# Create the target if this is the first invocation.
add_library(velox ${ARGN})
set_target_properties(velox PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set_target_properties(velox PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib)
set_target_properties(velox PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib)
install(TARGETS velox DESTINATION lib/velox)
endif()
# create alias for compatability
if(NOT TARGET ${TARGET})
add_library(${TARGET} ALIAS velox)
endif()
else()
# Create a library for each invocation.
velox_base_add_library(${TARGET} ${ARGN})
velox_base_add_library(${TARGET} ${library_type} ${ARGN})
endif()
# velox_install_library_headers()
velox_install_library_headers()
endfunction()

function(velox_link_libraries TARGET)
# TODO(assignUser): Handle scope keywords
# (they currently are empty calls ala target_link_libraries(target PRIVATE))
if(VELOX_MONO_LIBRARY)
message(STATUS "${TARGET}: ${ARGN}")
message(DEBUG "${TARGET}: ${ARGN}")
foreach(_lib ${ARGN})
if("${_lib}" MATCHES "^velox_*")
message(STATUS "\t\tDROP: ${_lib}")
message(DEBUG "\t\tDROP: ${_lib}")
else()
message(STATUS "\t\tADDING: ${_lib}")
message(DEBUG "\t\tADDING: ${_lib}")
target_link_libraries(velox ${_lib})
endif()
endforeach()
@@ -75,3 +110,11 @@ function(velox_include_directories TARGET)
target_include_directories(${TARGET} ${ARGN})
endif()
endfunction()

function(velox_compile_definitions TARGET)
if(VELOX_MONO_LIBRARY)
target_compile_definitions(velox ${ARGN})
else()
target_compile_definitions(${TARGET} ${ARGN})
endif()
endfunction()

0 comments on commit f651ccb

Please sign in to comment.