More cmake work.
This commit is contained in:
parent
05b542182a
commit
a3fe7edf3b
|
@ -1,6 +1,9 @@
|
||||||
# 3 june 2016
|
# 3 june 2016
|
||||||
cmake_minimum_required(VERSION 2.8.11)
|
cmake_minimum_required(VERSION 2.8.11)
|
||||||
|
|
||||||
|
# TODOs:
|
||||||
|
# - MSVC static linking does not include the .res file in out\, so executables lack the necessary
|
||||||
|
|
||||||
project(libui LANGUAGES C CXX)
|
project(libui LANGUAGES C CXX)
|
||||||
option(BUILD_SHARED_LIBS "Whether to build libui as a shared library or a static library" ON)
|
option(BUILD_SHARED_LIBS "Whether to build libui as a shared library or a static library" ON)
|
||||||
|
|
||||||
|
@ -22,14 +25,6 @@ else()
|
||||||
set(_OSNAME unix)
|
set(_OSNAME unix)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
# shared libraries link against system libs; executables don't
|
|
||||||
set(_LIBUI_LINKMODE PRIVATE)
|
|
||||||
else()
|
|
||||||
# static libraries don't link against system libs; executables do
|
|
||||||
set(_LIBUI_LINKMODE INTERFACE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# common flags
|
# common flags
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# TODO subsystem version
|
# TODO subsystem version
|
||||||
|
@ -82,8 +77,11 @@ target_compile_options(${_LIBUINAME}
|
||||||
PUBLIC ${_COMMON_CFLAGS}
|
PUBLIC ${_COMMON_CFLAGS}
|
||||||
PRIVATE ${_LIBUI_CFLAGS})
|
PRIVATE ${_LIBUI_CFLAGS})
|
||||||
# TODO link directories?
|
# TODO link directories?
|
||||||
target_link_libraries(${_LIBUINAME}
|
# because we need 2.8.11 for CentOS, we can't use target_link_libraries(INTERFACE) for static executables :(
|
||||||
${_LIBUI_LINKMODE} ${_LIBUI_LIBS})
|
if(BUILD_SHARED_LIBS)
|
||||||
|
target_link_libraries(${_LIBUINAME}
|
||||||
|
PRIVATE ${_LIBUI_LIBS})
|
||||||
|
endif()
|
||||||
# on Windows the linker for static libraries is different; don't give it the flags
|
# on Windows the linker for static libraries is different; don't give it the flags
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
_target_link_options_private(${_LIBUINAME}
|
_target_link_options_private(${_LIBUINAME}
|
||||||
|
@ -111,5 +109,14 @@ macro(_add_exec _name)
|
||||||
target_link_libraries(${_name} libui)
|
target_link_libraries(${_name} libui)
|
||||||
_target_link_options_private(${_name}
|
_target_link_options_private(${_name}
|
||||||
_COMMON_LDFLAGS)
|
_COMMON_LDFLAGS)
|
||||||
|
# make shared-linked executables PIC too
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
set_property(TARGET ${_name} PROPERTY
|
||||||
|
POSITION_INDEPENDENT_CODE True)
|
||||||
|
endif()
|
||||||
|
# because we need 2.8.11 for CentOS, we can't use target_link_libraries(PUBLIC) for static executables :(
|
||||||
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
|
target_link_libraries(${_name} ${_LIBUI_LIBS})
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
add_subdirectory("test")
|
add_subdirectory("test")
|
||||||
|
|
Loading…
Reference in New Issue