From f65caac1ce4ba7d00c4272ffd006cff85459cbd4 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 27 Mar 2019 00:56:43 -0400 Subject: [PATCH] More CMakeLists.txt cleanup. What's left in the top-level CMakeLists.txt is gonna take a while to put back properly... --- CMakeLists.txt | 77 +------------------------------------------------- meson.build | 1 + 2 files changed, 2 insertions(+), 76 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b87c8a3c..faf8b3ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,53 +2,6 @@ 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 # TODO figure out why FreeBSD follows linked libraries here # TODO figure out MSVC equivalents @@ -63,40 +16,12 @@ if(NOT MSVC) 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?! set_property(TARGET libui PROPERTY POSITION_INDEPENDENT_CODE True) 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 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() -add_subdirectory("test") -add_subdirectory("examples") diff --git a/meson.build b/meson.build index a2316428..3b7408ce 100644 --- a/meson.build +++ b/meson.build @@ -116,6 +116,7 @@ else 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 = [] if libui_mode == 'static' libui_project_compile_args += ['-D_UI_STATIC']