CMake: Improve library names
Use the same output names as MSVC and makefile.gcc/vc on Windows, and the same as configure on other platforms.
This commit is contained in:
@@ -18,6 +18,14 @@ endif()
|
||||
include(cotire) # For precompiled header handling
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
# Use the MSVC/makefile naming convention, or the configure naming convention,
|
||||
# this is the same check as used in FindwxWidgets.
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
set(WIN32_MSVC_NAMING 1)
|
||||
else()
|
||||
set(WIN32_MSVC_NAMING 0)
|
||||
endif()
|
||||
|
||||
# This function adds a list of headers to a variable while prepending
|
||||
# include/ to the path
|
||||
macro(wx_add_headers src_var)
|
||||
@@ -148,81 +156,95 @@ function(wx_set_target_properties target_name is_base)
|
||||
else()
|
||||
set(lib_toolkit ${wxBUILD_TOOLKIT}${wxBUILD_WIDGETSET})
|
||||
endif()
|
||||
if(MSVC)
|
||||
|
||||
if(WIN32_MSVC_NAMING)
|
||||
set(lib_version ${wxMAJOR_VERSION}${wxMINOR_VERSION})
|
||||
else()
|
||||
set(lib_version ${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
||||
endif()
|
||||
set(dll_version ${wxMAJOR_VERSION}${wxMINOR_VERSION})
|
||||
if(wxVERSION_IS_DEV)
|
||||
wx_string_append(dll_version ${wxRELEASE_NUMBER})
|
||||
endif()
|
||||
|
||||
set(lib_unicode)
|
||||
if(wxUSE_UNICODE)
|
||||
set(lib_unicode u)
|
||||
else()
|
||||
set(lib_unicode)
|
||||
set(lib_unicode "u")
|
||||
endif()
|
||||
|
||||
set(lib_rls)
|
||||
set(lib_dbg)
|
||||
set(lib_gen)
|
||||
if(WIN32_MSVC_NAMING)
|
||||
set(lib_dbg "d")
|
||||
set(lib_gen "$<$<CONFIG:Debug>:${lib_dbg}>")
|
||||
endif()
|
||||
|
||||
set(lib_suffix)
|
||||
if(NOT target_name_short STREQUAL "base" AND NOT target_name_short STREQUAL "mono")
|
||||
# Do not append library name for base library
|
||||
set(lib_suffix _${target_name_short})
|
||||
else()
|
||||
set(lib_suffix)
|
||||
# Do not append library name for base or mono library
|
||||
set(lib_suffix "_${target_name_short}")
|
||||
endif()
|
||||
set(lib_flavour "")
|
||||
if(wxBUILD_FLAVOUR)
|
||||
set(lib_flavour "_${wxBUILD_FLAVOUR}")
|
||||
string(REPLACE "-" "_" lib_flavour ${lib_flavour})
|
||||
set(lib_suffix "${lib_flavour}${lib_suffix}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
# match visual studio name
|
||||
set_target_properties(${target_name}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "wx${lib_toolkit}${lib_version}${lib_unicode}${lib_flavour}${lib_suffix}"
|
||||
OUTPUT_NAME_DEBUG "wx${lib_toolkit}${lib_version}${lib_unicode}d${lib_flavour}${lib_suffix}"
|
||||
PREFIX ""
|
||||
)
|
||||
else()
|
||||
# match configure name (mingw, cygwin)
|
||||
set_target_properties(${target_name}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "wx_${lib_toolkit}${lib_unicode}${lib_flavour}${lib_suffix}-${lib_version}"
|
||||
OUTPUT_NAME_DEBUG "wx_${lib_toolkit}${lib_unicode}d${lib_flavour}${lib_suffix}-${lib_version}"
|
||||
PREFIX "lib"
|
||||
)
|
||||
endif()
|
||||
set(dll_suffix "${lib_suffix}")
|
||||
if(wxCOMPILER_PREFIX)
|
||||
wx_string_append(dll_suffix "_${wxCOMPILER_PREFIX}")
|
||||
endif()
|
||||
if(wxBUILD_VENDOR AND wxVERSION_IS_DEV)
|
||||
wx_string_append(dll_suffix "_${wxBUILD_VENDOR}")
|
||||
endif()
|
||||
|
||||
if(wxBUILD_SHARED)
|
||||
# Add compiler type and or vendor
|
||||
set(dll_suffix "${lib_flavour}${lib_suffix}_${wxCOMPILER_PREFIX}")
|
||||
if(wxBUILD_VENDOR)
|
||||
wx_string_append(dll_suffix "_${wxBUILD_VENDOR}")
|
||||
endif()
|
||||
set(cross_target)
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(cross_target "-${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
set(dll_version ${wxMAJOR_VERSION}${wxMINOR_VERSION})
|
||||
if(wxVERSION_IS_DEV)
|
||||
wx_string_append(dll_version ${wxRELEASE_NUMBER})
|
||||
endif()
|
||||
set_target_properties(${target_name}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_NAME "wx${lib_toolkit}${dll_version}${lib_unicode}${dll_suffix}"
|
||||
RUNTIME_OUTPUT_NAME_DEBUG "wx${lib_toolkit}${dll_version}${lib_unicode}d${dll_suffix}"
|
||||
PREFIX ""
|
||||
)
|
||||
target_compile_definitions(${target_name} PRIVATE
|
||||
"-DWXDLLNAME=wx${lib_toolkit}${dll_version}${lib_unicode}$<$<CONFIG:Debug>:d>${dll_suffix}")
|
||||
endif()
|
||||
set(lib_prefix "lib")
|
||||
if(WIN32 AND wxBUILD_SHARED)
|
||||
set(lib_prefix)
|
||||
endif()
|
||||
|
||||
# static (and import) library names
|
||||
if(WIN32_MSVC_NAMING)
|
||||
# match msvc/makefile output name
|
||||
set(wxOUTPUT_NAME "wx${lib_toolkit}${lib_version}${lib_unicode}${lib_rls}${lib_suffix}")
|
||||
set(wxOUTPUT_NAME_DEBUG "wx${lib_toolkit}${lib_version}${lib_unicode}${lib_dbg}${lib_suffix}")
|
||||
else()
|
||||
set(cross_target "")
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(cross_target "-${CMAKE_SYSTEM_NAME}")
|
||||
endif ()
|
||||
|
||||
set_target_properties(${target_name}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME wx_${lib_toolkit}${lib_unicode}${lib_flavour}${lib_suffix}-${lib_version}${cross_target}
|
||||
# NOTE: wx-config can not be used to connect the libraries with the debug suffix.
|
||||
#OUTPUT_NAME_DEBUG wx_${lib_toolkit}${lib_unicode}d${lib_flavour}${lib_suffix}-${lib_version}${cross_target}
|
||||
OUTPUT_NAME_DEBUG wx_${lib_toolkit}${lib_unicode}${lib_flavour}${lib_suffix}-${lib_version}${cross_target}
|
||||
)
|
||||
# match configure output name
|
||||
set(wxOUTPUT_NAME "wx_${lib_toolkit}${lib_unicode}${lib_rls}${lib_suffix}-${lib_version}${cross_target}")
|
||||
set(wxOUTPUT_NAME_DEBUG "wx_${lib_toolkit}${lib_unicode}${lib_dbg}${lib_suffix}-${lib_version}${cross_target}")
|
||||
endif()
|
||||
|
||||
# shared library names
|
||||
if(WIN32)
|
||||
# msvc/makefile/configure use the same format on Windows
|
||||
set(wxRUNTIME_OUTPUT_NAME "wx${lib_toolkit}${dll_version}${lib_unicode}${lib_rls}${dll_suffix}")
|
||||
set(wxRUNTIME_OUTPUT_NAME_DEBUG "wx${lib_toolkit}${dll_version}${lib_unicode}${lib_dbg}${dll_suffix}")
|
||||
set(wxDLLNAME "wx${lib_toolkit}${dll_version}${lib_unicode}${lib_gen}${dll_suffix}")
|
||||
else()
|
||||
# match configure on linux/mac
|
||||
set(wxRUNTIME_OUTPUT_NAME "wx_${lib_toolkit}${lib_unicode}${lib_rls}${dll_suffix}-${lib_version}${cross_target}")
|
||||
set(wxRUNTIME_OUTPUT_NAME_DEBUG "wx_${lib_toolkit}${lib_unicode}${lib_dbg}${dll_suffix}-${lib_version}${cross_target}")
|
||||
set(wxDLLNAME "wx_${lib_toolkit}${lib_unicode}${lib_gen}${dll_suffix}-${lib_version}${cross_target}")
|
||||
endif()
|
||||
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
OUTPUT_NAME "${wxOUTPUT_NAME}"
|
||||
OUTPUT_NAME_DEBUG "${wxOUTPUT_NAME_DEBUG}"
|
||||
RUNTIME_OUTPUT_NAME "${wxRUNTIME_OUTPUT_NAME}"
|
||||
RUNTIME_OUTPUT_NAME_DEBUG "${wxRUNTIME_OUTPUT_NAME_DEBUG}"
|
||||
PREFIX "${lib_prefix}"
|
||||
)
|
||||
|
||||
if(wxBUILD_SHARED)
|
||||
target_compile_definitions(${target_name} PRIVATE "WXDLLNAME=${wxDLLNAME}")
|
||||
endif()
|
||||
|
||||
if(CYGWIN)
|
||||
target_link_libraries(${target_name} PUBLIC -L/usr/lib/w32api)
|
||||
endif()
|
||||
@@ -371,10 +393,15 @@ macro(wx_add_library name)
|
||||
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
|
||||
|
||||
# Setup install
|
||||
set(runtime_dir "lib")
|
||||
if(WIN32 AND NOT WIN32_MSVC_NAMING)
|
||||
# configure puts the .dll in the bin directory
|
||||
set(runtime_dir "bin")
|
||||
endif()
|
||||
wx_install(TARGETS ${name}
|
||||
LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
||||
ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
||||
RUNTIME DESTINATION "lib${wxPLATFORM_LIB_DIR}"
|
||||
RUNTIME DESTINATION "${runtime_dir}${wxPLATFORM_LIB_DIR}"
|
||||
BUNDLE DESTINATION Applications/wxWidgets
|
||||
)
|
||||
endif()
|
||||
@@ -474,25 +501,27 @@ endmacro()
|
||||
|
||||
# Set common properties for a builtin third party library
|
||||
function(wx_set_builtin_target_properties target_name)
|
||||
set(lib_unicode)
|
||||
if(wxUSE_UNICODE AND target_name STREQUAL "wxregex")
|
||||
set(lib_unicode u)
|
||||
else()
|
||||
set(lib_unicode)
|
||||
set(lib_unicode "u")
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
set(postfix -${wxMAJOR_VERSION}.${wxMINOR_VERSION})
|
||||
|
||||
set(lib_rls)
|
||||
set(lib_dbg)
|
||||
if(WIN32_MSVC_NAMING)
|
||||
set(lib_dbg "d")
|
||||
endif()
|
||||
set_target_properties(${target_name}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME ${target_name}${lib_unicode}${postfix}
|
||||
)
|
||||
if(WIN32)
|
||||
set_target_properties(${target_name}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME_DEBUG ${target_name}${lib_unicode}d
|
||||
)
|
||||
|
||||
set(lib_version)
|
||||
if(NOT WIN32_MSVC_NAMING)
|
||||
set(lib_version "-${wxMAJOR_VERSION}.${wxMINOR_VERSION}")
|
||||
endif()
|
||||
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
OUTPUT_NAME "${target_name}${lib_unicode}${lib_rls}${lib_version}"
|
||||
OUTPUT_NAME_DEBUG "${target_name}${lib_unicode}${lib_dbg}${lib_version}"
|
||||
)
|
||||
|
||||
if(wxUSE_UNICODE)
|
||||
if(WIN32)
|
||||
target_compile_definitions(${target_name} PUBLIC UNICODE)
|
||||
@@ -701,7 +730,7 @@ function(wx_add name group)
|
||||
set(SUB_DIR "tests/benchmarks")
|
||||
set(DEFAULT_RC_FILE "samples/sample.rc")
|
||||
else()
|
||||
message(WARNING "Unkown group \"${group}\"")
|
||||
message(WARNING "Unknown group \"${group}\"")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
@@ -129,9 +129,11 @@ if(wxBUILD_FLAVOUR)
|
||||
endif()
|
||||
|
||||
set(wxARCH_SUFFIX)
|
||||
set(wxCOMPILER_PREFIX)
|
||||
set(wxPLATFORM_LIB_DIR)
|
||||
|
||||
# TODO: include compiler version in wxCOMPILER_PREFIX ?
|
||||
if(WIN32)
|
||||
# TODO: include compiler version in wxCOMPILER_PREFIX for official builds
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
set(wxCOMPILER_PREFIX "vc")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
@@ -145,21 +147,17 @@ if(WIN32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(wxARCH_SUFFIX "_x64")
|
||||
endif()
|
||||
else()
|
||||
set(wxCOMPILER_PREFIX)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(WIN32_MSVC_NAMING)
|
||||
if(wxBUILD_SHARED)
|
||||
set(lib_suffix "dll")
|
||||
set(lib_suffix "_dll")
|
||||
else()
|
||||
set(lib_suffix "lib")
|
||||
set(lib_suffix "_lib")
|
||||
endif()
|
||||
|
||||
# Include generator expression to suppress default Debug/Release pair
|
||||
set(wxPLATFORM_LIB_DIR "$<1:/>${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_${lib_suffix}")
|
||||
else()
|
||||
set(wxPLATFORM_LIB_DIR)
|
||||
set(wxPLATFORM_LIB_DIR "$<1:/>${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}${lib_suffix}")
|
||||
endif()
|
||||
|
||||
if(wxBUILD_CUSTOM_SETUP_HEADER_PATH)
|
||||
@@ -169,14 +167,14 @@ if(wxBUILD_CUSTOM_SETUP_HEADER_PATH)
|
||||
set(wxSETUP_HEADER_PATH ${wxBUILD_CUSTOM_SETUP_HEADER_PATH})
|
||||
else()
|
||||
# Set path where setup.h will be created
|
||||
if(MSVC)
|
||||
if(WIN32_MSVC_NAMING)
|
||||
if(wxUSE_UNICODE)
|
||||
set(lib_unicode u)
|
||||
else()
|
||||
set(lib_unicode)
|
||||
endif()
|
||||
set(wxSETUP_HEADER_PATH
|
||||
${wxOUTPUT_DIR}/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_${lib_suffix}/${wxBUILD_TOOLKIT}${lib_unicode})
|
||||
${wxOUTPUT_DIR}/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}${lib_suffix}/${wxBUILD_TOOLKIT}${lib_unicode})
|
||||
file(MAKE_DIRECTORY ${wxSETUP_HEADER_PATH}/wx)
|
||||
file(MAKE_DIRECTORY ${wxSETUP_HEADER_PATH}d/wx)
|
||||
set(wxSETUP_HEADER_FILE_DEBUG ${wxSETUP_HEADER_PATH}d/wx/setup.h)
|
||||
|
@@ -12,13 +12,15 @@ if(NOT wxBUILD_INSTALL)
|
||||
endif()
|
||||
|
||||
install(CODE "message(STATUS \"Installing: Headers...\")")
|
||||
if(MSVC)
|
||||
if(WIN32_MSVC_NAMING)
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/wx"
|
||||
DESTINATION "include")
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/msvc"
|
||||
DESTINATION "include")
|
||||
if(MSVC)
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/msvc"
|
||||
DESTINATION "include")
|
||||
endif()
|
||||
else()
|
||||
wx_install(
|
||||
DIRECTORY "${wxSOURCE_DIR}/include/wx"
|
||||
@@ -26,7 +28,7 @@ else()
|
||||
endif()
|
||||
|
||||
# setup header and wx-config
|
||||
if(MSVC)
|
||||
if(WIN32_MSVC_NAMING)
|
||||
wx_install(
|
||||
DIRECTORY "${wxSETUP_HEADER_PATH}"
|
||||
DESTINATION "lib${wxPLATFORM_LIB_DIR}")
|
||||
@@ -60,11 +62,14 @@ else()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ${UNINST_NAME})
|
||||
# these files are not added to the install manifest
|
||||
set(WX_EXTRA_UNINSTALL_FILES
|
||||
"${CMAKE_INSTALL_PREFIX}/bin/wx-config"
|
||||
"${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION}"
|
||||
# these symlinks are not included in the install manifest
|
||||
set(WX_EXTRA_UNINSTALL_FILES)
|
||||
if(NOT WIN32_MSVC_NAMING)
|
||||
set(WX_EXTRA_UNINSTALL_FILES
|
||||
"${CMAKE_INSTALL_PREFIX}/bin/wx-config"
|
||||
"${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION}"
|
||||
)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${wxSOURCE_DIR}/build/cmake/uninstall.cmake.in"
|
||||
|
@@ -25,13 +25,13 @@ if(wxUSE_XRC)
|
||||
BUNDLE DESTINATION "bin"
|
||||
)
|
||||
|
||||
if(IPHONE)
|
||||
set(EXE_SUFFIX ".app")
|
||||
else()
|
||||
set(EXE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX})
|
||||
endif()
|
||||
if(NOT WIN32_MSVC_NAMING)
|
||||
if(IPHONE)
|
||||
set(EXE_SUFFIX ".app")
|
||||
else()
|
||||
set(EXE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX})
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
install(CODE "execute_process( \
|
||||
COMMAND ${CMAKE_COMMAND} -E rename \
|
||||
${CMAKE_INSTALL_PREFIX}/bin/wxrc${EXE_SUFFIX} \
|
||||
|
Reference in New Issue
Block a user