Fixed Windows static linking issues.
This commit is contained in:
parent
edbbe6eb59
commit
7d2f364256
|
@ -2,7 +2,6 @@
|
|||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
# TODOs:
|
||||
# - Windows: static linking does not include the .res file in out\, so executables lack the necessary resources
|
||||
# - Darwin, Unix: static linking temporary target makes PUBLIC properties not propagate
|
||||
|
||||
# the docs say we need to set this up prior to project()
|
||||
|
@ -123,8 +122,9 @@ if(BUILD_SHARED_LIBS)
|
|||
endif()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
_handle_static()
|
||||
# TODO this really should be PRIVATE but I haven't fully figured this out
|
||||
target_compile_definitions(${_LIBUINAME}
|
||||
PRIVATE _UI_STATIC)
|
||||
PUBLIC _UI_STATIC)
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
# on non-Windows platforms cmake adds an extra lib-
|
||||
|
@ -143,7 +143,7 @@ macro(_add_exec _name)
|
|||
add_executable(${_name}
|
||||
WIN32 EXCLUDE_FROM_ALL
|
||||
${ARGN})
|
||||
target_link_libraries(${_name} libui)
|
||||
target_link_libraries(${_name} libui ${_LIBUI_STATIC_RES})
|
||||
_target_link_options_private(${_name}
|
||||
_COMMON_LDFLAGS)
|
||||
# make shared-linked executables PIC too
|
||||
|
|
|
@ -60,9 +60,23 @@ list(APPEND _LIBUI_INCLUDEDIRS
|
|||
)
|
||||
set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE)
|
||||
|
||||
# no special handling of static libraries needed
|
||||
set(_LIBUINAME libui PARENT_SCOPE)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
set(_LIBUI_STATIC_RES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libui.res PARENT_SCOPE)
|
||||
endif()
|
||||
macro(_handle_static)
|
||||
if(MSVC)
|
||||
set(_res_suffix res)
|
||||
else()
|
||||
set(_res_suffix obj)
|
||||
endif()
|
||||
# TODO this full path feels hacky
|
||||
add_custom_command(
|
||||
TARGET libui PRE_LINK
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:libui,BINARY_DIR>/CMakeFiles/libui.dir/windows/resources.rc.${_res_suffix} ${_LIBUI_STATIC_RES}
|
||||
COMMENT "Copying libui.res")
|
||||
set(_res_suffix)
|
||||
endmacro()
|
||||
|
||||
# notice that usp10 comes before gdi32
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#pragma code_page(65001)
|
||||
|
||||
// this is the Common Controls 6 manifest
|
||||
// we only define it in a shared build; static builds have to include the appropriate parts of the manifest in the output executable
|
||||
// LONGTERM set up the string values here
|
||||
#ifndef _UI_STATIC
|
||||
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "libui.manifest"
|
||||
|
|
Loading…
Reference in New Issue