2016-06-03 13:56:21 -05:00
|
|
|
# 3 june 2016
|
|
|
|
|
2016-06-03 20:14:55 -05:00
|
|
|
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
|
2016-06-03 13:56:21 -05:00
|
|
|
|
2016-06-03 18:25:43 -05:00
|
|
|
# problem:
|
|
|
|
# - target_link_libraries() only supports - for flags
|
|
|
|
# - but cmake only doesn't generate the manifest if the flag has a /
|
2016-06-03 16:30:00 -05:00
|
|
|
macro(_target_link_options_private _target)
|
|
|
|
foreach(_opt IN LISTS ${ARGN})
|
|
|
|
set_property(TARGET ${_target} APPEND_STRING PROPERTY
|
|
|
|
LINK_FLAGS " ${_opt}")
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
2016-06-03 13:56:21 -05:00
|
|
|
add_subdirectory("common")
|
|
|
|
add_subdirectory("${_OSNAME}")
|
2018-05-12 22:59:43 -05:00
|
|
|
add_library(libui ${_LIBUI_SOURCES})
|
|
|
|
target_include_directories(libui
|
2016-06-03 13:56:21 -05:00
|
|
|
PUBLIC .
|
|
|
|
PRIVATE ${_LIBUI_INCLUEDIRS})
|
2018-05-12 22:59:43 -05:00
|
|
|
target_compile_definitions(libui
|
2016-06-03 13:56:21 -05:00
|
|
|
PRIVATE ${_LIBUI_DEFS})
|
2016-06-03 21:19:33 -05:00
|
|
|
# cmake produces this for us by default but only for shared libraries
|
2018-05-12 22:59:43 -05:00
|
|
|
target_compile_definitions(libui
|
2016-06-03 21:19:33 -05:00
|
|
|
PRIVATE libui_EXPORTS)
|
2018-05-12 22:59:43 -05:00
|
|
|
target_compile_options(libui
|
2016-06-03 13:56:21 -05:00
|
|
|
PUBLIC ${_COMMON_CFLAGS}
|
|
|
|
PRIVATE ${_LIBUI_CFLAGS})
|
|
|
|
# TODO link directories?
|
2016-06-03 17:28:14 -05:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2018-05-12 22:59:43 -05:00
|
|
|
target_link_libraries(libui
|
2016-06-03 17:28:14 -05:00
|
|
|
PRIVATE ${_LIBUI_LIBS})
|
|
|
|
endif()
|
2016-06-17 09:13:46 -05:00
|
|
|
# TODO INTERFACE libs don't inherit to grandhcildren?
|
2016-06-03 13:56:21 -05:00
|
|
|
# on Windows the linker for static libraries is different; don't give it the flags
|
|
|
|
if(BUILD_SHARED_LIBS)
|
2018-05-12 22:59:43 -05:00
|
|
|
_target_link_options_private(libui
|
2016-06-03 16:30:00 -05:00
|
|
|
_COMMON_LDFLAGS
|
|
|
|
_LIBUI_LDFLAGS)
|
2016-06-03 13:56:21 -05:00
|
|
|
endif()
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
2016-06-04 17:52:40 -05:00
|
|
|
# TODO figure out a way to tell libui that it's static
|
2018-05-12 22:59:43 -05:00
|
|
|
target_compile_definitions(libui
|
2016-06-04 17:52:40 -05:00
|
|
|
PUBLIC _UI_STATIC)
|
2016-06-03 13:56:21 -05:00
|
|
|
endif()
|
2016-06-04 13:30:43 -05:00
|
|
|
if(NOT MSVC)
|
|
|
|
# on non-MSVC compilers cmake adds an extra lib-
|
2016-06-03 20:14:55 -05:00
|
|
|
# note that we apply this to libui, not to any intermediates
|
|
|
|
set_target_properties(libui PROPERTIES
|
|
|
|
OUTPUT_NAME ui)
|
2016-06-04 17:52:40 -05:00
|
|
|
|
|
|
|
# flags for warning on undefined symbols
|
|
|
|
# TODO figure out why FreeBSD follows linked libraries here
|
|
|
|
# TODO figure out MSVC equivalents
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD))
|
|
|
|
# on OS X we don't need to do this; Apple's linker warns about undefined symbols in -shared builds!
|
|
|
|
if(NOT APPLE)
|
|
|
|
target_link_libraries(libui
|
|
|
|
PRIVATE -Wl,--no-undefined -Wl,--no-allow-shlib-undefined
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-06-03 20:14:55 -05:00
|
|
|
endif()
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
if(_HASVERSION)
|
2018-05-12 22:59:43 -05:00
|
|
|
set_target_properties(libui PROPERTIES
|
2016-06-03 20:14:55 -05:00
|
|
|
SOVERSION "${_VERSION}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-09-01 19:37:05 -05:00
|
|
|
# TODO why is this not a default?!
|
|
|
|
set_property(TARGET libui PROPERTY
|
|
|
|
POSITION_INDEPENDENT_CODE True)
|
2016-06-03 13:56:21 -05:00
|
|
|
|
|
|
|
macro(_add_exec _name)
|
2017-02-22 02:43:43 -06:00
|
|
|
# TODOTODO re-add WIN32 when merging back
|
2016-06-03 13:56:21 -05:00
|
|
|
add_executable(${_name}
|
2017-02-22 02:43:43 -06:00
|
|
|
EXCLUDE_FROM_ALL
|
2016-06-03 13:56:21 -05:00
|
|
|
${ARGN})
|
2018-05-02 22:04:43 -05:00
|
|
|
target_link_libraries(${_name} libui)
|
2016-06-03 16:30:00 -05:00
|
|
|
_target_link_options_private(${_name}
|
|
|
|
_COMMON_LDFLAGS)
|
2018-09-01 19:37:05 -05:00
|
|
|
# TODO does this propagate?
|
|
|
|
set_property(TARGET ${_name} PROPERTY
|
|
|
|
POSITION_INDEPENDENT_CODE True)
|
2016-06-17 09:13:46 -05:00
|
|
|
# TODO see above about INTERFACE
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
target_link_libraries(${_name}
|
2016-06-17 09:16:53 -05:00
|
|
|
${_LIBUI_LIBS})
|
2016-06-17 09:13:46 -05:00
|
|
|
endif()
|
2016-06-04 13:59:26 -05:00
|
|
|
|
|
|
|
# TODOfor some reason these don't propagate
|
|
|
|
if(NOT WIN32)
|
|
|
|
target_include_directories(${_name}
|
|
|
|
PUBLIC .)
|
|
|
|
target_compile_options(${_name}
|
|
|
|
PUBLIC ${_COMMON_CFLAGS})
|
|
|
|
endif()
|
2016-06-03 13:56:21 -05:00
|
|
|
endmacro()
|
2016-06-03 16:30:00 -05:00
|
|
|
add_subdirectory("test")
|
2016-06-03 18:25:43 -05:00
|
|
|
add_subdirectory("examples")
|