Skip to content
Snippets Groups Projects
Commit db7d059f authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos
Browse files

Add deprecation warning on old exported names

parent 3d25332d
No related branches found
No related tags found
1 merge request!1247Export targets under custom namespaces (Dune:: by default)
......@@ -14,7 +14,7 @@ include(DuneMacros)
dune_project()
# Create the module library for dune-common
dune_add_library(dunecommon)
dune_add_library(dunecommon EXPORT_NAME Common)
# minimal c++ standard required
target_compile_features(dunecommon PUBLIC cxx_std_17)
......
......@@ -186,9 +186,13 @@ function(dune_add_library_normal _name)
set(${ProjectName}_EXPORT_SET ${ProjectName}-targets CACHE INTERNAL "")
endif()
# Register library in global property <module>LIBRARIES
if(NOT ARG_NO_MODULE_LIBRARY)
# Register library in global property <module>LIBRARIES
set_property(GLOBAL APPEND PROPERTY ${ProjectName}_LIBRARIES Dune::${ARG_EXPORT_NAME})
if(NOT ARG_NO_EXPORT)
set_property(GLOBAL APPEND PROPERTY ${ProjectName}_LIBRARIES_ALIASES "${_name}:=Dune::${ARG_EXPORT_NAME}")
get_property(_library_aliases GLOBAL PROPERTY ${ProjectName}_LIBRARIES_ALIASES)
endif()
endif()
endfunction(dune_add_library_normal)
......@@ -214,6 +218,7 @@ function(dune_add_library_interface _name)
if(NOT ARG_EXPORT_NAME)
set(ARG_EXPORT_NAME ${_name})
endif()
add_library(Dune::${ARG_EXPORT_NAME} ALIAS ${_name})
......@@ -231,6 +236,9 @@ function(dune_add_library_interface _name)
# Register library in global property <module>_LIBRARIES
if(NOT ARG_NO_MODULE_LIBRARY)
set_property(GLOBAL APPEND PROPERTY ${ProjectName}_LIBRARIES Dune::${ARG_EXPORT_NAME})
if(NOT ARG_NO_EXPORT)
set_property(GLOBAL APPEND PROPERTY ${ProjectName}_LIBRARIES_ALIASES "${_name}:=Dune::${ARG_EXPORT_NAME}")
endif()
endif()
endfunction(dune_add_library_interface)
......
......@@ -86,7 +86,7 @@ function(dune_add_pybind11_module)
endif()
target_compile_definitions(${PYBIND11_MODULE_NAME} PRIVATE ${PYBIND11_MODULE_COMPILE_DEFINITIONS})
target_link_libraries(${PYBIND11_MODULE_NAME} PUBLIC dunecommon)
target_link_libraries(${PYBIND11_MODULE_NAME} PUBLIC Dune::Common)
dune_target_enable_all_packages(${PYBIND11_MODULE_NAME})
if(PYBIND11_MODULE_EXCLUDE_FROM_ALL)
......
......@@ -87,6 +87,11 @@ macro(dune_project)
define_property(GLOBAL PROPERTY ${ProjectName}_LIBRARIES
BRIEF_DOCS "List of libraries of the module. DO NOT EDIT!"
FULL_DOCS "List of libraries of the module. Used to generate CMake's package configuration files. DO NOT EDIT!")
define_property(GLOBAL PROPERTY ${ProjectName}_LIBRARIES_ALIASES
BRIEF_DOCS "List of library aliases of the module. DO NOT EDIT!"
FULL_DOCS "List of libraries aliases of the module. Used to generate CMake's package configuration files. DO NOT EDIT!")
dune_create_dependency_tree()
# assert the project names matches
......@@ -207,6 +212,7 @@ ${DUNE_CUSTOM_PKG_CONFIG_SECTION}
if(${ProjectName}_LIBRARIES)
get_filename_component(_dir \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)
include(\"\${_dir}/${ProjectName}-targets.cmake\")
@DUNE_DEPRECATED_LIBRARY_ALIASES@
endif()
endif()")
......@@ -228,6 +234,28 @@ endif()")
set(DUNE_INSTALL_LIBDIR ${DUNE_INSTALL_NONOBJECTLIBDIR})
endif()
# setup deprecated aliases
get_property(_library_aliases GLOBAL PROPERTY ${ProjectName}_LIBRARIES_ALIASES)
set(DUNE_DEPRECATED_LIBRARY_ALIASES "")
foreach(_alias "${_library_aliases}")
string(FIND "${_alias}" ":=" _pos)
if(NOT _pos EQUAL "-1")
string(SUBSTRING "${_alias}" 0 ${_pos} _alias_name)
math(EXPR _pos "${_pos}+2")
string(SUBSTRING "${_alias}" ${_pos} -1 _export_name)
set(DUNE_DEPRECATED_LIBRARY_ALIASES "${DUNE_DEPRECATED_LIBRARY_ALIASES}
add_library(${_alias_name} INTERFACE)
target_link_libraries(${_alias_name} INTERFACE ${_export_name})
if(CMAKE_VERSION VERSION_GREATER_EQUAL \"3.17\")
set_property(TARGET ${_alias_name} PROPERTY DEPRECATION \"Use ${_export_name} instead.\")
endif()")
unset(_alias_name)
unset(_export_name)
endif()
unset(_pos)
endforeach(_alias)
unset(_library_aliases)
# Set the location of the doc file source. Needed by custom package configuration
# file section of dune-grid.
set(DUNE_MODULE_SRC_DOCDIR "${PROJECT_SOURCE_DIR}/doc")
......
......@@ -343,7 +343,7 @@ function(dune_add_test)
endif()
# add some default libraries to link against
list(APPEND ADDTEST_LINK_LIBRARIES dunecommon)
list(APPEND ADDTEST_LINK_LIBRARIES Dune::Common)
list(REMOVE_DUPLICATES ADDTEST_LINK_LIBRARIES)
# Add the executable if it is not already present
......
......@@ -16,7 +16,7 @@ set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
set(@DUNE_MOD_NAME@_LIBRARIES "dunecommon")
set(@DUNE_MOD_NAME@_LIBRARIES Dune::Common)
set_and_check(@DUNE_MOD_NAME@_SCRIPT_DIR "@PACKAGE_SCRIPT_DIR@")
set_and_check(DOXYSTYLE_FILE "@PACKAGE_DOXYSTYLE_DIR@/Doxystyle")
set_and_check(DOXYGENMACROS_FILE "@PACKAGE_DOXYSTYLE_DIR@/doxygen-macros")
......@@ -26,3 +26,9 @@ set(@DUNE_MOD_NAME@_HASPYTHON 1)
set(@DUNE_MOD_NAME@_PYTHONREQUIRES "@DUNE_MODULE_PYTHONREQUIRES@")
set_and_check(@DUNE_MOD_NAME@_MODULE_PATH "@PACKAGE_DUNE_INSTALL_MODULEDIR@")
endif(NOT @DUNE_MOD_NAME@_FOUND)
add_library(dunecommon INTERFACE)
target_link_libraries(dunecommon INTERFACE Dune::Common)
if(CMAKE_VERSION VERSION_GREATER_EQUAL \"3.17\")
set_property(TARGET dunecommon PROPERTY DEPRECATION \"Use Dune::Common instead.\")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment