From 0c2d05f52fc83673a0c38261c9258d1ccd780301 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 17 May 2020 19:41:33 +0200 Subject: [PATCH] CMake: add library aliases using wx:: namespace --- build/cmake/functions.cmake | 9 +++++++++ build/cmake/policies.cmake | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 1aafa4a983..3d93ac9e09 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -334,6 +334,7 @@ macro(wx_add_library name) endif() add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files}) + add_library(wx::${name} ALIAS ${name}) wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE}) # Setup install @@ -501,7 +502,15 @@ endfunction() # Add a third party builtin library function(wx_add_builtin_library name) 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(wx::${name_short} ALIAS ${name}) wx_set_builtin_target_properties(${name}) if(wxBUILD_SHARED) set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) diff --git a/build/cmake/policies.cmake b/build/cmake/policies.cmake index 14aaeef17a..1a7415d0e1 100644 --- a/build/cmake/policies.cmake +++ b/build/cmake/policies.cmake @@ -14,6 +14,11 @@ if(POLICY CMP0025) cmake_policy(SET CMP0025 NEW) endif() +if(POLICY CMP0028) + # Double colon in target name means ALIAS or IMPORTED target. + cmake_policy(SET CMP0028 NEW) +endif() + if(POLICY CMP0038) # targets may not link directly to themselves cmake_policy(SET CMP0038 NEW)