Normalize dashes in CMake package dependency names to underscores
Packages like `opentelemetry-cpp` export standard CMake variables
in the expected form `OPENTELEMETRY_CPP_LIBRARIES`, _not_ in the
form of `OPENTELEMETRY-CPP_LIBRARIES`. Implicitly normalize dashes
to underscores to fix this.
@@ -51,6 +51,7 @@ endfunction()
function(vespa_add_package_dependency PACKAGE_NAME)
find_package(${PACKAGE_NAME} REQUIRED)
string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME)
+ string(REPLACE "-" "_" PACKAGE_NAME ${PACKAGE_NAME})
set(PACKAGE_INCLUDE_DIR ${${PACKAGE_NAME}_INCLUDE_DIR})
set(PACKAGE_LIBRARIES ${${PACKAGE_NAME}_LIBRARIES})
link_libraries(${PACKAGE_LIBRARIES})
@@ -61,6 +62,7 @@ endfunction()
function(vespa_add_target_package_dependency TARGET PACKAGE_NAME)
find_package(${PACKAGE_NAME} REQUIRED)
string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME)
+ string(REPLACE "-" "_" PACKAGE_NAME ${PACKAGE_NAME})
set(PACKAGE_INCLUDE_DIR ${${PACKAGE_NAME}_INCLUDE_DIR})
set(PACKAGE_LIBRARIES ${${PACKAGE_NAME}_LIBRARIES})
target_link_libraries(${TARGET} PUBLIC ${PACKAGE_LIBRARIES})
