CMake: add library aliases using wx:: namespace

This commit is contained in:
Maarten Bent
2020-05-17 19:41:33 +02:00
parent 498b79d619
commit 0c2d05f52f
2 changed files with 14 additions and 0 deletions

View File

@@ -334,6 +334,7 @@ macro(wx_add_library name)
endif() endif()
add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files}) add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files})
add_library(wx::${name} ALIAS ${name})
wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE}) wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE})
# Setup install # Setup install
@@ -501,7 +502,15 @@ endfunction()
# Add a third party builtin library # Add a third party builtin library
function(wx_add_builtin_library name) function(wx_add_builtin_library name)
wx_list_add_prefix(src_list "${wxSOURCE_DIR}/" ${ARGN}) wx_list_add_prefix(src_list "${wxSOURCE_DIR}/" ${ARGN})
if(${name} MATCHES "wx.*")
string(SUBSTRING ${name} 2 -1 name_short)
else()
set(name_short ${name})
endif()
add_library(${name} STATIC ${src_list}) add_library(${name} STATIC ${src_list})
add_library(wx::${name_short} ALIAS ${name})
wx_set_builtin_target_properties(${name}) wx_set_builtin_target_properties(${name})
if(wxBUILD_SHARED) if(wxBUILD_SHARED)
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

View File

@@ -14,6 +14,11 @@ if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW) cmake_policy(SET CMP0025 NEW)
endif() endif()
if(POLICY CMP0028)
# Double colon in target name means ALIAS or IMPORTED target.
cmake_policy(SET CMP0028 NEW)
endif()
if(POLICY CMP0038) if(POLICY CMP0038)
# targets may not link directly to themselves # targets may not link directly to themselves
cmake_policy(SET CMP0038 NEW) cmake_policy(SET CMP0038 NEW)