More CMake work. Thanks to Mr-Hide in irc.freenode.net/#cmake.
This commit is contained in:
parent
ec730962aa
commit
0fff9c6fd6
|
@ -6,8 +6,24 @@ set(CMAKE_CONFIGURATION_TYPES Debug Static Release ReleaseStatic)
|
||||||
# we load the variables after calling project()
|
# we load the variables after calling project()
|
||||||
# default to Debug if no configuration specified
|
# default to Debug if no configuration specified
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
# the CACHE FORCE is necessary for this to work properly
|
||||||
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type; one of: Debug Release Static ReleaseStatic" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
# and save whether this is shared in a variable
|
||||||
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||||
|
set(_SHARED TRUE)
|
||||||
|
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||||
|
set(_SHARED TRUE)
|
||||||
|
endif()
|
||||||
|
if(WIN32)
|
||||||
|
if(NOT MSVC)
|
||||||
|
if(_SHARED)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Sorry, libui for Windows cannot be built as a DLL with MinGW. You will need to either build as a static library or build with MSVC.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# and we need to set this up prior to project() too
|
# and we need to set this up prior to project() too
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")
|
||||||
|
@ -25,18 +41,6 @@ cfgcopy(CMAKE_SHARED_LINKER_FLAGS)
|
||||||
cfgcopy(CMAKE_STATIC_LINKER_FLAGS)
|
cfgcopy(CMAKE_STATIC_LINKER_FLAGS)
|
||||||
cfgcopy(CMAKE_EXE_LINKER_FLAGS)
|
cfgcopy(CMAKE_EXE_LINKER_FLAGS)
|
||||||
|
|
||||||
set(_NOSHARED FALSE)
|
|
||||||
if(WIN32)
|
|
||||||
if(NOT MSVC)
|
|
||||||
set(_NOSHARED TRUE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
macro(nosharedmingw _target)
|
|
||||||
add_custom_target(${_target}
|
|
||||||
COMMAND exit 1
|
|
||||||
COMMENT "Sorry, libui for Windows cannot be built as a DLL with MinGW. You will need to either build as a static library or build with MSVC.")
|
|
||||||
endmacro(nosharedmingw)
|
|
||||||
|
|
||||||
macro(append _var _val)
|
macro(append _var _val)
|
||||||
set(${_var} "${${_var}} ${_val}")
|
set(${_var} "${${_var}} ${_val}")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
@ -122,3 +126,21 @@ append2(CMAKE_EXE_LINKER_FLAGS_STATIC CMAKE_EXE_LINKER_FLAGS_RUNTIMESTATIC
|
||||||
" ${_PLATFORM_LIBS}")
|
" ${_PLATFORM_LIBS}")
|
||||||
|
|
||||||
add_subdirectory("common")
|
add_subdirectory("common")
|
||||||
|
add_subdirectory("${_OSDIR}")
|
||||||
|
if(_SHARED)
|
||||||
|
add_library(libui SHARED
|
||||||
|
$<TARGET_OBJECTS:libui-common>
|
||||||
|
$<TARGET_OBJECTS:libui-${_OSDIR}>
|
||||||
|
)
|
||||||
|
if(_SETVERSION)
|
||||||
|
set_target_properties(libui PROPERTIES
|
||||||
|
SOVERSION "${_VERSION}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
_add_static(libui
|
||||||
|
$<TARGET_OBJECTS:libui-common>
|
||||||
|
$<TARGET_OBJECTS:libui-${_OSDIR}>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
set_target_properties(libui PROPERTIES
|
||||||
|
OUTPUT_NAME ui)
|
||||||
|
|
|
@ -12,5 +12,4 @@ add_library(libui-common OBJECT
|
||||||
)
|
)
|
||||||
set_target_properties(libui-common PROPERTIES
|
set_target_properties(libui-common PROPERTIES
|
||||||
COMPILE_FLAGS "${_LIBUI_CFLAGS}"
|
COMPILE_FLAGS "${_LIBUI_CFLAGS}"
|
||||||
LINK_FLAGS "${_LIBUI_LDFLAGS}"
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
# 31 may 2016
|
||||||
|
|
||||||
|
include_directories(.. . ../common)
|
||||||
|
|
||||||
|
add_library(libui-darwin OBJECT
|
||||||
|
alloc.m
|
||||||
|
area.m
|
||||||
|
areaevents.m
|
||||||
|
autolayout.m
|
||||||
|
box.m
|
||||||
|
button.m
|
||||||
|
checkbox.m
|
||||||
|
colorbutton.m
|
||||||
|
combobox.m
|
||||||
|
control.m
|
||||||
|
datetimepicker.m
|
||||||
|
debug.m
|
||||||
|
draw.m
|
||||||
|
drawtext.m
|
||||||
|
editablecombo.m
|
||||||
|
entry.m
|
||||||
|
fontbutton.m
|
||||||
|
group.m
|
||||||
|
label.m
|
||||||
|
main.m
|
||||||
|
map.m
|
||||||
|
menu.m
|
||||||
|
multilineentry.m
|
||||||
|
progressbar.m
|
||||||
|
radiobuttons.m
|
||||||
|
scrollview.m
|
||||||
|
separator.m
|
||||||
|
slider.m
|
||||||
|
spinbox.m
|
||||||
|
stddialogs.m
|
||||||
|
tab.m
|
||||||
|
text.m
|
||||||
|
util.m
|
||||||
|
window.m
|
||||||
|
)
|
||||||
|
set_target_properties(libui-darwin PROPERTIES
|
||||||
|
COMPILE_FLAGS "${_LIBUI_CFLAGS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
macro(_add_static _name)
|
||||||
|
add_library(${_name} STATIC "${ARGN}")
|
||||||
|
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/sharedhidden)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${_name} POST_BUILD
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_AR} x $<TARGET_FILE:${_name}>
|
||||||
|
COMMAND
|
||||||
|
nm -m *.o | sed -E -n "'s/^[0-9a-f]* \\([A-Z_]+,[a-z_]+\\) external //p'" > ${_name}.lst
|
||||||
|
COMMAND
|
||||||
|
ld -exported_symbols_list ${_name}.lst -r *.o -o ../_combined_${_name}.o
|
||||||
|
COMMAND
|
||||||
|
rm $<TARGET_FILE:${_name}>
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_AR} rcs $<TARGET_FILE:${_name}> ../_combined_${_name}.o
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/sharedhidden
|
||||||
|
COMMENT "Removing hidden symbols")
|
||||||
|
endmacro()
|
Loading…
Reference in New Issue