More CMakeLists.txt cleanup. What's left in the top-level CMakeLists.txt is gonna take a while to put back properly...
This commit is contained in:
parent
beba7470f4
commit
f65caac1ce
|
@ -2,53 +2,6 @@
|
||||||
|
|
||||||
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
|
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
|
||||||
|
|
||||||
# problem:
|
|
||||||
# - target_link_libraries() only supports - for flags
|
|
||||||
# - but cmake only doesn't generate the manifest if the flag has a /
|
|
||||||
macro(_target_link_options_private _target)
|
|
||||||
foreach(_opt IN LISTS ${ARGN})
|
|
||||||
set_property(TARGET ${_target} APPEND_STRING PROPERTY
|
|
||||||
LINK_FLAGS " ${_opt}")
|
|
||||||
endforeach()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
add_subdirectory("common")
|
|
||||||
add_subdirectory("${_OSNAME}")
|
|
||||||
add_library(libui ${_LIBUI_SOURCES})
|
|
||||||
target_include_directories(libui
|
|
||||||
PUBLIC .
|
|
||||||
PRIVATE ${_LIBUI_INCLUEDIRS})
|
|
||||||
target_compile_definitions(libui
|
|
||||||
PRIVATE ${_LIBUI_DEFS})
|
|
||||||
# cmake produces this for us by default but only for shared libraries
|
|
||||||
target_compile_definitions(libui
|
|
||||||
PRIVATE libui_EXPORTS)
|
|
||||||
target_compile_options(libui
|
|
||||||
PUBLIC ${_COMMON_CFLAGS}
|
|
||||||
PRIVATE ${_LIBUI_CFLAGS})
|
|
||||||
# TODO link directories?
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
target_link_libraries(libui
|
|
||||||
PRIVATE ${_LIBUI_LIBS})
|
|
||||||
endif()
|
|
||||||
# TODO INTERFACE libs don't inherit to grandhcildren?
|
|
||||||
# on Windows the linker for static libraries is different; don't give it the flags
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
_target_link_options_private(libui
|
|
||||||
_COMMON_LDFLAGS
|
|
||||||
_LIBUI_LDFLAGS)
|
|
||||||
endif()
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
# TODO figure out a way to tell libui that it's static
|
|
||||||
target_compile_definitions(libui
|
|
||||||
PUBLIC _UI_STATIC)
|
|
||||||
endif()
|
|
||||||
if(NOT MSVC)
|
|
||||||
# on non-MSVC compilers cmake adds an extra lib-
|
|
||||||
# note that we apply this to libui, not to any intermediates
|
|
||||||
set_target_properties(libui PROPERTIES
|
|
||||||
OUTPUT_NAME ui)
|
|
||||||
|
|
||||||
# flags for warning on undefined symbols
|
# flags for warning on undefined symbols
|
||||||
# TODO figure out why FreeBSD follows linked libraries here
|
# TODO figure out why FreeBSD follows linked libraries here
|
||||||
# TODO figure out MSVC equivalents
|
# TODO figure out MSVC equivalents
|
||||||
|
@ -63,40 +16,12 @@ if(NOT MSVC)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
if(_HASVERSION)
|
|
||||||
set_target_properties(libui PROPERTIES
|
|
||||||
SOVERSION "${_VERSION}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
# TODO why is this not a default?!
|
# TODO why is this not a default?!
|
||||||
set_property(TARGET libui PROPERTY
|
set_property(TARGET libui PROPERTY
|
||||||
POSITION_INDEPENDENT_CODE True)
|
POSITION_INDEPENDENT_CODE True)
|
||||||
|
|
||||||
macro(_add_exec _name)
|
macro(_add_exec _name)
|
||||||
# TODOTODO re-add WIN32 when merging back
|
|
||||||
add_executable(${_name}
|
|
||||||
EXCLUDE_FROM_ALL
|
|
||||||
${ARGN})
|
|
||||||
target_link_libraries(${_name} libui)
|
|
||||||
_target_link_options_private(${_name}
|
|
||||||
_COMMON_LDFLAGS)
|
|
||||||
# TODO does this propagate?
|
|
||||||
set_property(TARGET ${_name} PROPERTY
|
set_property(TARGET ${_name} PROPERTY
|
||||||
POSITION_INDEPENDENT_CODE True)
|
POSITION_INDEPENDENT_CODE True)
|
||||||
# TODO see above about INTERFACE
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
target_link_libraries(${_name}
|
|
||||||
${_LIBUI_LIBS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# TODOfor some reason these don't propagate
|
|
||||||
if(NOT WIN32)
|
|
||||||
target_include_directories(${_name}
|
|
||||||
PUBLIC .)
|
|
||||||
target_compile_options(${_name}
|
|
||||||
PUBLIC ${_COMMON_CFLAGS})
|
|
||||||
endif()
|
|
||||||
endmacro()
|
endmacro()
|
||||||
add_subdirectory("test")
|
|
||||||
add_subdirectory("examples")
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# TODO come up with a better way to do this, both for libui (the compiler define, used by winapi.hpp, and the manifest args) and for the binaries (the manifest args)
|
||||||
libui_manifest_args = []
|
libui_manifest_args = []
|
||||||
if libui_mode == 'static'
|
if libui_mode == 'static'
|
||||||
libui_project_compile_args += ['-D_UI_STATIC']
|
libui_project_compile_args += ['-D_UI_STATIC']
|
||||||
|
|
Loading…
Reference in New Issue